From 52864cb701e59a1d847fd5586245519eb5e3b3bc Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 23 Jan 2026 20:22:30 -0800 Subject: Move code over --- lwjgl3/build.gradle | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 lwjgl3/build.gradle (limited to 'lwjgl3/build.gradle') diff --git a/lwjgl3/build.gradle b/lwjgl3/build.gradle new file mode 100644 index 0000000..295b01b --- /dev/null +++ b/lwjgl3/build.gradle @@ -0,0 +1,193 @@ + +buildscript { + repositories { + gradlePluginPortal() + } + dependencies { + classpath "io.github.fourlastor:construo:2.1.0" + if(enableGraalNative == 'true') { + classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.28" + } + } +} +plugins { + id "application" +} +apply plugin: 'io.github.fourlastor.construo' + + +import io.github.fourlastor.construo.Target + +sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ] +application.mainClass = 'coffee.liz.abstractionengine.lwjgl3.Lwjgl3Launcher' +eclipse.project.name = appName + '-lwjgl3' +java.sourceCompatibility = 24 +java.targetCompatibility = 24 +if (JavaVersion.current().isJava9Compatible()) { + compileJava.options.release.set(24) +} + +dependencies { + implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" + implementation "com.badlogicgames.gdx:gdx-lwjgl3-angle:$gdxVersion" + implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + implementation project(':core') + + if(enableGraalNative == 'true') { + implementation "io.github.berstanio:gdx-svmhelper-backend-lwjgl3:$graalHelperVersion" + implementation "io.github.berstanio:gdx-svmhelper-extension-freetype:$graalHelperVersion" + + } +} + +def os = System.properties['os.name'].toLowerCase(Locale.ROOT) + +run { + workingDir = rootProject.file('assets').path +// You can uncomment the next line if your IDE claims a build failure even when the app closed properly. + //setIgnoreExitValue(true) + + if (os.contains('mac')) jvmArgs += "-XstartOnFirstThread" +} + +// Run with JVM debugger listening on port 5005 +tasks.register('runDebug', JavaExec) { + group = 'application' + description = 'Run the application with the JVM debugger listening on 5005' + classpath = sourceSets.main.runtimeClasspath + mainClass = application.mainClass + workingDir = rootProject.file('assets').path + if (os.contains('mac')) jvmArgs += "-XstartOnFirstThread" + jvmArgs += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005" +} + +jar { +// sets the name of the .jar file this produces to the name of the game or app, with the version after. + archiveFileName.set("${appName}-${projectVersion}.jar") +// the duplicatesStrategy matters starting in Gradle 7.0; this setting works. + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + dependsOn configurations.runtimeClasspath + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } +// these "exclude" lines remove some unnecessary duplicate files in the output JAR. + exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA') + dependencies { + exclude('META-INF/INDEX.LIST', 'META-INF/maven/**') + } +// setting the manifest makes the JAR runnable. +// enabling native access helps avoid a warning when Java 24 or later runs the JAR. + manifest { + attributes 'Main-Class': application.mainClass, 'Enable-Native-Access': 'ALL-UNNAMED' + } +// this last step may help on some OSes that need extra instruction to make runnable JARs. + doLast { + file(archiveFile).setExecutable(true, false) + } +} + +// Builds a JAR that only includes the files needed to run on macOS, not Windows or Linux. +// The file size for a Mac-only JAR is about 7MB smaller than a cross-platform JAR. +tasks.register("jarMac") { + dependsOn("jar") + group("build") + jar.archiveFileName.set("${appName}-${projectVersion}-mac.jar") + jar.exclude("windows/x86/**", "windows/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**", "**/*.dll", "**/*.so", + 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA') + dependencies { + jar.exclude("windows/x86/**", "windows/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**", + 'META-INF/INDEX.LIST', 'META-INF/maven/**') + } +} + +// Builds a JAR that only includes the files needed to run on Linux, not Windows or macOS. +// The file size for a Linux-only JAR is about 5MB smaller than a cross-platform JAR. +tasks.register("jarLinux") { + dependsOn("jar") + group("build") + jar.archiveFileName.set("${appName}-${projectVersion}-linux.jar") + jar.exclude("windows/x86/**", "windows/x64/**", "macos/arm64/**", "macos/x64/**", "**/*.dll", "**/*.dylib", + 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA') + dependencies { + jar.exclude("windows/x86/**", "windows/x64/**", "macos/arm64/**", "macos/x64/**", + 'META-INF/INDEX.LIST', 'META-INF/maven/**') + } +} + +// Builds a JAR that only includes the files needed to run on Windows, not Linux or macOS. +// The file size for a Windows-only JAR is about 6MB smaller than a cross-platform JAR. +tasks.register("jarWin") { + dependsOn("jar") + group("build") + jar.archiveFileName.set("${appName}-${projectVersion}-win.jar") + jar.exclude("macos/arm64/**", "macos/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**", "**/*.dylib", "**/*.so", + 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA') + dependencies { + jar.exclude("macos/arm64/**", "macos/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**", + 'META-INF/INDEX.LIST', 'META-INF/maven/**') + } +} + +construo { + // name of the executable + name.set(appName) + // human-readable name, used for example in the `.app` name for macOS + humanName.set(appName) + + targets.configure { + register("linuxX64", Target.Linux) { + architecture.set(Target.Architecture.X86_64) + jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_x64_linux_hotspot_17.0.15_6.tar.gz") + // Linux does not currently have a way to set the icon on the executable + } + register("macM1", Target.MacOs) { + architecture.set(Target.Architecture.AARCH64) + jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.15_6.tar.gz") + // macOS needs an identifier + identifier.set("coffee.liz.abstractionengine." + appName) + // Optional: icon for macOS, as an ICNS file + macIcon.set(project.file("icons/logo.icns")) + } + register("macX64", Target.MacOs) { + architecture.set(Target.Architecture.X86_64) + jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_x64_mac_hotspot_17.0.15_6.tar.gz") + // macOS needs an identifier + identifier.set("coffee.liz.abstractionengine." + appName) + // Optional: icon for macOS, as an ICNS file + macIcon.set(project.file("icons/logo.icns")) + } + register("winX64", Target.Windows) { + architecture.set(Target.Architecture.X86_64) + // Optional: icon for Windows, as a PNG + icon.set(project.file("icons/logo.png")) + jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.15%2B6/OpenJDK17U-jdk_x64_windows_hotspot_17.0.15_6.zip") + // Uncomment the next line to show a console when the game runs, to print messages. + //useConsole.set(true) + } + } +} + +// Equivalent to the jar task; here for compatibility with gdx-setup. +tasks.register('dist') { + dependsOn 'jar' +} + +distributions { + main { + contents { + into('libs') { + project.configurations.runtimeClasspath.files.findAll { file -> + file.getName() != project.tasks.jar.outputs.files.singleFile.name + }.each { file -> + exclude file.name + } + } + } + } +} + +startScripts.dependsOn(':lwjgl3:jar') +startScripts.classpath = project.tasks.jar.outputs.files + +if(enableGraalNative == 'true') { + apply from: file("nativeimage.gradle") +} -- cgit v1.2.3-70-g09d2