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. def gameToCopy = "minetest_game"
  51. // See issue #4638
  52. def unsupportedLanguages = new File("${projRoot}/src/unsupported_language_list.txt").text.readLines()
  53. doFirst {
  54. logger.lifecycle('Preparing assets at {}', assetsFolder)
  55. }
  56. doLast {
  57. copy {
  58. from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder
  59. }
  60. copy {
  61. from "${projRoot}/doc/lgpl-2.1.txt" into assetsFolder
  62. }
  63. copy {
  64. from "${projRoot}/builtin" into "${assetsFolder}/builtin"
  65. }
  66. copy {
  67. from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders"
  68. }
  69. copy {
  70. from "../native/deps/armeabi-v7a/Irrlicht/Shaders" into "${assetsFolder}/client/shaders/Irrlicht"
  71. }
  72. copy {
  73. from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts"
  74. }
  75. copy {
  76. from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}"
  77. }
  78. copy {
  79. from "${projRoot}/textures" into "${assetsFolder}/textures"
  80. }
  81. // compile translations
  82. fileTree("${projRoot}/po").include("**/*.po").grep {
  83. it.parentFile.name !in unsupportedLanguages
  84. }.forEach { poFile ->
  85. def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/"
  86. file(moPath).mkdirs()
  87. exec {
  88. commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile
  89. }
  90. }
  91. file("${assetsFolder}/.nomedia").text = ""
  92. }
  93. task zipAssets(dependsOn: prepareAssets, type: Zip) {
  94. archiveFileName = "Minetest.zip"
  95. from assetsFolder
  96. destinationDirectory = file("src/main/assets")
  97. }
  98. }
  99. preBuild.dependsOn zipAssets
  100. prepareAssets.dependsOn ':native:getDeps'
  101. // Map for the version code that gives each ABI a value.
  102. import com.android.build.OutputFile
  103. def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
  104. android.applicationVariants.all { variant ->
  105. variant.outputs.each {
  106. output ->
  107. def abiName = output.getFilter(OutputFile.ABI)
  108. output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
  109. }
  110. }
  111. dependencies {
  112. implementation project(':native')
  113. implementation 'androidx.appcompat:appcompat:1.6.1'
  114. }