-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Generated unit test source files not being picked up by Android Studio #229
Comments
Just a small note here, if I add |
I take it this is expected behaviour? |
This should work and sounds like a bug. I'll schedule some time soon to fix this. |
I have done some more research into this as I wanted to provide a PR but I noticed a couple of things The method Also, even if I add the idea plugin to the project and the debugUnitTest generated sources are added to the ideaModel, I then refresh the gradle project in Android studio, the generated iml file still does not contain the sourcefolder line as mentioned above. I think this might be an Android Studio issue? Its weird though that the main generated source directory is picked up without issue. Any idea on why the test generated source directory is not being picked up but the main generated source directory is? |
Right, What happens if you apply the |
Yeah I tried doing that but it seems Android studio does not like that. It needs to generate the iml files itself by importing the project. I also tried adding an idea module definition in the I do think Android studio is doing some magic in the background that is different from a standard IntelliJ build. Just out of curiosity, has this been working without issues in previous Android Studio builds?
Im not sure this is the case nor do I think that Android Studio calls the idea plugin to generate the iml files. The reason I say this is because
Though I think the key here relates to the main generated sources. These are located under |
We have limited experience with Android, so we don't have much more data
than the unit tests. I'd like to dig into how Android Studio interacts with
the protobuf plugin. Would it be possible for you to share a simple project
that reproduces this problem?
…On Thu, May 31, 2018 at 11:34 PM Muzzah ***@***.***> wrote:
Yeah I tried doing that but it seems Android studio does not like that. It
needs to generate the iml files itself by importing the project. I also
tried adding an idea module definition in the build.gradle file to
specify the directory to add as a testSourceDirectory but that also did
not have an impact.
I do think Android studio is doing some magic in the background that is
different from a standard IntelliJ build. Just out of curiosity, has this
been working without issues in previous Android Studio builds?
Android Studio is built on top of intellij so I think this behavior is
fine.
Im not sure this is the case nor do I think that Android Studio calls the
idea plugin to generate the iml files. The reason I say this is because
1. Modifying the Idea model in my own build file has no impact on the
resulting iml files.
2. The IdeaModel instance that is returned by
project.getExtensions().findByType(IdeaModel) in the addToIdeSources
method is always null unless I specifically apply the idea plugin when
using Android Studio. But if from my own testing, if point 1 is true, then
the protobuf plugin modiyfing the IdeaModel will have no effect
either. Either that or AndroidStudio does some wacky things that wipes that
info out.
Though I think the key here relates to the main generated sources. These
are located under /build/generated/source/proto/debug/javalite and are
detected by the IDE as generated sources. If I can figure out why that is
being detected by Android Studio as a sources directory then maybe we can
figure how to do the same for the test sources directory.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#229 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACsG5LB9drkFOGS6SeP_0C_Q5uDsETZsks5t4OB3gaJpZM4UDFh5>
.
--
Spencer Fang
|
This may be the correct way to add source folders to Android studio: If it works, then the protobuf plugin should be using the same way to set it up for the Android plugin, rather than idea plugin. EDIT: this probably is not right, since the generated sources are not really the same as user created source sets. |
I'd also like to confirm whether |
Also with the link you shared, adding
into my android block in the build.gradle file does indeed work and Android studio see the generated files as a test source directory. |
Thanks for verifying. The reproduction test case is no longer needed. Do you happen to know whether there's a gradle task that generates the Android studio .iml files? That would allow us to add a unit test. So far I have been validating the behavior by handl |
Not that I am aware of but ill look into it |
Hi,
Im using the following setup
Android Studio 3.1.2
Android gradle plugin 3.1.2
Protobuf gradle plugin 0.8.5
Gradle 4.7
My protobuf configuration in my gradle file is as follows :
So all is pretty standard and up to date. Though when I add a proto file under
[moduleDir]/src/test/proto
directory, Android studio does not pick up the generated sources under the build directory and thus I cannot reference them. See the screen shot below :You can see that the debug folder is picked up which is from a proto file in the main (debug) source set but the files under debugUnitTest are not marked as a generated source directory. I tried applying the idea plugin and adding that directory but did not work. Is this expected behaviour?
The text was updated successfully, but these errors were encountered: