build.gradle 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion 30
  4. buildToolsVersion '30.0.3'
  5. ndkVersion "$ndk_version"
  6. defaultConfig {
  7. applicationId 'net.minetest.minetest'
  8. minSdkVersion 16
  9. targetSdkVersion 30
  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'
  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 = "../.."
  50. def gameToCopy = "minetest_game"
  51. copy {
  52. from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder
  53. }
  54. copy {
  55. from "${projRoot}/doc/lgpl-2.1.txt" into "${assetsFolder}"
  56. }
  57. copy {
  58. from "${projRoot}/builtin" into "${assetsFolder}/builtin"
  59. }
  60. copy {
  61. from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders"
  62. }
  63. copy {
  64. from "../native/deps/armeabi-v7a/Irrlicht/Shaders" into "${assetsFolder}/client/shaders/Irrlicht"
  65. }
  66. copy {
  67. from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts"
  68. }
  69. copy {
  70. from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}"
  71. }
  72. fileTree("${projRoot}/po").include("**/*.po").forEach { poFile ->
  73. def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/"
  74. file(moPath).mkdirs()
  75. exec {
  76. commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile
  77. }
  78. }
  79. copy {
  80. from "${projRoot}/textures" into "${assetsFolder}/textures"
  81. }
  82. file("${assetsFolder}/.nomedia").text = "";
  83. task zipAssets(type: Zip) {
  84. archiveName "Minetest.zip"
  85. from "${assetsFolder}"
  86. destinationDir file("src/main/assets")
  87. }
  88. }
  89. preBuild.dependsOn zipAssets
  90. // Map for the version code that gives each ABI a value.
  91. import com.android.build.OutputFile
  92. def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
  93. android.applicationVariants.all { variant ->
  94. variant.outputs.each {
  95. output ->
  96. def abiName = output.getFilter(OutputFile.ABI)
  97. output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
  98. }
  99. }
  100. dependencies {
  101. implementation project(':native')
  102. implementation 'androidx.appcompat:appcompat:1.3.1'
  103. }