build.gradle 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion 19
  4. buildToolsVersion "22.0.1"
  5. defaultConfig {
  6. applicationId "com.garagegames.torque2d"
  7. minSdkVersion 19
  8. targetSdkVersion 19
  9. sourceSets.main {
  10. assets.srcDirs=[
  11. 'src/main/assets',
  12. 'src/main/game'
  13. ]
  14. jni.srcDirs = ['../../../source/']
  15. jniLibs.srcDir 'src/main/libs'
  16. }
  17. task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
  18. def ndkDir = plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder()
  19. commandLine "$ndkDir/ndk-build",
  20. '-C', file('src/main/jni').absolutePath,
  21. '-j', Runtime.runtime.availableProcessors(),
  22. 'all',
  23. 'NDK_DEBUG=1'
  24. }
  25. task cleanNative(type: Exec, description: 'Clean JNI object files') {
  26. def ndkDir = plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder()
  27. commandLine "$ndkDir/ndk-build",
  28. '-C', file('src/main/jni').absolutePath,
  29. 'clean'
  30. }
  31. task copyGame(type: Copy, description: 'Copy torque scripts and modules'){
  32. from('../../../../'){
  33. include '**'
  34. exclude 'engine/**'
  35. exclude 'tools/**'
  36. exclude 'tutorials/**'
  37. exclude '.**'
  38. exclude '*.dll'
  39. exclude 'preferences.cs'
  40. exclude '*.md'
  41. exclude '*.app'
  42. exclude '*.bat'
  43. exclude '*.log'
  44. exclude '*.torsion'
  45. }
  46. into 'src/main/game'
  47. includeEmptyDirs = false
  48. }
  49. task wipeGame(type: Delete, description: 'Wipe android-specific copy of torque scripts and modules'){
  50. delete 'src/main/game/'
  51. }
  52. clean.dependsOn 'cleanNative'
  53. clean.dependsOn 'wipeGame'
  54. tasks.withType(JavaCompile) {
  55. compileTask -> compileTask.dependsOn copyGame
  56. }
  57. tasks.withType(JavaCompile) {
  58. compileTask -> compileTask.dependsOn buildNative
  59. }
  60. tasks.withType(com.android.build.gradle.tasks.NdkCompile){task->
  61. task.enabled = false
  62. }
  63. }
  64. buildTypes {
  65. release {
  66. minifyEnabled false
  67. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  68. }
  69. }
  70. }