Skip to content

Instantly share code, notes, and snippets.

@nickwph
Created June 13, 2016 14:52
Show Gist options
  • Save nickwph/fac980fd6cf4ef9415d5a35477646024 to your computer and use it in GitHub Desktop.
Save nickwph/fac980fd6cf4ef9415d5a35477646024 to your computer and use it in GitHub Desktop.
// temporarily solution: place generated code into source directory
project.afterEvaluate {
def variants
if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.test")) {
variants = project.android.applicationVariants
} else if (project.plugins.hasPlugin("com.android.library")) {
variants = project.android.libraryVariants
} else {
throw new Exception("The android application or library plugin must be applied to the project")
}
variants.all { variant ->
File file = project.file(new File(project.buildDir, "generated/source/annotationProcessor/${variant.name}"))
project.tasks.getByName("transformClassesWithPreJackPackagedLibrariesFor${variant.name.capitalize()}").doFirst {
file.mkdirs()
}
variant.addJavaSourceFoldersToModel(file)
variant.javaCompiler.transform.options.additionalParameters.put("jack.annotation-processor.source.output", file.absolutePath)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment