Gradle: Update build tools, less dirty approach for compat library (supported by IDEs)
This commit is contained in:
parent
a22b5f488c
commit
0eadcc1882
30
build.gradle
30
build.gradle
|
@ -1,5 +1,3 @@
|
|||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -21,36 +19,12 @@ 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 {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue