143 lines
5.1 KiB
Groovy
143 lines
5.1 KiB
Groovy
buildscript {
|
|
repositories {
|
|
gradlePluginPortal()
|
|
}
|
|
dependencies {
|
|
if(enableGraalNative == 'true') {
|
|
classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.28"
|
|
}
|
|
}
|
|
}
|
|
plugins {
|
|
id "io.github.fourlastor.construo" version "1.4.1"
|
|
id "application"
|
|
}
|
|
|
|
|
|
import io.github.fourlastor.construo.Target
|
|
|
|
sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ]
|
|
mainClassName = 'com.openeggbert.lwjgl3.Lwjgl3Launcher'
|
|
application.setMainClass(mainClassName)
|
|
eclipse.project.name = appName + '-lwjgl3'
|
|
java.sourceCompatibility = 11
|
|
java.targetCompatibility = 11
|
|
|
|
if (JavaVersion.current().isJava9Compatible()) {
|
|
compileJava.options.release.set(11)
|
|
}
|
|
|
|
dependencies {
|
|
implementation "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"
|
|
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
|
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
|
|
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
|
implementation "com.github.MrStahlfelge.gdx-websockets:common:$websocketVersion"
|
|
implementation "com.github.crykn.guacamole:gdx-desktop:$guacamoleVersion"
|
|
implementation "games.rednblack.miniaudio:miniaudio:$miniaudioVersion:natives-desktop"
|
|
|
|
implementation project(':core')
|
|
implementation "com.pixelgamelibrary:pixel:$pixelVersion"
|
|
implementation "com.pixelgamelibrary:pixel-backend-libgdx:$pixelVersion"
|
|
|
|
if(enableGraalNative == 'true') {
|
|
implementation "io.github.berstanio:gdx-svmhelper-backend-lwjgl3:$graalHelperVersion"
|
|
}
|
|
}
|
|
|
|
def jarName = "${appName}-${version}.jar"
|
|
def os = System.properties['os.name'].toLowerCase()
|
|
|
|
run {
|
|
workingDir = rootProject.file('assets').path
|
|
setIgnoreExitValue(true)
|
|
|
|
if (os.contains('mac')) jvmArgs += "-XstartOnFirstThread"
|
|
}
|
|
|
|
jar {
|
|
// sets the name of the .jar file this produces to the name of the game or app.
|
|
archiveFileName.set(jarName)
|
|
// using 'lib' instead of the default 'libs' appears to be needed by jpackageimage.
|
|
destinationDirectory = file("${project.layout.buildDirectory.asFile.get().absolutePath}/lib")
|
|
// 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.
|
|
manifest {
|
|
attributes 'Main-Class': project.mainClassName
|
|
}
|
|
// this last step may help on some OSes that need extra instruction to make runnable JARs.
|
|
doLast {
|
|
file(archiveFile).setExecutable(true, false)
|
|
}
|
|
}
|
|
|
|
construo {
|
|
// name of the executable
|
|
name.set(appName)
|
|
// human-readable name, used for example in the `.app` name for macOS
|
|
humanName.set(appName)
|
|
// Optional, defaults to project version
|
|
version.set("0.0.0")
|
|
|
|
targets.configure {
|
|
create("linuxX64", Target.Linux) {
|
|
architecture.set(Target.Architecture.X86_64)
|
|
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")
|
|
}
|
|
create("macM1", Target.MacOs) {
|
|
architecture.set(Target.Architecture.AARCH64)
|
|
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")
|
|
// macOS needs an identifier
|
|
identifier.set("com.openeggbert." + appName)
|
|
// Optional: icon for macOS
|
|
macIcon.set(project.file("icons/logo.icns"))
|
|
}
|
|
create("macX64", Target.MacOs) {
|
|
architecture.set(Target.Architecture.X86_64)
|
|
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")
|
|
// macOS needs an identifier
|
|
identifier.set("i.should.be.changed.before.merge." + appName)
|
|
// Optional: icon for macOS
|
|
macIcon.set(project.file("icons/logo.icns"))
|
|
}
|
|
create("winX64", Target.Windows) {
|
|
architecture.set(Target.Architecture.X86_64)
|
|
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")
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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")
|
|
}
|