blob: 28117f1785c9a75e7c09323c6da9d5cfbf905746 [file] [log] [blame]
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
}
// query for all (non-test) variants and inject a new step in the builds
android.applicationVariants.all { variant ->
// create a task that "handles" the compile classes
// does some processing (or not)
// and outputs a jar
def jarTask = tasks.create(name: "jar${variant.name.capitalize()}", type: Jar) {
from variant.javaCompile.destinationDir
destinationDir file("${buildDir}/jars/${variant.dirName}")
baseName "classes"
}
// this task depends on the compilation task
jarTask.dependsOn variant.javaCompile
// now make the dex task depend on it and use its output
variant.dex.dependsOn jarTask
variant.dex.inputFiles = files(jarTask.archivePath).files
}
project.afterEvaluate {
if (android.applicationVariants.size() != 2) {
throw new GradleException("Wrong number of app variants!")
}
if (android.testVariants.size() != 1) {
throw new GradleException("Wrong number of test variants!")
}
}