import java.util.concurrent.atomic.AtomicBoolean buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' } } final boolean buildNlpAsLib = name.equals('UnifiedNlpLib') if (buildNlpAsLib) { apply plugin: 'com.android.library' } else { apply plugin: 'com.android.application' } 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); } } }; } android { compileSdkVersion 21 buildToolsVersion "21.0.2" lintOptions.abortOnError false sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] aidl.srcDirs = ['src'] res.srcDirs = ['res'] } } if (!buildNlpAsLib) { productFlavors { NetworkLocation { applicationId = 'com.google.android.gms' minSdkVersion 19 } LegacyNetworkLocation { applicationId = 'com.google.android.location' } UnifiedNlp { applicationId = 'org.microg.nlp' } } } } if (file('user.gradle').exists()) { apply from: 'user.gradle' }