build.gradle 4.1 KB

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