I use code generation in my gradle build. Building works fine from both
command line and Android Studio via Build-> Make Project. However, Android
studio shows many error markers in files which reference symbols of the
generated code. My first attempt at build.gradle was:
apply plugin: 'com.android.library'
android {
sourceSets {
main.java.srcDir "$buildDir/source-generated"
}
}
task ragel(type:Exec) {
File outputDir = file("$buildDir/source-generated/blah")
... stuff ...
doFirst {
outputDir.exists() || outputDir.mkdirs()
}
}
preBuild.dependsOn ragel
... and this was fine. But to fix the errors in AS editors, I added
android.libraryVariants.all { variant ->
variant.addJavaSourceFoldersToModel(file("$buildDir/source-generated"))
}
Unfortunately, it seems like I need both addJavaSourceFoldersToModel AND
main.java.srcDir "$buildDir/source-generated".
If I leave out the former, error markers galore. If I leave out the latter,
it doesn't build at all. So it seems I need both - yet the examples do not
modify the sourceSet.
Anyone know what could be happening here ? I thought
addJavaSourceFoldersToModel should be sufficient.
--
You received this message because you are subscribed to the Google Groups
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.