build.gradle 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. doFirst {
  52. logger.lifecycle('Preparing assets at {}', assetsFolder)
  53. }
  54. doLast {
  55. copy {
  56. from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder
  57. }
  58. copy {
  59. from "${projRoot}/doc/lgpl-2.1.txt" into assetsFolder
  60. }
  61. copy {
  62. from "${projRoot}/builtin" into "${assetsFolder}/builtin"
  63. }
  64. copy {
  65. from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders"
  66. }
  67. copy {
  68. from "../native/deps/armeabi-v7a/Irrlicht/Shaders" into "${assetsFolder}/client/shaders/Irrlicht"
  69. }
  70. copy {
  71. from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts"
  72. }
  73. copy {
  74. from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}"
  75. }
  76. copy {
  77. from "${projRoot}/textures" into "${assetsFolder}/textures"
  78. }
  79. // compile translations
  80. fileTree("${projRoot}/po").include("**/*.po").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. // Map for the version code that gives each ABI a value.
  98. import com.android.build.OutputFile
  99. def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
  100. android.applicationVariants.all { variant ->
  101. variant.outputs.each {
  102. output ->
  103. def abiName = output.getFilter(OutputFile.ABI)
  104. output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
  105. }
  106. }
  107. dependencies {
  108. implementation project(':native')
  109. implementation 'androidx.appcompat:appcompat:1.6.1'
  110. }