apply plugin: 'android' dependencies { compile fileTree(include: '*.jar', dir: 'libs') } android { compileSdkVersion 21 buildToolsVersion "21.1.2" compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] // jniLibs.srcDirs = ['jni'] jniLibs.srcDirs = ['libs'] jni.srcDirs = [] // disable automatic ndk-build call } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/ // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src//... which would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be accompanied // by a similar customization. debug.setRoot('build-types/debug') release.setRoot('build-types/release') } project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9] //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-* // put ndk-build in build's path, or replace below with its full path task ndkBuild(type: Exec) { Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') commandLine "$ndkDir/ndk-build", '-C', file('jni').absolutePath } // generate files early in the process task perlBuild(type: Exec) { commandLine 'sh', '-c', 'cd ../..; ../hacks/check-configs.pl --build-android $ANDROID_HACKS' } task perlClean(type: Delete) { delete('../../gen') delete('res/values') delete('res/xml') delete('src/org/jwz/xscreensaver/gen') delete('AndroidManifest.xml') } task objlibClean(type: Delete) { delete('./build') delete('./libs') delete('./obj') } task downloadNeededDrawables(type: Exec) { commandLine 'sh', '-c', 'cd ../../ ; \ for f in $ANDROID_HACKS; do \ f=`echo "$f" | sed s/rd-bomb/rdbomb/` ; \ make -s project/xscreensaver/res/drawable/$f.png ; \ done' } preBuild.dependsOn downloadNeededDrawables preBuild.dependsOn perlBuild task config_h(type: Exec) { commandLine 'sh', '-c', 'if [ ! -s ../../../config.h ]; then \ echo "" >&2 ; echo "" >&2 ; \ echo "config.h does not exist. cd .. and run ./configure" >&2 ; \ echo "" >&2 ; \ exit 1 ; \ fi' } preBuild.dependsOn config_h clean.dependsOn perlClean clean.dependsOn objlibClean tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild } defaultConfig { minSdkVersion 15 targetSdkVersion 21 } productFlavors { } buildTypes { debug { jniDebuggable true } } }