changed build system for Android from Ant to Gradle
[rocksndiamonds.git] / build-projects / android / app / build.gradle.tmpl
diff --git a/build-projects/android/app/build.gradle.tmpl b/build-projects/android/app/build.gradle.tmpl
new file mode 100644 (file)
index 0000000..68c234b
--- /dev/null
@@ -0,0 +1,74 @@
+def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
+def buildAsApplication = !buildAsLibrary
+if (buildAsApplication) {
+    apply plugin: 'com.android.application'
+}
+else {
+    apply plugin: 'com.android.library'
+}
+
+android {
+    compileSdkVersion 26
+
+    defaultConfig {
+        if (buildAsApplication) {
+            applicationId "org.artsoft.rocksndiamonds"
+        }
+
+        minSdkVersion 17
+        targetSdkVersion 26
+
+        versionCode  __VERSION_CODE__
+        versionName "__VERSION_NAME__"
+
+        externalNativeBuild {
+            ndkBuild {
+                arguments "APP_PLATFORM=android-17"
+                abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
+            }
+        }
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
+        sourceSets.main {
+            jniLibs.srcDir 'libs'
+        }
+
+        externalNativeBuild {
+            ndkBuild {
+                path 'jni/Android.mk'
+            }
+        }
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+
+    if (buildAsLibrary) {
+        libraryVariants.all { variant ->
+            variant.outputs.each { output ->
+                def outputFile = output.outputFile
+                if (outputFile != null && outputFile.name.endsWith(".aar")) {
+                    def fileName = "org.libsdl.app.aar";
+                    output.outputFile = new File(outputFile.parent, fileName);
+                }
+            }
+        }
+    }
+
+    aaptOptions {
+        ignoreAssetsPattern ""
+    }
+}
+
+dependencies {
+    implementation fileTree(include: ['*.jar'], dir: 'libs')
+}