Last active
December 20, 2015 05:38
-
-
Save yageek/6079345 to your computer and use it in GitHub Desktop.
Android Annotations + Android Studio + Gradle
This file contains hidden or 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.7.+' | |
} | |
} | |
apply plugin: 'android' | |
repositories { | |
mavenCentral() | |
} | |
configurations { | |
apt | |
} | |
dependencies { | |
compile 'com.android.support:appcompat-v7:+' | |
compile 'org.androidannotations:androidannotations-api:3.0' | |
apt 'org.androidannotations:androidannotations:3.0' | |
} | |
android { | |
compileSdkVersion 19 | |
buildToolsVersion "19.0.1" | |
defaultConfig { | |
minSdkVersion 14 | |
targetSdkVersion 19 | |
} | |
buildTypes { | |
release { | |
runProguard false | |
proguardFile getDefaultProguardFile('proguard-android.txt') | |
} | |
} | |
productFlavors { | |
defaultFlavor { | |
proguardFile 'proguard-rules.txt' | |
} | |
} | |
signingConfigs { | |
myConfig { | |
storeFile file(project.property("MyProject.signing")) | |
storePassword "xxxxxxxxx" | |
keyAlias "yageek company" | |
keyPassword "xxxxxxxxxx" | |
} | |
} | |
buildTypes { | |
release { | |
signingConfig signingConfigs.myConfig | |
} | |
} | |
} | |
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(), | |
'-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