1 apply plugin: 'android'
4 compile fileTree(include: '*.jar', dir: 'libs')
9 buildToolsVersion "21.1.2"
11 sourceCompatibility JavaVersion.VERSION_1_7
12 targetCompatibility JavaVersion.VERSION_1_7
16 manifest.srcFile 'AndroidManifest.xml'
17 java.srcDirs = ['src']
18 resources.srcDirs = ['src']
19 aidl.srcDirs = ['src']
20 renderscript.srcDirs = ['src']
22 assets.srcDirs = ['assets']
23 // jniLibs.srcDirs = ['jni']
24 jniLibs.srcDirs = ['libs']
25 jni.srcDirs = [] // disable automatic ndk-build call
28 // Move the tests to tests/java, tests/res, etc...
29 instrumentTest.setRoot('tests')
31 // Move the build types to build-types/<type>
32 // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
33 // This moves them out of them default location under src/<type>/... which would
34 // conflict with src/ being used by the main source set.
35 // Adding new build types or product flavors should be accompanied
36 // by a similar customization.
37 debug.setRoot('build-types/debug')
38 release.setRoot('build-types/release')
40 project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
41 //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
44 // put ndk-build in build's path, or replace below with its full path
45 task ndkBuild(type: Exec) {
46 Properties properties = new Properties()
47 properties.load(project.rootProject.file('local.properties').newDataInputStream())
48 def ndkDir = properties.getProperty('ndk.dir')
49 commandLine "$ndkDir/ndk-build", '-C', file('jni').absolutePath
52 // generate files early in the process
53 task perlBuild(type: Exec) {
54 commandLine 'sh', '-c',
55 'cd ../..; ../hacks/check-configs.pl --build-android $ANDROID_HACKS'
58 task perlClean(type: Delete) {
62 delete('src/org/jwz/xscreensaver/gen')
63 delete('AndroidManifest.xml')
66 task objlibClean(type: Delete) {
72 task downloadNeededDrawables(type: Exec) {
73 commandLine 'sh', '-c',
75 for f in $ANDROID_HACKS; do \
76 f=`echo "$f" | sed s/rd-bomb/rdbomb/` ; \
77 make -s project/xscreensaver/res/drawable/$f.png ; \
80 preBuild.dependsOn downloadNeededDrawables
82 preBuild.dependsOn perlBuild
84 task config_h(type: Exec) {
85 commandLine 'sh', '-c',
86 'if [ ! -s ../../../config.h ]; then \
87 echo "" >&2 ; echo "" >&2 ; \
88 echo "config.h does not exist. cd .. and run ./configure" >&2 ; \
93 preBuild.dependsOn config_h
95 clean.dependsOn perlClean
96 clean.dependsOn objlibClean
98 tasks.withType(JavaCompile) {
99 options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
102 tasks.withType(JavaCompile) {
103 compileTask -> compileTask.dependsOn ndkBuild