-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
113 lines (104 loc) · 4.24 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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(enableGraalNative == 'true') {
classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.28"
}
}
}
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_14)) {
apply plugin: 'org.beryx.runtime'
}
else {
apply plugin: 'application'
}
mainClassName = 'no.sandramoen.ggj2024oslo.lwjgl3.Lwjgl3Launcher'
eclipse.project.name = appName + '-lwjgl3'
java.sourceCompatibility = 11
java.targetCompatibility = 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 project(':core')
}
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)
}
}
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 = jarName
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']
}
if(enableGraalNative == 'true') {
apply from: file("nativeimage.gradle")
}