build.gradle 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. plugins {
  2. id 'com.android.application'
  3. }
  4. android {
  5. compileSdk 31
  6. ndkVersion '25.2.9519653'
  7. defaultConfig {
  8. applicationId "is.xyz.vcmi"
  9. minSdk 19
  10. targetSdk 31
  11. versionCode 1400
  12. versionName "1.4.0"
  13. setProperty("archivesBaseName", "vcmi")
  14. }
  15. signingConfigs {
  16. releaseSigning
  17. dailySigning
  18. LoadSigningConfig("releaseSigning")
  19. LoadSigningConfig("dailySigning")
  20. }
  21. buildTypes {
  22. debug {
  23. debuggable true
  24. applicationIdSuffix '.debug'
  25. manifestPlaceholders = [
  26. applicationLabel: 'VCMI debug',
  27. ]
  28. ndk {
  29. debugSymbolLevel 'full'
  30. }
  31. }
  32. release {
  33. minifyEnabled false
  34. zipAlignEnabled true
  35. signingConfig signingConfigs.releaseSigning
  36. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  37. manifestPlaceholders = [
  38. applicationLabel: '@string/app_name',
  39. ]
  40. ndk {
  41. debugSymbolLevel 'symbol_table'
  42. }
  43. }
  44. daily {
  45. initWith release
  46. applicationIdSuffix '.daily'
  47. signingConfig signingConfigs.dailySigning
  48. manifestPlaceholders = [
  49. applicationLabel: 'VCMI daily',
  50. ]
  51. }
  52. }
  53. applicationVariants.all { variant -> RenameOutput(project.archivesBaseName, variant) }
  54. tasks.withType(JavaCompile) {
  55. options.compilerArgs += ["-Xlint:deprecation"]
  56. }
  57. compileOptions {
  58. sourceCompatibility JavaVersion.VERSION_1_8
  59. targetCompatibility JavaVersion.VERSION_1_8
  60. }
  61. buildFeatures {
  62. viewBinding true
  63. dataBinding true
  64. }
  65. }
  66. def RenameOutput(final baseName, final variant) {
  67. final def buildTaskId = System.getenv("GITHUB_RUN_ID")
  68. ResolveGitInfo()
  69. def name = baseName + "-" + ext.gitInfoVcmi
  70. if (buildTaskId != null && !buildTaskId.isEmpty()) {
  71. name = buildTaskId + "-" + name
  72. }
  73. if (!variant.buildType.name != "release") {
  74. name += "-" + variant.buildType.name
  75. }
  76. variant.outputs.each { output ->
  77. def oldPath = output.outputFile.getAbsolutePath()
  78. output.outputFileName = name + oldPath.substring(oldPath.lastIndexOf("."))
  79. }
  80. }
  81. def CommandOutput(final cmd, final arguments, final cwd) {
  82. try {
  83. new ByteArrayOutputStream().withStream { final os ->
  84. exec {
  85. executable cmd
  86. args arguments
  87. workingDir cwd
  88. standardOutput os
  89. }
  90. return os.toString().trim()
  91. }
  92. }
  93. catch (final Exception ex) {
  94. print("Broken: " + cmd + " " + arguments + " in " + cwd + " :: " + ex.toString())
  95. return ""
  96. }
  97. }
  98. def ResolveGitInfo() {
  99. if (ext.gitInfoVcmi != "none") {
  100. return
  101. }
  102. ext.gitInfoVcmi =
  103. CommandOutput("git", ["log", "-1", "--pretty=%D", "--decorate-refs=refs/remotes/origin/*"], ".").replace("origin/", "").replace(", HEAD", "").replaceAll("[^a-zA-Z0-9\\-_]", "_") +
  104. "-" +
  105. CommandOutput("git", ["describe", "--match=", "--always", "--abbrev=7"], ".")
  106. }
  107. def SigningPropertiesPath(final basePath, final signingConfigKey) {
  108. return file("${basePath}/${signingConfigKey}.properties")
  109. }
  110. def SigningKeystorePath(final basePath, final keystoreFileName) {
  111. return file("${basePath}/${keystoreFileName}")
  112. }
  113. def LoadSigningConfig(final signingConfigKey) {
  114. final def projectRoot = "${project.projectDir}/../../CI/android"
  115. final def props = new Properties()
  116. final def propFile = SigningPropertiesPath(projectRoot, signingConfigKey)
  117. def signingConfig = android.signingConfigs.getAt(signingConfigKey)
  118. if (propFile.canRead()) {
  119. props.load(new FileInputStream(propFile))
  120. if (props != null
  121. && props.containsKey('STORE_FILE')
  122. && props.containsKey('KEY_ALIAS')) {
  123. signingConfig.storeFile = SigningKeystorePath(projectRoot, props['STORE_FILE'])
  124. signingConfig.storePassword = props['STORE_PASSWORD']
  125. signingConfig.keyAlias = props['KEY_ALIAS']
  126. if(props.containsKey('STORE_PASSWORD'))
  127. signingConfig.storePassword = props['STORE_PASSWORD']
  128. else
  129. signingConfig.storePassword = System.getenv("ANDROID_STORE_PASSWORD")
  130. if(props.containsKey('KEY_PASSWORD'))
  131. signingConfig.keyPassword = props['KEY_PASSWORD']
  132. else
  133. signingConfig.keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
  134. } else {
  135. println("Some props from signing file are missing")
  136. android.signingConfigs.putAt(signingConfigKey, null)
  137. }
  138. } else {
  139. println("file with signing properties is missing")
  140. android.signingConfigs.putAt(signingConfigKey, null)
  141. }
  142. }
  143. dependencies {
  144. implementation 'androidx.appcompat:appcompat:1.2.0'
  145. implementation 'com.google.android.material:material:1.3.0'
  146. implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  147. implementation 'com.google.android.gms:play-services-base:18.2.0'
  148. implementation 'com.google.android.gms:play-services-basement:18.1.0'
  149. }