Gradle: Update build tools, less dirty approach for compat library (supported by IDEs)

This commit is contained in:
mar-v-in 2015-01-14 16:56:54 +01:00
parent a22b5f488c
commit 0eadcc1882
2 changed files with 12 additions and 52 deletions

View File

@ -1,5 +1,3 @@
import java.util.concurrent.atomic.AtomicBoolean
buildscript {
repositories {
mavenCentral()
@ -21,40 +19,16 @@ dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':UnifiedNlpApi')
}
/**
* This is a dirty approach to add a compile-time module that is not build into the APK.
* Doing everything in the beginning will break other dependencies, so we first compile the module
* and then configure gradle to change the compile classpath before compiling
*/
tasks.getByName('preBuild').dependsOn += 'compatSetup'
task compatSetup(dependsOn: [project('compat').path + ':assembleDebug', project('compat').path + ':assembleRelease']) << {
final AtomicBoolean classpathSet = new AtomicBoolean(false);
tasks.findAll { it.name.startsWith('compile') && it.name.endsWith('Java') }.each {
it.doFirst {
if (!classpathSet.get()) {
def variants;
if (buildNlpAsLib) variants = android.libraryVariants;
else variants = android.applicationVariants;
variants.all {
it.javaCompile.classpath += project('compat').files('build/intermediates/bundles/' + (it.name.endsWith('ebug') ? 'debug' : 'release') + '/classes.jar');
};
classpathSet.set(true);
}
}
};
provided project('compat')
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
buildToolsVersion "21.1.2"
lintOptions.abortOnError false
sourceSets {
main {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']

View File

@ -1,24 +1,10 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
lintOptions.abortOnError false
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['v9/src', 'current/src']
aidl.srcDirs = ['v9/src', 'current/src']
}
}
apply plugin: 'java'
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def sdkDir = properties.getProperty('sdk.dir')
sourceSets.main {
java.srcDirs = ['current/src', 'v9/src']
compileClasspath += project.rootProject.files("$sdkDir/platforms/android-21/android.jar")
}