Add Gradle (simple and for android) Project Configurator
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
apply plugin: 'android'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 15
|
||||
buildToolsVersion "17.0"
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
}
|
||||
|
||||
// query for all (non-test) variants and inject a new step in the builds
|
||||
android.applicationVariants.each { variant ->
|
||||
// create a task that "handles" the compile classes
|
||||
// does some processing (or not)
|
||||
// and outputs a jar
|
||||
def jarTask = tasks.add(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.sourceFiles = files(jarTask.archivePath).files
|
||||
}
|
||||
|
||||
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!")
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '$VERSION$'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.5.+'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$ext.kotlin_version"
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$ext.kotlin_version"
|
||||
}
|
||||
Reference in New Issue
Block a user