build.gradle 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. sourceSets.main.java.srcDirs = [ "src/" ]
  2. sourceCompatibility = '1.7'
  3. [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  4. ext {
  5. mainClassName = "com.eyeofmidas.cardtrick.IOSLauncher"
  6. }
  7. // Extracts native libs (*.a) from the native-ios.jar and places them
  8. // under build/libs/ios/.
  9. task copyNatives << {
  10. file("build/libs/ios/").mkdirs();
  11. configurations.natives.files.each { jar ->
  12. def outputDir = null
  13. if (jar.name.endsWith("natives-ios.jar")) outputDir = file("build/libs/ios")
  14. if (outputDir != null) {
  15. copy {
  16. from zipTree(jar)
  17. into outputDir
  18. include "*.a"
  19. }
  20. }
  21. }
  22. }
  23. // Updates a robovm.xml file.
  24. task updateRoboVMXML << {
  25. def xml = file('robovm.xml')
  26. if (!xml.exists()) {
  27. return
  28. }
  29. // Find all native (*.a) libraries beneath libs
  30. def libtree = fileTree(dir: 'build/libs', include: '**/*.a')
  31. def config = new groovy.util.XmlParser().parse(xml)
  32. config.libs.each {libs ->
  33. libs.children().clear()
  34. libtree.each { File file ->
  35. libs.appendNode('lib', 'build/libs/ios/' + file.getName())
  36. }
  37. }
  38. def writer = new FileWriter(xml)
  39. def printer = new XmlNodePrinter(new PrintWriter(writer))
  40. printer.setPreserveWhitespace true
  41. printer.print(config)
  42. }
  43. updateRoboVMXML.dependsOn copyNatives
  44. build.dependsOn updateRoboVMXML
  45. tasks.eclipse.dependsOn updateRoboVMXML
  46. launchIPhoneSimulator.dependsOn build
  47. launchIPadSimulator.dependsOn build
  48. launchIOSDevice.dependsOn build
  49. createIPA.dependsOn build
  50. eclipse.project {
  51. name = appName + "-ios"
  52. natures 'org.robovm.eclipse.RoboVMNature'
  53. }