-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
73 lines (61 loc) · 1.99 KB
/
build.gradle.kts
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
import com.github.jengelman.gradle.plugins.shadow.relocation.SimpleRelocator
plugins {
java
id("com.github.johnrengelman.shadow") version "7.1.0"
`maven-publish`
}
group = "io.github.orioncraftmc"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
tasks {
build.get().dependsOn(shadowJar)
shadowJar {
archiveClassifier.set(null as String?)
// Keep these as is
arrayOf("org.lwjgl.nanovg", "org.lwjgl.util.yoga").forEach {
relocate(it, it)
}
// Relocate these to a different package
arrayOf("org.lwjgl").forEach {
relocate(it, "${project.group}.libs.$it")
}
arrayOf(
"""(windows|macos|linux)(/x64/)(.+?)((?:\.(?:sha1|git|so|dylib|dll))+)""" to "\$1\$2${
"${project.group}.libs".replace(
'.',
'/'
)
}/\$3_orion\$4",
).forEach { pair ->
val relocator = SimpleRelocator(pair.first, pair.second, listOf(), listOf(), true)
arrayOf("pattern", "shadedPattern").forEach {
relocator.javaClass.getDeclaredField(it).apply {
isAccessible = true
set(relocator, "")
}
}
relocate(relocator)
}
}
}
dependencies {
implementation(platform("org.lwjgl:lwjgl-bom:3.2.3"))
implementation("org.lwjgl", "lwjgl")
implementation("org.lwjgl", "lwjgl-nanovg")
implementation("org.lwjgl", "lwjgl-yoga")
listOf("windows", "linux", "macos").forEach { osName ->
val nativeClassifier = "natives-$osName"
runtimeOnly("org.lwjgl", "lwjgl", classifier = nativeClassifier)
runtimeOnly("org.lwjgl", "lwjgl-nanovg", classifier = nativeClassifier)
runtimeOnly("org.lwjgl", "lwjgl-yoga", classifier = nativeClassifier)
}
}
publishing {
publications {
create<MavenPublication>("maven") {
artifact(tasks["shadowJar"])
}
}
}