How do the build/src/xxx/<variant> paths get added to the source path? Is that something I could use to get generated source from annotations to the build path too? I'm still looking for a way to tell Android Studio through the Gradle model to add a source path...
one plus one
Shared publicly•View activity
View 4 previous comments
- Because of the common apt_generated folder I guess?Jun 25, 2013
- Xavier DucrohetModeratorActually I'm not sure. When you pass for the folder to the compiler args, I'm not sure what the task will do. It may not be used as a "file" input (vs. an input string) so emptying it may not have any issue.
Although the fact that you are changing the source folders after the task is set to run or not in the doFirst may have weird side-effects, especially when compiling more than one variants since they share that folder.Jun 25, 2013
- Hmm, I'm not getting how the variants work I guess, I thought each variant was a unique compilation with it's respective compileTask, but that's not the case?
I have an gist here that generates apt to a separate folder based on the variant: https://gist.github.com/hvisser/2679c5c8f983c9a15564
Compiling this twice makes gradle say "up to date" so that's all good I suppose.
But this has the issue that I don't think I can deduce the correct source set to add the generated source to per variant....Jun 25, 2013
- Xavier DucrohetModeratoryou are right but you are using the same folder for all the variants since you are adding it to android.sourceSets.main so clearing it between runs may have an effect since Gradle records the input/output of each task for each run to figure out if something changed.
Your new gist looks better, but you want to add to the sourceSets first, since looping on the build variants creates the task, so you are adding them too late (we are fixing this issue).Jun 25, 2013
- Thanks Xavier, actually I'd only need a dummy source set for studio to pick up. The gradle build works fine as is. I'll fiddle some more with it later...Jun 26, 2013
- I've settled on this for now https://bitbucket.org/qbusict/android-gradle-scripts/src/686ce2301245ab1f0e6a32fb20b4d246ef742223/annotations.groovy?at=default, it seems to work OK, also when using flavors, but I've given it some light testing only. I pull this into my projects and use apply from: to include it at the end of the build file.Jun 26, 2013