build.gradle 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion 29
  4. buildToolsVersion '30.0.3'
  5. ndkVersion '22.0.7026061'
  6. defaultConfig {
  7. applicationId 'net.minetest.minetest'
  8. minSdkVersion 16
  9. targetSdkVersion 29
  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/Android/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. /*copy {
  73. // ToDo: fix broken locales
  74. from "${projRoot}/po" into "${assetsFolder}/po"
  75. }*/
  76. copy {
  77. from "${projRoot}/textures" into "${assetsFolder}/textures"
  78. }
  79. file("${assetsFolder}/.nomedia").text = "";
  80. task zipAssets(type: Zip) {
  81. archiveName "Minetest.zip"
  82. from "${assetsFolder}"
  83. destinationDir file("src/main/assets")
  84. }
  85. }
  86. preBuild.dependsOn zipAssets
  87. // Map for the version code that gives each ABI a value.
  88. import com.android.build.OutputFile
  89. def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
  90. android.applicationVariants.all { variant ->
  91. variant.outputs.each {
  92. output ->
  93. def abiName = output.getFilter(OutputFile.ABI)
  94. output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
  95. }
  96. }
  97. dependencies {
  98. implementation project(':native')
  99. implementation 'androidx.appcompat:appcompat:1.2.0'
  100. }