This repository was archived by the owner on Sep 16, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
124 lines (101 loc) · 3.45 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
124 lines (101 loc) · 3.45 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.kotlin.dsl.named
plugins {
java
id("com.gradleup.shadow") version "9.6.1"
}
relocate("org.yaml.snakeyaml")
relocate("org.spongepowered.configurate")
relocate("com.google.gson")
val nativePlatforms = listOf(
"windows-x86_64",
"x86_64",
"aarch64",
"macos-x86_64",
"macos-arm64"
)
val id = project.property("id") as String
val extensionName = project.property("name") as String
val author = project.property("author") as String
val version = project.version as String
val geyserVersion = "2.11.0"
val netherNetVersion = "1.8.0"
val libdatachannelVersion = "0.24.1.1"
val configurateVersion = "4.2.0-GeyserMC-20251111.004649-11"
repositories {
// Repo for the Geyser API artifact
maven("https://repo.opencollab.dev/main/")
// Add other repositories here
mavenCentral()
}
dependencies {
// Geyser API - needed for all extensions
compileOnly("org.geysermc.geyser:api:$geyserVersion-SNAPSHOT")
// Geyser Core - we use things not exposed in the API
compileOnly("org.geysermc.geyser:core:$geyserVersion-SNAPSHOT")
// The NetherNet Netty transport
implementation("dev.kastle.netty:netty-transport-nethernet:$netherNetVersion")
// The WebRTC library and its natives
implementation("tel.schich:libdatachannel-java:$libdatachannelVersion")
nativePlatforms.forEach { platform ->
runtimeOnly("tel.schich:libdatachannel-java:$libdatachannelVersion:$platform")
}
// Configurate
annotationProcessor("org.spongepowered:configurate-extra-interface-ap:$configurateVersion")
implementation("org.spongepowered:configurate-extra-interface:$configurateVersion")
implementation("org.spongepowered:configurate-yaml:$configurateVersion")
}
// Java currently requires Java 21 or higher, so extensions should also target it
java {
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
}
afterEvaluate {
val idRegex = Regex("[a-z][a-z0-9-_]{0,63}")
if (idRegex.matches(id).not()) {
throw IllegalArgumentException("Invalid extension id $id! Must only contain lowercase letters, " +
"and cannot start with a number.")
}
val nameRegex = Regex("^[A-Za-z_.-]+$")
if (nameRegex.matches(extensionName).not()) {
throw IllegalArgumentException("Invalid extension name $extensionName! Must fit regex: ${nameRegex.pattern})")
}
}
tasks {
// This automatically fills in the extension.yml file.
processResources {
filesMatching("extension.yml") {
expand(
"id" to id,
"name" to extensionName,
"api" to geyserVersion,
"version" to version,
"author" to author
)
}
}
jar {
enabled = false
}
shadowJar {
dependencies {
// Exclude netty apart from the http codec
exclude {
it.moduleGroup == "io.netty" && (it.moduleName != "netty-codec-http" && it.moduleName != "netty-handler")
}
exclude {
it.moduleGroup == "org.slf4j"
}
}
archiveClassifier.set("")
archiveVersion.set("")
}
build {
dependsOn(shadowJar)
}
}
fun Project.relocate(pattern: String) {
tasks.named<ShadowJar>("shadowJar") {
relocate(pattern, "org.geyser.extension.nethernet.shaded.$pattern")
}
}