Skip to content

Commit

Permalink
Allow Android Java shim to be built as an AAR
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgkccampbell committed Jan 10, 2018
1 parent 940933d commit b401cfd
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions android-project/app/build.gradle
@@ -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
Expand All @@ -22,17 +31,32 @@ android {
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 {
Expand All @@ -41,4 +65,4 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}
}

0 comments on commit b401cfd

Please sign in to comment.