build.gradle 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. apply plugin: 'application'
  2. java.sourceCompatibility = 21
  3. java.targetCompatibility = 21
  4. if (JavaVersion.current().isJava9Compatible()) {
  5. compileJava.options.release.set(21)
  6. }
  7. application.mainClass = 'me.lethunderhawk.server.ServerLauncher'
  8. application.applicationName = appName
  9. eclipse.project.name = appName + '-server'
  10. dependencies {
  11. implementation project(':shared')
  12. api project(':shared')
  13. }
  14. jar {
  15. archiveBaseName.set(appName)
  16. // the duplicatesStrategy matters starting in Gradle 7.0; this setting works.
  17. duplicatesStrategy = DuplicatesStrategy.EXCLUDE
  18. dependsOn configurations.runtimeClasspath
  19. from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
  20. // these "exclude" lines remove some unnecessary duplicate files in the output JAR.
  21. exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
  22. dependencies {
  23. exclude('META-INF/INDEX.LIST', 'META-INF/maven/**')
  24. }
  25. // setting the manifest makes the JAR runnable.
  26. // enabling native access helps avoid a warning when Java 24 or later runs the JAR.
  27. manifest {
  28. attributes 'Main-Class': application.mainClass, 'Enable-Native-Access': 'ALL-UNNAMED', 'Multi-Release': 'true'
  29. }
  30. // this last step may help on some OSes that need extra instruction to make runnable JARs.
  31. doLast {
  32. file(archiveFile).setExecutable(true, false)
  33. }
  34. }
  35. // Equivalent to the jar task; here for compatibility with gdx-setup.
  36. task dist(dependsOn: [jar]) {
  37. }