apply plugin: 'android' dependencies { implementation fileTree(include: '*.jar', dir: 'libs') implementation "com.android.support:support-v4:27.1.1" } android { compileSdkVersion 27 buildToolsVersion "27.0.3" 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... androidTest.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, '-j' + Runtime.getRuntime().availableProcessors().toString() } // 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 xscreensaver/res/drawable/$f.png ; \ done' } preBuild.dependsOn downloadNeededDrawables preBuild.dependsOn perlBuild clean.dependsOn perlClean clean.dependsOn objlibClean tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild } defaultConfig { // Previous applicationId was "org.jwz.xscreensaver" but I had // to change it because I managed to lose the signing key... // Note that the Java class tree is still "org.jwz.xscreensaver". applicationId "org.jwz.android.xscreensaver" minSdkVersion 15 targetSdkVersion 27 } productFlavors { } buildTypes { debug { jniDebuggable true } } }