gradle-androidannotations-plugin
gradle-androidannotations-plugin copied to clipboard
Add support for the official Android Gradle plugin
http://tools.android.com/tech-docs/new-build-system/user-guide
Will this ever be done?
I've described how I hacked up my build.gradle directly here: https://github.com/excilys/androidannotations/issues/517#issuecomment-14355119
You can do the same thing until somebody who understands gradle better than I do makes a nice plugin.
I just found that, actually and ended up using it too :)
Thanks for your great work!
Just to update this issue, with the actual version of gradle (0.4.2) I'm using the following recipe in my gradle builds:
- for dependencies:
configurations {
apt
}
dependencies {
apt group: "com.googlecode.androidannotations", name: "androidannotations", version: "2.7.1"
compile group: "com.googlecode.androidannotations", name: "androidannotations-api", version: "2.7.1"
}
- to compile with AA support:
afterEvaluate {
android.applicationVariants.each { variant ->
def aptOutputDir = file("${project.buildDir}/source/apt/${variant.dirName}")
variant.javaCompile.doFirst {
aptOutputDir.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutputDir
]
}
}
}
I choose the build/sources/apt
because every generated code goes to build/sources
, e.g BuildConfig
and R
classes. This way I didn't need to configure extra clean paths and don't feel hacky IMO.
The only problem that I found was with Android Studio, which don't see the extra folder as a source root. To fix this issue I have to manually set the build/source/apt/debug
as source folder, and the IDE doesn't remember this configuration after restart/synching. Is annoying but doable.