DEADSOFTWARE

d52b9e92d650e7802b3bdfd545bedb0fbbeb6301
[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 19
41 targetSdkVersion 34
42 versionCode 25
43 versionName "alpha0.9.2"
45 multiDexEnabled true
46 }
47 applicationVariants.all { variant ->
48 variant.outputs.all {
49 outputFileName = "android-${versionName}.apk"
50 }
51 }
53 signingConfigs {
54 release_config {
55 storeFile file(keystoreProperties['releaseKeystorePath'])
56 storePassword keystoreProperties['releaseKeystorePassword']
57 keyAlias keystoreProperties['releaseKeyAlias']
58 keyPassword keystoreProperties['releaseKeyPassword']
59 }
60 }
62 buildTypes {
63 release {
64 minifyEnabled false
65 signingConfig signingConfigs.release_config
66 }
67 debug {
68 applicationIdSuffix ".debug"
69 }
70 }
71 buildFeatures {
72 buildConfig true
73 }
75 }
78 // called every time gradle gets executed, takes the native dependencies of
79 // the natives configuration, and extracts them to the proper libs/ folders
80 // so they get packed with the APK.
81 task copyAndroidNatives {
82 doFirst {
83 file("libs/armeabi/").mkdirs()
84 file("libs/armeabi-v7a/").mkdirs()
85 file("libs/arm64-v8a/").mkdirs()
86 file("libs/x86_64/").mkdirs()
87 file("libs/x86/").mkdirs()
89 configurations.natives.files.each { jar ->
90 def outputDir = null
91 if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
92 if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
93 if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
94 if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
95 if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
96 if(outputDir != null) {
97 copy {
98 from zipTree(jar)
99 into outputDir
100 include "*.so"
107 tasks.whenTaskAdded { packageTask ->
108 if (packageTask.name.contains("package")) {
109 packageTask.dependsOn 'copyAndroidNatives'
113 task run(type: Exec) {
114 def path
115 def localProperties = project.file("../local.properties")
116 if (localProperties.exists()) {
117 Properties properties = new Properties()
118 localProperties.withInputStream { instr ->
119 properties.load(instr)
121 def sdkDir = properties.getProperty('sdk.dir')
122 if (sdkDir) {
123 path = sdkDir
124 } else {
125 path = "$System.env.ANDROID_HOME"
127 } else {
128 path = "$System.env.ANDROID_HOME"
131 def adb = path + "/platform-tools/adb"
132 commandLine "$adb", 'shell', 'am', 'start', '-n', 'ru.deadsoftware.cavedroid/ru.deadsoftware.cavedroid.AndroidLauncher'
135 dependencies {
136 implementation project(":core")
137 implementation platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion")
138 api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
139 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
140 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
141 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
142 natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
144 configurations.implementation {
145 exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'