build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import org.apache.tools.ant.taskdefs.condition.Os
  2. apply plugin: 'com.android.application'
  3. android {
  4. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  5. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  6. namespace "org.cocos2dx.javascript"
  7. defaultConfig {
  8. minSdkVersion PROP_MIN_SDK_VERSION
  9. targetSdkVersion PROP_TARGET_SDK_VERSION
  10. versionCode 1
  11. versionName "1.0"
  12. externalNativeBuild {
  13. ndkBuild {
  14. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  15. // skip the NDK Build step if PROP_NDK_MODE is none
  16. targets 'cocos2djs'
  17. arguments 'NDK_TOOLCHAIN_VERSION=clang'
  18. def module_paths = [project.file("D:/CocosEditors/Creator/2.4.12/resources/cocos2d-x"),
  19. project.file("D:/CocosEditors/Creator/2.4.12/resources/cocos2d-x/cocos"),
  20. project.file("D:/CocosEditors/Creator/2.4.12/resources/cocos2d-x/external")]
  21. if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  22. arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
  23. }
  24. else {
  25. arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
  26. }
  27. arguments '-j' + Runtime.runtime.availableProcessors()
  28. }
  29. }
  30. ndk {
  31. abiFilters PROP_APP_ABI.split(':')
  32. }
  33. }
  34. }
  35. sourceSets.main {
  36. java.srcDirs "../src", "src"
  37. res.srcDirs "../res", 'res'
  38. jniLibs.srcDirs "../libs", 'libs'
  39. manifest.srcFile "AndroidManifest.xml"
  40. }
  41. externalNativeBuild {
  42. ndkBuild {
  43. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  44. // skip the NDK Build step if PROP_NDK_MODE is none
  45. path "jni/Android.mk"
  46. }
  47. }
  48. }
  49. signingConfigs {
  50. release {
  51. if (project.hasProperty("RELEASE_STORE_FILE")) {
  52. storeFile file(RELEASE_STORE_FILE)
  53. storePassword RELEASE_STORE_PASSWORD
  54. keyAlias RELEASE_KEY_ALIAS
  55. keyPassword RELEASE_KEY_PASSWORD
  56. }
  57. }
  58. }
  59. buildTypes {
  60. release {
  61. debuggable false
  62. jniDebuggable false
  63. renderscriptDebuggable false
  64. minifyEnabled true
  65. shrinkResources true
  66. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  67. if (project.hasProperty("RELEASE_STORE_FILE")) {
  68. signingConfig signingConfigs.release
  69. }
  70. externalNativeBuild {
  71. ndkBuild {
  72. arguments 'NDK_DEBUG=0'
  73. }
  74. }
  75. }
  76. debug {
  77. debuggable true
  78. jniDebuggable true
  79. renderscriptDebuggable true
  80. externalNativeBuild {
  81. ndkBuild {
  82. arguments 'NDK_DEBUG=1'
  83. }
  84. }
  85. }
  86. }
  87. }
  88. android.applicationVariants.all { variant ->
  89. // delete previous files first
  90. delete "${buildDir}/intermediates/merged_assets/"
  91. variant.mergeAssets.doLast {
  92. def sourceDir = "${buildDir}/../../../../.."
  93. copy {
  94. from "${sourceDir}"
  95. include "assets/**"
  96. include "src/**"
  97. include "jsb-adapter/**"
  98. into outputDir
  99. }
  100. copy {
  101. from "${sourceDir}/main.js"
  102. from "${sourceDir}/project.json"
  103. into outputDir
  104. }
  105. }
  106. }
  107. dependencies {
  108. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  109. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  110. implementation fileTree(dir: "D:/CocosEditors/Creator/2.4.12/resources/cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
  111. implementation project(':libcocos2dx')
  112. }