build.gradle 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. apply plugin: "java"
  2. sourceCompatibility = 1.6
  3. sourceSets.main.java.srcDirs = [ "src/" ]
  4. project.ext.mainClassName = "com.eyeofmidas.cardtrick.desktop.DesktopLauncher"
  5. project.ext.assetsDir = new File("../android/assets");
  6. task run(dependsOn: classes, type: JavaExec) {
  7. main = project.mainClassName
  8. classpath = sourceSets.main.runtimeClasspath
  9. standardInput = System.in
  10. workingDir = project.assetsDir
  11. ignoreExitValue = true
  12. }
  13. task dist(type: Jar) {
  14. from files(sourceSets.main.output.classesDir)
  15. from files(sourceSets.main.output.resourcesDir)
  16. from {configurations.compile.collect {zipTree(it)}}
  17. from files(project.assetsDir);
  18. manifest {
  19. attributes 'Main-Class': project.mainClassName
  20. }
  21. }
  22. dist.dependsOn classes
  23. eclipse {
  24. project {
  25. name = appName + "-desktop"
  26. linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets'
  27. }
  28. }
  29. task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
  30. doLast {
  31. def classpath = new XmlParser().parse(file(".classpath"))
  32. new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
  33. def writer = new FileWriter(file(".classpath"))
  34. def printer = new XmlNodePrinter(new PrintWriter(writer))
  35. printer.setPreserveWhitespace(true)
  36. printer.print(classpath)
  37. }
  38. }