Created
November 30, 2013 09:07
-
-
Save mjason/7716847 to your computer and use it in GitHub Desktop.
androidannotations的android studo 配置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.6.+' | |
} | |
} | |
apply plugin: 'android' | |
repositories { | |
mavenCentral() | |
} | |
android { | |
compileSdkVersion 15 | |
buildToolsVersion "19.0.0" | |
defaultConfig { | |
minSdkVersion 14 | |
targetSdkVersion 19 | |
} | |
buildTypes { | |
release { | |
runProguard true | |
proguardFile getDefaultProguardFile('proguard-android-optimize.txt') | |
} | |
} | |
productFlavors { | |
defaultFlavor { | |
proguardFile 'proguard-rules.txt' | |
} | |
} | |
} | |
ext.androidAnnotationsVersion = '2.7.1' | |
configurations { | |
apt | |
} | |
dependencies { | |
compile 'com.android.support:support-v13:+' | |
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}" | |
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}" | |
} | |
def getSourceSetName(variant) { | |
return new File(variant.dirName).getName(); | |
} | |
android.applicationVariants.all { variant -> | |
def aptOutputDir = project.file("build/source/apt") | |
def aptOutput = new File(aptOutputDir, variant.dirName) | |
println "****************************" | |
println "variant: ${variant.name}" | |
println "manifest: ${variant.processResources.manifestFile}" | |
println "aptOutput: ${aptOutput}" | |
println "****************************" | |
android.sourceSets[getSourceSetName(variant)].java.srcDirs+= aptOutput.getPath() | |
variant.javaCompile.options.compilerArgs += [ | |
'-processorpath', configurations.apt.getAsPath(), | |
'-processor', 'com.googlecode.androidannotations.AndroidAnnotationProcessor', | |
'-AandroidManifestFile=' + variant.processResources.manifestFile, | |
'-s', aptOutput | |
] | |
variant.javaCompile.source += variant.javaCompile.source.filter { p -> | |
return !p.getPath().startsWith(aptOutputDir.getPath()) | |
} | |
variant.javaCompile.doFirst { | |
aptOutput.mkdirs() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment