DEADSOFTWARE

Upgrade project
[cavedroid.git] / android / build.gradle
1 plugins {
2 id "kotlin-android"
3 }
5 android {
6 namespace "ru.deadsoftware.cavedroid"
7 compileSdkVersion 34
8 sourceSets {
9 main {
10 manifest.srcFile 'AndroidManifest.xml'
11 java.srcDirs = ['src']
12 aidl.srcDirs = ['src']
13 renderscript.srcDirs = ['src']
14 res.srcDirs = ['res']
15 assets.srcDirs = ['assets']
16 jniLibs.srcDirs = ['libs']
17 }
18 debug {
19 res.srcDirs = ['debug/res']
20 }
21 }
22 compileOptions {
23 sourceCompatibility 11
24 targetCompatibility 11
25 }
26 packagingOptions {
27 exclude 'META-INF/robovm/ios/robovm.xml'
28 }
29 defaultConfig {
30 applicationId "ru.deadsoftware.cavedroid"
31 minSdkVersion 24
32 targetSdkVersion 34
33 versionCode 10
34 versionName "alpha0.4"
35 }
36 applicationVariants.all { variant ->
37 variant.outputs.all {
38 outputFileName = "android-${versionName}.apk"
39 }
40 }
41 buildTypes {
42 release {
43 minifyEnabled false
44 }
45 debug {
46 applicationIdSuffix ".debug"
47 }
48 }
50 }
53 // called every time gradle gets executed, takes the native dependencies of
54 // the natives configuration, and extracts them to the proper libs/ folders
55 // so they get packed with the APK.
56 task copyAndroidNatives {
57 doFirst {
58 file("libs/armeabi/").mkdirs()
59 file("libs/armeabi-v7a/").mkdirs()
60 file("libs/arm64-v8a/").mkdirs()
61 file("libs/x86_64/").mkdirs()
62 file("libs/x86/").mkdirs()
64 configurations.natives.files.each { jar ->
65 def outputDir = null
66 if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
67 if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
68 if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
69 if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
70 if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
71 if(outputDir != null) {
72 copy {
73 from zipTree(jar)
74 into outputDir
75 include "*.so"
76 }
77 }
78 }
79 }
80 }
82 tasks.whenTaskAdded { packageTask ->
83 if (packageTask.name.contains("package")) {
84 packageTask.dependsOn 'copyAndroidNatives'
85 }
86 }
88 task run(type: Exec) {
89 def path
90 def localProperties = project.file("../local.properties")
91 if (localProperties.exists()) {
92 Properties properties = new Properties()
93 localProperties.withInputStream { instr ->
94 properties.load(instr)
95 }
96 def sdkDir = properties.getProperty('sdk.dir')
97 if (sdkDir) {
98 path = sdkDir
99 } else {
100 path = "$System.env.ANDROID_HOME"
102 } else {
103 path = "$System.env.ANDROID_HOME"
106 def adb = path + "/platform-tools/adb"
107 commandLine "$adb", 'shell', 'am', 'start', '-n', 'ru.deadsoftware.cavedroid/ru.deadsoftware.cavedroid.AndroidLauncher'