DEADSOFTWARE

External keystore properties
[cavedroid.git] / android / build.gradle
1 plugins {
2 id "kotlin-android"
3 }
5 def keystorePropertiesFile = rootProject.file("keystore.properties")
6 def keystoreProperties = new Properties()
7 keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
9 android {
10 namespace "ru.deadsoftware.cavedroid"
11 compileSdkVersion 34
12 sourceSets {
13 main {
14 manifest.srcFile 'AndroidManifest.xml'
15 java.srcDirs = ['src']
16 aidl.srcDirs = ['src']
17 renderscript.srcDirs = ['src']
18 res.srcDirs = ['res']
19 assets.srcDirs = ['assets']
20 jniLibs.srcDirs = ['libs']
21 }
22 debug {
23 res.srcDirs = ['debug/res']
24 }
25 }
26 compileOptions {
27 sourceCompatibility 17
28 targetCompatibility 17
29 }
30 packagingOptions {
31 exclude 'META-INF/robovm/ios/robovm.xml'
32 }
33 defaultConfig {
34 applicationId "ru.deadsoftware.cavedroid"
35 minSdkVersion 24
36 targetSdkVersion 34
37 versionCode 16
38 versionName "alpha0.5.2"
39 }
40 applicationVariants.all { variant ->
41 variant.outputs.all {
42 outputFileName = "android-${versionName}.apk"
43 }
44 }
46 signingConfigs {
47 debug_config {
48 storeFile file(keystoreProperties['debugKeystorePath'])
49 storePassword keystoreProperties['debugKeystorePassword']
50 keyAlias keystoreProperties['debugKeyAlias']
51 keyPassword keystoreProperties['debugKeyPassword']
52 }
53 release_config {
54 storeFile file(keystoreProperties['releaseKeystorePath'])
55 storePassword keystoreProperties['releaseKeystorePassword']
56 keyAlias keystoreProperties['releaseKeyAlias']
57 keyPassword keystoreProperties['releaseKeyPassword']
58 }
59 }
61 buildTypes {
62 release {
63 minifyEnabled false
64 signingConfig signingConfigs.release_config
65 }
66 debug {
67 applicationIdSuffix ".debug"
68 signingConfig signingConfigs.debug_config
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'