-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathbuild.gradle
More file actions
251 lines (221 loc) · 10.6 KB
/
build.gradle
File metadata and controls
251 lines (221 loc) · 10.6 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url = 'https://central.sonatype.com/repository/maven-snapshots/' }
// mavenLocal()
google()
}
dependencies {
classpath "io.github.fourlastor:construo:2.1.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jlleitschuh.gradle:ktlint-gradle:14.0.1"
}
}
plugins {
id "application"
}
apply plugin: 'io.github.fourlastor.construo'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'kotlin'
apply plugin: 'java-library'
apply plugin: 'application'
apply plugin: 'org.jlleitschuh.gradle.ktlint'
import io.github.fourlastor.construo.Target
version = "$liftoffVersion"
application.mainClass = 'gdx.liftoff.Main'
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
def appName = "gdx-liftoff"
def jarName = "$appName-${version}.jar"
application.applicationName = appName
jar {
manifest {
attributes (
// Enabling native access is good for JARs run by Java 24 or later.
// Setting Multi-Release to true allows LWJGL3 to use different classes on recent Java versions.
'Main-Class': application.mainClass, 'Enable-Native-Access': 'ALL-UNNAMED', 'Multi-Release': 'true'
)
}
archiveFileName.set(jarName)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/freebsd/**')
dependencies {
exclude('META-INF/INDEX.LIST', 'META-INF/maven/**', 'META-INF/freebsd/**')
}
doLast {
file(archiveFile).setExecutable(true, false)
}
}
repositories {
mavenCentral()
maven { url = "https://central.sonatype.com/repository/maven-snapshots/" }
maven { url = "https://jitpack.io" }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
implementation "org.apache.commons:commons-exec:$commonsExecVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
// implementation "com.kotcrab.vis:vis-ui:$visUiVersion" // for stable releases
implementation "com.github.kotcrab.vis-ui:vis-ui:$visUiVersion" // for JitPack commits
implementation "com.github.raeleus.TenPatch:tenpatch:5.2.3"
implementation "com.github.raeleus.stripe:stripe:2.0.0"
implementation "com.github.tommyettinger:textratypist:2.2.14"
// implementation "com.rafaskoberg.gdx:typing-label:1.4.0" // not used because at least not currently compatible
implementation "com.github.tommyettinger:regexodus:0.1.21" // updates version used by Stripe
// "Needed" by Construo when LWJGL 3.4.x is used, because jspecify otherwise is used by LWJGL3, but unavailable.
api "org.jspecify:jspecify:1.0.0"
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
// Increases downloaded executable size, but may allow it to run in more places.
// This seems to cause more trouble than it's worth at this point...
// implementation "com.badlogicgames.gdx:gdx-lwjgl3-angle:$gdxVersion"
implementation("com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"){
exclude group: "org.lwjgl", module: "lwjgl-openal"
exclude group: "org.jcraft", module: "jorbis"
}
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-windows"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-windows-x86"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-linux"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-linux-arm32"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-linux-arm64"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-macos"
implementation "org.lwjgl:lwjgl-nfd:$nfdVersion:natives-macos-arm64"
// Older; only used when we needed $nfdVersion to be less than $lwjgl3Version .
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-windows"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-windows-x86"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-linux"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-linux-arm32"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-linux-arm64"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-macos"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// implementation("org.lwjgl:lwjgl-nfd:$nfdVersion:natives-macos-arm64"){ exclude group: 'org.lwjgl', module: 'lwjgl' }
// for some network requests, such as checking the versions of dependencies
implementation "com.github.kittinunf.fuel:fuel:2.3.1"
implementation "org.slf4j:slf4j-nop:2.0.5"
// This is the same as the "official" mvnrepository-client version 2.0.2, but with dependencies updated to avoid vulnerabilities.
// It is here in a comment in case MvnRepository's search starts working again...
// implementation 'com.github.tommyettinger:mvnrepository-client:v2.0.2.4'
// Forces LWJGL3 to use at least $lwjgl3Version, currently 3.4.1, to avoid problems on Java 25 and up.
constraints{
implementation("org.lwjgl:lwjgl:$lwjgl3Version")
implementation("org.lwjgl:lwjgl-glfw:$lwjgl3Version")
implementation("org.lwjgl:lwjgl-jemalloc:$lwjgl3Version")
implementation("org.lwjgl:lwjgl-openal:$lwjgl3Version")
implementation("org.lwjgl:lwjgl-opengl:$lwjgl3Version")
implementation("org.lwjgl:lwjgl-stb:$lwjgl3Version")
}
}
// 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}-${version}-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}-${version}-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 x64 Windows, not Linux or macOS.
// The file size for a Windows-only JAR is about 4MB smaller than a cross-platform JAR.
tasks.register("jarWin") {
dependsOn("jar")
group("build")
jar.archiveFileName.set("${appName}-${version}-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',
"windows/x86/**", "gdx.dll"
)
dependencies {
jar.exclude("macos/arm64/**", "macos/x64/**", "linux/arm32/**", "linux/arm64/**", "linux/x64/**",
'META-INF/INDEX.LIST', 'META-INF/maven/**',
"windows/x86/**", "gdx.dll")
}
}
construo {
// name of the executable
name.set(appName)
// human-readable name, used for example in the `.app` name for macOS
humanName.set(appName)
jlink {
includeDefaultCryptoModules.set(false) // we don't need any encryption in Liftoff itself.
guessModulesFromJar.set(false)
modules.addAll("java.base", "java.management", "java.desktop", "jdk.unsupported")
}
targets.configure {
register("linuxX64", Target.Linux) {
architecture.set(Target.Architecture.X86_64)
jdkUrl.set("https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.10%2B7/OpenJDK21U-jdk_x64_linux_hotspot_21.0.10_7.tar.gz")
}
register("macM1", Target.MacOs) {
architecture.set(Target.Architecture.AARCH64)
jdkUrl.set("https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.10%2B7/OpenJDK21U-jdk_aarch64_mac_hotspot_21.0.10_7.tar.gz")
// macOS needs an identifier
identifier.set("com.libgdx.liftoff." + appName)
// Optional: icon for macOS
macIcon.set(file("icons/logo.icns"))
}
register("macX64", Target.MacOs) {
architecture.set(Target.Architecture.X86_64)
jdkUrl.set("https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.10%2B7/OpenJDK21U-jdk_x64_mac_hotspot_21.0.10_7.tar.gz")
// macOS needs an identifier
identifier.set("com.libgdx.liftoff." + appName)
// Optional: icon for macOS
macIcon.set(file("icons/logo.icns"))
}
register("winX64", Target.Windows) {
architecture.set(Target.Architecture.X86_64)
icon.set(file("icons/gdx-liftoff.png"))
jdkUrl.set("https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.10%2B7/OpenJDK21U-jdk_x64_windows_hotspot_21.0.10_7.zip")
}
}
}
// I can't figure this out for now...
// We only need the platform-specific JAR when making a platform-specific Construo build.
// But, Construo currently can't figure out the modules for jlink when given any other jarTask.
//tasks.register("construoWin") {
// construo.jarTask.set("jarWin")
// dependsOn("packageWinX64")
//}
distributions {
main {
contents {
into('lib') {
project.configurations.runtimeClasspath.files.findAll { file ->
file.getName() != project.tasks.jar.outputs.files.singleFile.name
}.each { file ->
exclude file.name
}
}
}
}
}
startScripts.dependsOn('jar')
startScripts.classpath = project.tasks.jar.outputs.files
tasks.register('sample', JavaExec) {
dependsOn classes
setDescription("Generates a sample libGDX project into build/dist/sample")
mainClass.set("gdx.liftoff.Sample")
setClasspath(sourceSets.main.runtimeClasspath)
}
jar.dependsOn('ktlintFormat')