Advertisement
mike29

Untitled

Jul 2nd, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. android {
  2. buildToolsVersion "22.0.1"
  3. compileSdkVersion 22
  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.  
  14. instrumentTest.setRoot('tests')
  15. }
  16.  
  17. lintOptions {
  18. abortOnError false
  19. }
  20.  
  21. signingConfigs {
  22. release {
  23. storeFile file("key")
  24. storePassword "XXX"
  25. keyAlias "XXX"
  26. keyPassword "XXX"
  27. }
  28. }
  29.  
  30. buildTypes {
  31. release {
  32. signingConfig signingConfigs.release
  33. }
  34. }
  35. }
  36.  
  37. // needed to add JNI shared libraries to APK when compiling on CLI
  38. tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
  39. pkgTask.jniFolders = new HashSet<File>()
  40. pkgTask.jniFolders.add(new File(projectDir, 'libs'))
  41. }
  42.  
  43. // called every time gradle gets executed, takes the native dependencies of
  44. // the natives configuration, and extracts them to the proper libs/ folders
  45. // so they get packed with the APK.
  46. task copyAndroidNatives() {
  47. file("libs/armeabi/").mkdirs();
  48. file("libs/armeabi-v7a/").mkdirs();
  49. file("libs/x86/").mkdirs();
  50.  
  51. configurations.natives.files.each { jar ->
  52. def outputDir = null
  53. if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
  54. if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
  55. if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
  56. if(outputDir != null) {
  57. copy {
  58. from zipTree(jar)
  59. into outputDir
  60. include "*.so"
  61. }
  62. }
  63. }
  64.  
  65.  
  66. println 'Kodable: Moving media to android assets'
  67. FileTree tree = fileTree (dir: "../android/assets");
  68.  
  69. tree.each { File file ->
  70. delete(file)
  71. }
  72. copy{
  73. from '../desktop/media'
  74. into '../android/assets'
  75. include '**/*ipad*/**'
  76. include '**/*sounds*/**'
  77. include '**/*shaders*/**'
  78. include '**/*maps*/**'
  79. include '**/*loading_screen*/**'
  80. exclude '**/*ipadhd*/**'
  81. exclude '**/*web*/**'
  82. include '**/*final_spec*/**'
  83. include '**/*props*/**'
  84. }
  85.  
  86. }
  87.  
  88.  
  89. task run(type: Exec) {
  90. def path
  91. def localProperties = project.file("../local.properties")
  92. if (localProperties.exists()) {
  93. Properties properties = new Properties()
  94. localProperties.withInputStream { instr ->
  95. properties.load(instr)
  96. }
  97. def sdkDir = properties.getProperty('sdk.dir')
  98. if (sdkDir) {
  99. path = sdkDir
  100. } else {
  101. path = "$System.env.ANDROID_HOME"
  102. }
  103. } else {
  104. path = "$System.env.ANDROID_HOME"
  105. }
  106.  
  107. def adb = path + "/platform-tools/adb"
  108. commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.surfscore.kodable.main.android/com.surfscore.kodable.main.android.AndroidLauncher'
  109. }
  110.  
  111. // sets up the Android Eclipse project, using the old Ant based build.
  112. eclipse {
  113. // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
  114. // ignores any nodes added in classpath.file.withXml
  115. sourceSets {
  116. main {
  117. java.srcDirs "src", 'gen'
  118. }
  119. }
  120.  
  121. jdt {
  122. sourceCompatibility = 1.6
  123. targetCompatibility = 1.6
  124. }
  125.  
  126. classpath {
  127. plusConfigurations += [ project.configurations.compile ]
  128. containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
  129. }
  130.  
  131. project {
  132. name = appName + "-android"
  133. natures 'com.android.ide.eclipse.adt.AndroidNature'
  134. buildCommands.clear();
  135. buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
  136. buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
  137. buildCommand "org.eclipse.jdt.core.javabuilder"
  138. buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
  139. }
  140. }
  141.  
  142. // sets up the Android Idea project, using the old Ant based build.
  143. idea {
  144. module {
  145. sourceDirs += file("src");
  146. scopes = [ COMPILE: [plus:[project.configurations.compile]]]
  147.  
  148. iml {
  149. withXml {
  150. def node = it.asNode()
  151. def builder = NodeBuilder.newInstance();
  152. builder.current = node;
  153. builder.component(name: "FacetManager") {
  154. facet(type: "android", name: "Android") {
  155. configuration {
  156. option(name: "UPDATE_PROPERTY_FILES", value:"true")
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement