DEADSOFTWARE

bf1af009dae215b66422a87bff325fc37e8d50f4
[cavedroid.git] / android / build.gradle
1 buildscript {
2 configurations { natives }
3 }
5 plugins {
6 id "com.android.application"
7 id "kotlin-android"
8 }
10 def keystorePropertiesFile = rootProject.file("keystore.properties")
11 def keystoreProperties = new Properties()
12 keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
14 android {
15 namespace "ru.deadsoftware.cavedroid"
16 compileSdkVersion 34
17 sourceSets {
18 main {
19 manifest.srcFile 'AndroidManifest.xml'
20 java.srcDirs = ['src']
21 aidl.srcDirs = ['src']
22 renderscript.srcDirs = ['src']
23 res.srcDirs = ['res']
24 assets.srcDirs = ['assets']
25 jniLibs.srcDirs = ['libs']
26 }
27 debug {
28 res.srcDirs = ['debug/res']
29 }
30 }
31 compileOptions {
32 sourceCompatibility 17
33 targetCompatibility 17
34 }
35 packagingOptions {
36 exclude 'META-INF/robovm/ios/robovm.xml'
37 }
38 defaultConfig {
39 applicationId "ru.deadsoftware.cavedroid"
40 minSdkVersion 24
41 targetSdkVersion 34
42 versionCode 25
43 versionName "alpha0.9.2"
44 }
45 applicationVariants.all { variant ->
46 variant.outputs.all {
47 outputFileName = "android-${versionName}.apk"
48 }
49 }
51 signingConfigs {
52 release_config {
53 storeFile file(keystoreProperties['releaseKeystorePath'])
54 storePassword keystoreProperties['releaseKeystorePassword']
55 keyAlias keystoreProperties['releaseKeyAlias']
56 keyPassword keystoreProperties['releaseKeyPassword']
57 }
58 }
60 buildTypes {
61 release {
62 minifyEnabled false
63 signingConfig signingConfigs.release_config
64 }
65 debug {
66 applicationIdSuffix ".debug"
67 }
68 }
69 buildFeatures {
70 buildConfig true
71 }
73 }
76 // called every time gradle gets executed, takes the native dependencies of
77 // the natives configuration, and extracts them to the proper libs/ folders
78 // so they get packed with the APK.
79 task copyAndroidNatives {
80 doFirst {
81 file("libs/armeabi/").mkdirs()
82 file("libs/armeabi-v7a/").mkdirs()
83 file("libs/arm64-v8a/").mkdirs()
84 file("libs/x86_64/").mkdirs()
85 file("libs/x86/").mkdirs()
87 configurations.natives.files.each { jar ->
88 def outputDir = null
89 if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
90 if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
91 if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
92 if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
93 if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
94 if(outputDir != null) {
95 copy {
96 from zipTree(jar)
97 into outputDir
98 include "*.so"
99 }
105 tasks.whenTaskAdded { packageTask ->
106 if (packageTask.name.contains("package")) {
107 packageTask.dependsOn 'copyAndroidNatives'
111 task run(type: Exec) {
112 def path
113 def localProperties = project.file("../local.properties")
114 if (localProperties.exists()) {
115 Properties properties = new Properties()
116 localProperties.withInputStream { instr ->
117 properties.load(instr)
119 def sdkDir = properties.getProperty('sdk.dir')
120 if (sdkDir) {
121 path = sdkDir
122 } else {
123 path = "$System.env.ANDROID_HOME"
125 } else {
126 path = "$System.env.ANDROID_HOME"
129 def adb = path + "/platform-tools/adb"
130 commandLine "$adb", 'shell', 'am', 'start', '-n', 'ru.deadsoftware.cavedroid/ru.deadsoftware.cavedroid.AndroidLauncher'
133 dependencies {
134 implementation project(":core")
135 implementation platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion")
136 api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
137 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
138 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
139 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
140 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
142 configurations.implementation {
143 exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'