build.gradle 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion 33
  4. buildToolsVersion '33.0.2'
  5. ndkVersion "$ndk_version"
  6. defaultConfig {
  7. applicationId 'net.minetest.minetest'
  8. minSdkVersion 21
  9. targetSdkVersion 33
  10. versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  11. versionCode project.versionCode
  12. }
  13. // load properties
  14. Properties props = new Properties()
  15. def propfile = file('../local.properties')
  16. if (propfile.exists())
  17. props.load(new FileInputStream(propfile))
  18. if (props.getProperty('keystore') != null) {
  19. signingConfigs {
  20. release {
  21. storeFile file(props['keystore'])
  22. storePassword props['keystore.password']
  23. keyAlias props['key']
  24. keyPassword props['key.password']
  25. }
  26. }
  27. buildTypes {
  28. release {
  29. minifyEnabled true
  30. signingConfig signingConfigs.release
  31. }
  32. }
  33. }
  34. // for multiple APKs
  35. splits {
  36. abi {
  37. enable true
  38. reset()
  39. include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
  40. }
  41. }
  42. compileOptions {
  43. sourceCompatibility JavaVersion.VERSION_1_8
  44. targetCompatibility JavaVersion.VERSION_1_8
  45. }
  46. }
  47. task prepareAssets() {
  48. def assetsFolder = "build/assets"
  49. def projRoot = rootDir.parent
  50. // See issue #4638
  51. def unsupportedLanguages = new File("${projRoot}/src/unsupported_language_list.txt").text.readLines()
  52. doFirst {
  53. logger.lifecycle('Preparing assets at {}', assetsFolder)
  54. }
  55. doLast {
  56. copy {
  57. from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder
  58. }
  59. copy {
  60. from "${projRoot}/doc/lgpl-2.1.txt" into assetsFolder
  61. }
  62. copy {
  63. from "${projRoot}/builtin" into "${assetsFolder}/builtin"
  64. }
  65. copy {
  66. from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders"
  67. }
  68. copy {
  69. from "${projRoot}/irr/media/Shaders" into "${assetsFolder}/client/shaders/Irrlicht"
  70. }
  71. copy {
  72. from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts"
  73. }
  74. copy {
  75. from "${projRoot}/textures/base/pack" into "${assetsFolder}/textures/base/pack"
  76. }
  77. // compile translations
  78. fileTree("${projRoot}/po").include("**/*.po").grep {
  79. it.parentFile.name !in unsupportedLanguages
  80. }.forEach { poFile ->
  81. def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/"
  82. file(moPath).mkdirs()
  83. exec {
  84. commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile
  85. }
  86. }
  87. file("${assetsFolder}/.nomedia").text = ""
  88. }
  89. task zipAssets(dependsOn: prepareAssets, type: Zip) {
  90. archiveFileName = "Minetest.zip"
  91. from assetsFolder
  92. destinationDirectory = file("src/main/assets")
  93. }
  94. }
  95. preBuild.dependsOn zipAssets
  96. prepareAssets.dependsOn ':native:getDeps'
  97. clean {
  98. delete new File("src/main/assets", "Minetest.zip")
  99. }
  100. // Map for the version code that gives each ABI a value.
  101. import com.android.build.OutputFile
  102. def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
  103. android.applicationVariants.all { variant ->
  104. variant.outputs.each {
  105. output ->
  106. def abiName = output.getFilter(OutputFile.ABI)
  107. output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
  108. }
  109. }
  110. dependencies {
  111. implementation project(':native')
  112. implementation 'androidx.appcompat:appcompat:1.6.1'
  113. }