114 lines
4.4 KiB
Groovy
114 lines
4.4 KiB
Groovy
buildscript {
|
|
repositories {
|
|
gradlePluginPortal()
|
|
}
|
|
dependencies {
|
|
// using jpackage only works if the JDK version is 14 or higher.
|
|
// your JAVA_HOME environment variable may also need to be a JDK with version 14 or higher.
|
|
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_14)) {
|
|
classpath "org.beryx:badass-runtime-plugin:1.13.0"
|
|
}
|
|
}
|
|
}
|
|
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_14)) {
|
|
apply plugin: 'org.beryx.runtime'
|
|
}
|
|
else {
|
|
apply plugin: 'application'
|
|
}
|
|
|
|
//sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ]
|
|
sourceSets.main.resources.srcDirs += [ rootProject.file('assets') ]
|
|
|
|
mainClassName = 'io.doppelspalt.lwjgl3.Lwjgl3Launcher'
|
|
eclipse.project.name = appName + '-lwjgl3'
|
|
java.sourceCompatibility = 11
|
|
java.targetCompatibility = 11
|
|
|
|
dependencies {
|
|
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
|
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
|
|
|
implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
|
implementation project(':core')
|
|
|
|
|
|
}
|
|
|
|
def os = System.properties['os.name'].toLowerCase()
|
|
|
|
run {
|
|
workingDir = rootProject.file('assets').path
|
|
setIgnoreExitValue(true)
|
|
|
|
// This next line could be needed to run LWJGL3 Java apps on macOS, but StartupHelper should make it unnecessary.
|
|
//if (os.contains('mac')) jvmArgs += "-XstartOnFirstThread"
|
|
// If you encounter issues with the 'lwjgl3:run' task on macOS specifically, try uncommenting the above line, and
|
|
// regardless, please report it via the gdx-liftoff issue tracker or just mention it on the libGDX Discord.
|
|
}
|
|
|
|
jar {
|
|
// sets the name of the .jar file this produces to the name of the game or app.
|
|
archiveBaseName.set(appName)
|
|
// 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)
|
|
}
|
|
}
|
|
|
|
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_14)) {
|
|
tasks.jpackageImage.doNotTrackState("This task both reads from and writes to the build folder.")
|
|
runtime {
|
|
options.set(['--strip-debug',
|
|
'--compress', '2',
|
|
'--no-header-files',
|
|
'--no-man-pages',
|
|
'--strip-native-commands',
|
|
'--vm', 'server'])
|
|
// you could very easily need more modules than this one.
|
|
// use the lwjgl3:suggestModules task to see which modules may be needed.
|
|
modules.set([
|
|
'jdk.unsupported'
|
|
])
|
|
distDir.set(file(project.layout.buildDirectory))
|
|
jpackage {
|
|
imageName = appName
|
|
// you can set this to false if you want to build an installer, or keep it as true to build just an app.
|
|
skipInstaller = true
|
|
// this may need to be set to a different path if your JAVA_HOME points to a low JDK version.
|
|
jpackageHome = javaHome.getOrElse("")
|
|
mainJar = jar.archiveFileName.get()
|
|
if (os.contains('win')) {
|
|
imageOptions = ["--icon", "icons/logo.ico"]
|
|
} else if (os.contains('nix') || os.contains('nux') || os.contains('bsd')) {
|
|
imageOptions = ["--icon", "icons/logo.png"]
|
|
} else if (os.contains('mac')) {
|
|
// If you are making a jpackage image on macOS, the below line should work thanks to StartupHelper.
|
|
imageOptions = ["--icon", "icons/logo.icns"]
|
|
// If the above line doesn't produce a runnable executable, you can try using the below line instead of the above one.
|
|
// imageOptions = ["--icon", "icons/logo.icns", "--java-options", "\"-XstartOnFirstThread\""]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Equivalent to the jar task; here for compatibility with gdx-setup.
|
|
tasks.register('dist') {
|
|
dependsOn['jar']
|
|
}
|