diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-19 20:22:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-19 20:22:09 +0200 |
commit | f9db6ad8c5a37dcfdc1ba8d3f1ddd0ddb05845b0 (patch) | |
tree | b01da6cdc8c280b5724fd848753f03b9c29dbd86 /platform/android/java/lib/build.gradle | |
parent | af51fbd994f1f5ece1f50617cb1aaf41369b8574 (diff) | |
parent | f2d203a8a413c3a58ac2761b76323f39bd88b356 (diff) |
Merge pull request #31919 from m4gr3d/use_aar_for_custom_build
Leverage Android archive (AAR) file for Godot custom build
Diffstat (limited to 'platform/android/java/lib/build.gradle')
-rw-r--r-- | platform/android/java/lib/build.gradle | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/platform/android/java/lib/build.gradle b/platform/android/java/lib/build.gradle new file mode 100644 index 0000000000..6d07504e45 --- /dev/null +++ b/platform/android/java/lib/build.gradle @@ -0,0 +1,91 @@ +apply plugin: 'com.android.library' + +dependencies { + implementation "com.android.support:support-core-utils:28.0.0" +} + +def pathToRootDir = "../../../../" +// Note: Only keep the abis you support to speed up the gradle 'assemble' task. +def supportedAbis = ["armv7", "arm64v8", "x86", "x86_64"] + +android { + compileSdkVersion versions.compileSdk + buildToolsVersion versions.buildTools + useLibrary 'org.apache.http.legacy' + + defaultConfig { + minSdkVersion versions.minSdk + targetSdkVersion versions.targetSdk + } + + lintOptions { + abortOnError false + disable 'MissingTranslation', 'UnusedResources' + } + + packagingOptions { + exclude 'META-INF/LICENSE' + exclude 'META-INF/NOTICE' + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + res.srcDirs = ['res'] + aidl.srcDirs = ['aidl'] + assets.srcDirs = ['assets'] + } + debug.jniLibs.srcDirs = ['libs/debug'] + release.jniLibs.srcDirs = ['libs/release'] + } + + libraryVariants.all { variant -> + variant.outputs.all { output -> + output.outputFileName = "godot-lib.${variant.name}.aar" + } + + def buildType = variant.buildType.name.capitalize() + + def taskPrefix = "" + if (project.path != ":") { + taskPrefix = project.path + ":" + } + + // Disable the externalNativeBuild* task as it would cause build failures since the cmake build + // files is only setup for editing support. + gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType + + // Create tasks to generate the Godot native libraries. + def taskName = "compileGodotNativeLibs" + buildType + def releaseTarget = "release" + if (buildType == "Debug") { + releaseTarget += "_debug" + } + + def abiTaskNames = [] + // Creating gradle tasks to generate the native libraries for the supported abis. + supportedAbis.each { abi -> + def abiTaskName = taskName + abi.capitalize() + abiTaskNames += abiTaskName + tasks.create(name: abiTaskName, type: Exec) { + executable "scons" + args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${abi}" + } + } + + // Creating gradle task to run all of the previously generated tasks. + tasks.create(name: taskName, type: GradleBuild) { + tasks = abiTaskNames + } + + // Schedule the tasks so the generated libs are present before the aar file is packaged. + tasks["merge${buildType}JniLibFolders"].dependsOn taskName + } + + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +} |