build.gradle 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. apply plugin: "java"
  2. apply plugin: 'kotlin'
  3. sourceCompatibility = 1.6
  4. sourceSets.main.java.srcDirs = [ "src/" ]
  5. project.ext.mainClassName = "info.raa0121.exebattle.desktop.DesktopLauncher"
  6. project.ext.assetsDir = new File("../core/assets");
  7. task run(dependsOn: classes, type: JavaExec) {
  8. main = project.mainClassName
  9. classpath = sourceSets.main.runtimeClasspath
  10. standardInput = System.in
  11. workingDir = project.assetsDir
  12. ignoreExitValue = true
  13. }
  14. task debug(dependsOn: classes, type: JavaExec) {
  15. main = project.mainClassName
  16. classpath = sourceSets.main.runtimeClasspath
  17. standardInput = System.in
  18. workingDir = project.assetsDir
  19. ignoreExitValue = true
  20. debug = true
  21. }
  22. task dist(type: Jar) {
  23. from files(sourceSets.main.output.classesDir)
  24. from files(sourceSets.main.output.resourcesDir)
  25. from {configurations.compile.collect {zipTree(it)}}
  26. from files(project.assetsDir);
  27. manifest {
  28. attributes 'Main-Class': project.mainClassName
  29. }
  30. }
  31. dist.dependsOn classes
  32. eclipse {
  33. project {
  34. name = appName + "-desktop"
  35. linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
  36. }
  37. }
  38. task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
  39. doLast {
  40. def classpath = new XmlParser().parse(file(".classpath"))
  41. new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
  42. def writer = new FileWriter(file(".classpath"))
  43. def printer = new XmlNodePrinter(new PrintWriter(writer))
  44. printer.setPreserveWhitespace(true)
  45. printer.print(classpath)
  46. }
  47. }
  48. buildscript {
  49. ext.kotlin_version = '1.2.21'
  50. repositories {
  51. mavenCentral()
  52. }
  53. dependencies {
  54. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  55. }
  56. }
  57. repositories {
  58. mavenCentral()
  59. }
  60. dependencies {
  61. compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
  62. }
  63. compileKotlin {
  64. kotlinOptions {
  65. jvmTarget = "1.8"
  66. }
  67. }
  68. compileTestKotlin {
  69. kotlinOptions {
  70. jvmTarget = "1.8"
  71. }
  72. }