[Commits] SDL: Allow Android Java shim to be built as an AAR

libsdl.org revision control commits-owner at libsdl.org
Wed Feb 7 15:08:21 PST 2018


details:   https://hg.libsdl.org/SDL/rev/934d77867168
changeset: 11854:934d77867168
user:      Cole Campbell <cole.campbell at twistedlogik.net>
date:      Tue Jan 09 19:11:34 2018 -0500
description:
Allow Android Java shim to be built as an AAR

diffstat:

 android-project/app/build.gradle |  42 +++++++++++++++++++++++++++++++--------
 1 files changed, 33 insertions(+), 9 deletions(-)

diffs (71 lines):

diff -r c7946b873fe8 -r 934d77867168 android-project/app/build.gradle
--- a/android-project/app/build.gradle	Wed Feb 07 15:05:30 2018 -0800
+++ b/android-project/app/build.gradle	Tue Jan 09 19:11:34 2018 -0500
@@ -1,10 +1,19 @@
-apply plugin: 'com.android.application'
+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 16
     buildToolsVersion "26.0.1"
     defaultConfig {
-        applicationId "org.libsdl.app"
+        if (buildAsApplication) {
+            applicationId "org.libsdl.app"
+        }
         minSdkVersion 14
         targetSdkVersion 16
         versionCode 1
@@ -22,17 +31,32 @@
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
-    sourceSets.main {
-        jniLibs.srcDir 'libs'
-    }
-    externalNativeBuild {
-        ndkBuild {
-            path 'jni/Android.mk'
+    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);
+                }
+            }
+        }
+    }
 }
 
 dependencies {
@@ -41,4 +65,4 @@
         exclude group: 'com.android.support', module: 'support-annotations'
     })
     testCompile 'junit:junit:4.12'
-}
+}
\ No newline at end of file


More information about the commits mailing list