build.gradle 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. android {
  2. buildToolsVersion "19.1.0"
  3. compileSdkVersion 20
  4. sourceSets {
  5. main {
  6. manifest.srcFile 'AndroidManifest.xml'
  7. java.srcDirs = ['src']
  8. aidl.srcDirs = ['src']
  9. renderscript.srcDirs = ['src']
  10. res.srcDirs = ['res']
  11. assets.srcDirs = ['assets']
  12. }
  13. instrumentTest.setRoot('tests')
  14. }
  15. }
  16. // needed to add JNI shared libraries to APK when compiling on CLI
  17. tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
  18. pkgTask.jniFolders = new HashSet<File>()
  19. pkgTask.jniFolders.add(new File(projectDir, 'libs'))
  20. }
  21. // called every time gradle gets executed, takes the native dependencies of
  22. // the natives configuration, and extracts them to the proper libs/ folders
  23. // so they get packed with the APK.
  24. task copyAndroidNatives() {
  25. file("libs/armeabi/").mkdirs();
  26. file("libs/armeabi-v7a/").mkdirs();
  27. file("libs/x86/").mkdirs();
  28. configurations.natives.files.each { jar ->
  29. def outputDir = null
  30. if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
  31. if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
  32. if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
  33. if(outputDir != null) {
  34. copy {
  35. from zipTree(jar)
  36. into outputDir
  37. include "*.so"
  38. }
  39. }
  40. }
  41. }
  42. task run(type: Exec) {
  43. def path
  44. def localProperties = project.file("../local.properties")
  45. if (localProperties.exists()) {
  46. Properties properties = new Properties()
  47. localProperties.withInputStream { instr ->
  48. properties.load(instr)
  49. }
  50. def sdkDir = properties.getProperty('sdk.dir')
  51. if (sdkDir) {
  52. path = sdkDir
  53. } else {
  54. path = "$System.env.ANDROID_HOME"
  55. }
  56. } else {
  57. path = "$System.env.ANDROID_HOME"
  58. }
  59. def adb = path + "/platform-tools/adb"
  60. commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.eyeofmidas.cardtrick.android/com.eyeofmidas.cardtrick.android.AndroidLauncher'
  61. }
  62. // sets up the Android Eclipse project, using the old Ant based build.
  63. eclipse {
  64. // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
  65. // ignores any nodes added in classpath.file.withXml
  66. sourceSets {
  67. main {
  68. java.srcDirs "src", 'gen'
  69. }
  70. }
  71. jdt {
  72. sourceCompatibility = 1.6
  73. targetCompatibility = 1.6
  74. }
  75. classpath {
  76. plusConfigurations += project.configurations.compile
  77. containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
  78. }
  79. project {
  80. name = appName + "-android"
  81. natures 'com.android.ide.eclipse.adt.AndroidNature'
  82. buildCommands.clear();
  83. buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
  84. buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
  85. buildCommand "org.eclipse.jdt.core.javabuilder"
  86. buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
  87. }
  88. }
  89. // sets up the Android Idea project, using the old Ant based build.
  90. idea {
  91. module {
  92. sourceDirs += file("src");
  93. scopes = [ COMPILE: [plus:[project.configurations.compile]]]
  94. iml {
  95. withXml {
  96. def node = it.asNode()
  97. def builder = NodeBuilder.newInstance();
  98. builder.current = node;
  99. builder.component(name: "FacetManager") {
  100. facet(type: "android", name: "Android") {
  101. configuration {
  102. option(name: "UPDATE_PROPERTY_FILES", value:"true")
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }