build.gradle 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. buildscript {
  2. repositories {
  3. gradlePluginPortal()
  4. }
  5. dependencies {
  6. classpath "io.github.fourlastor:construo:1.4.3"
  7. if(enableGraalNative == 'true') {
  8. classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.28"
  9. }
  10. }
  11. }
  12. plugins {
  13. id "application"
  14. }
  15. apply plugin: 'io.github.fourlastor.construo'
  16. import io.github.fourlastor.construo.Target
  17. sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ]
  18. mainClassName = 'xyz.prismix.lwjgl3.Lwjgl3Launcher'
  19. application.setMainClass(mainClassName)
  20. eclipse.project.name = appName + '-lwjgl3'
  21. java.sourceCompatibility = 8
  22. java.targetCompatibility = 8
  23. if (JavaVersion.current().isJava9Compatible()) {
  24. compileJava.options.release.set(8)
  25. }
  26. dependencies {
  27. implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
  28. implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
  29. implementation "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
  30. implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
  31. implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
  32. implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion"
  33. implementation project(':core')
  34. if(enableGraalNative == 'true') {
  35. implementation "io.github.berstanio:gdx-svmhelper-backend-lwjgl3:$graalHelperVersion"
  36. implementation "io.github.berstanio:gdx-svmhelper-extension-box2d:$graalHelperVersion"
  37. implementation "io.github.berstanio:gdx-svmhelper-extension-bullet:$graalHelperVersion"
  38. implementation "io.github.berstanio:gdx-svmhelper-extension-freetype:$graalHelperVersion"
  39. }
  40. }
  41. def os = System.properties['os.name'].toLowerCase()
  42. run {
  43. workingDir = rootProject.file('assets').path
  44. setIgnoreExitValue(true)
  45. if (os.contains('mac')) jvmArgs += "-XstartOnFirstThread"
  46. }
  47. jar {
  48. // sets the name of the .jar file this produces to the name of the game or app, with the version after.
  49. archiveFileName.set("${appName}-${projectVersion}.jar")
  50. // the duplicatesStrategy matters starting in Gradle 7.0; this setting works.
  51. duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
  52. dependsOn configurations.runtimeClasspath
  53. from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
  54. // these "exclude" lines remove some unnecessary duplicate files in the output JAR.
  55. exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
  56. dependencies {
  57. exclude('META-INF/INDEX.LIST', 'META-INF/maven/**')
  58. }
  59. // setting the manifest makes the JAR runnable.
  60. manifest {
  61. attributes 'Main-Class': project.mainClassName
  62. }
  63. // this last step may help on some OSes that need extra instruction to make runnable JARs.
  64. doLast {
  65. file(archiveFile).setExecutable(true, false)
  66. }
  67. }
  68. construo {
  69. // name of the executable
  70. name.set(appName)
  71. // human-readable name, used for example in the `.app` name for macOS
  72. humanName.set(appName)
  73. // Optional, defaults to project version property
  74. version.set("$projectVersion")
  75. targets.configure {
  76. create("linuxX64", Target.Linux) {
  77. architecture.set(Target.Architecture.X86_64)
  78. jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.12_7.tar.gz")
  79. }
  80. create("macM1", Target.MacOs) {
  81. architecture.set(Target.Architecture.AARCH64)
  82. jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.12_7.tar.gz")
  83. // macOS needs an identifier
  84. identifier.set("xyz.prismix." + appName)
  85. // Optional: icon for macOS
  86. macIcon.set(project.file("icons/logo.icns"))
  87. }
  88. create("macX64", Target.MacOs) {
  89. architecture.set(Target.Architecture.X86_64)
  90. jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_mac_hotspot_17.0.12_7.tar.gz")
  91. // macOS needs an identifier
  92. identifier.set("xyz.prismix." + appName)
  93. // Optional: icon for macOS
  94. macIcon.set(project.file("icons/logo.icns"))
  95. }
  96. create("winX64", Target.Windows) {
  97. architecture.set(Target.Architecture.X86_64)
  98. jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_windows_hotspot_17.0.12_7.zip")
  99. // Uncomment the next line to show a console when the game runs, to print messages.
  100. //useConsole.set(true)
  101. }
  102. }
  103. }
  104. // Equivalent to the jar task; here for compatibility with gdx-setup.
  105. tasks.register('dist') {
  106. dependsOn 'jar'
  107. }
  108. distributions {
  109. main {
  110. contents {
  111. into('libs') {
  112. project.configurations.runtimeClasspath.files.findAll { file ->
  113. file.getName() != project.tasks.jar.outputs.files.singleFile.name
  114. }.each { file ->
  115. exclude file.name
  116. }
  117. }
  118. }
  119. }
  120. }
  121. startScripts.dependsOn(':lwjgl3:jar')
  122. startScripts.classpath = project.tasks.jar.outputs.files
  123. if(enableGraalNative == 'true') {
  124. apply from: file("nativeimage.gradle")
  125. }