我已经能够使用gradle(以及Dagger)成功运行AndroidAnnotations,但是当我尝试将storm-apt添加到生成器时,gradle会无声地失败,跳过所有注释处理。
这是一个示例build.gradle,它可以工作(即运行aa apt处理器,但不是暴风雨处理器)而不包含storm-apt jar,但是会失败(即无法同时运行aa apt处理器,以及风暴处理器):
import groovy.io.FileType
apply plugin: 'android'
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
repositories {
mavenCentral()
}
ext.androidAnnotationsVersion = '2.7.1'
configurations {
apt
}
dependencies {
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}"
// commenting out the following line will allow the aa apt processor to complete,
// while leaving it uncommented will cause all annotation processing,
// both aa and storm to silently fail
apt files('libs/storm-apt-0.97.jar')
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
compile files('libs/storm-api-0.97.jar')
}
afterEvaluate { project ->
android.applicationVariants.each { variant ->
variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
ext.aptOutput = file("${project.buildDir}/source/r/${variant.dirName}")
aptOutput.mkdirs()
aptOutput.eachFileRecurse FileType.FILES, {
if (it.name.equals('R.java')) {
return
}
it.delete()
}
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-s', aptOutput
]
println "*** ${variant.javaCompile.options.compilerArgs}"
}
}
}