Skip to content

Commit 15f0bf2

Browse files
committedFeb 17, 2025·
chore: Migrate to Kotlin DSL
1 parent 8cce1c1 commit 15f0bf2

File tree

1 file changed

+139
-137
lines changed

1 file changed

+139
-137
lines changed
 

‎build.gradle.kts

+139-137
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
//file:noinspection GroovyAssignabilityCheck
2-
//file:noinspection GroovyAccessibility
31
import xyz.jpenilla.runtask.task.AbstractRun
2+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
3+
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
4+
import xyz.jpenilla.runpaper.task.RunServer
45

56
plugins {
6-
id 'java'
7-
id "maven-publish"
7+
id("java")
8+
id("maven-publish")
89
alias(libs.plugins.plugin.yml)
910
alias(libs.plugins.minotaur)
1011
alias(libs.plugins.run.server)
1112
alias(libs.plugins.shadow)
1213
}
1314

14-
group = 'me.adrigamer2950'
15-
version = properties.get("version") + (
16-
project.hasProperty("BUILD_NUMBER") ?
17-
(project.property("BUILD_NUMBER") == "0" ? "" : ("-b" + project.property("BUILD_NUMBER")))
18-
: ""
19-
)
20-
author = properties.get("author")
15+
val group = "me.adrigamer2950"
16+
val version = properties["version"] as String + (
17+
if (project.hasProperty("BUILD_NUMBER")) {
18+
if (project.property("BUILD_NUMBER") == "0") "" else "-b" + project.property("BUILD_NUMBER")
19+
} else {
20+
""
21+
}
22+
)
2123

2224
if (project.hasProperty("NEXUS_USERNAME") && project.hasProperty("NEXUS_PASSWORD")) {
2325
java {
@@ -28,34 +30,33 @@ if (project.hasProperty("NEXUS_USERNAME") && project.hasProperty("NEXUS_PASSWORD
2830
publishing {
2931
repositories {
3032
maven {
31-
def baseUrl = "https://repo.devadri.es/repository/"
33+
val baseUrl = "https://repo.devadri.es/repository/"
3234

3335
url = uri(
34-
baseUrl + (project.hasProperty("BUILD_NUMBER") ? "dev" : "releases")
36+
baseUrl + if (project.hasProperty("BUILD_NUMBER")) "dev" else "releases"
3537
)
3638
credentials {
37-
username = project.property("NEXUS_USERNAME")
38-
password = project.property("NEXUS_PASSWORD")
39+
username = project.property("NEXUS_USERNAME") as String
40+
password = project.property("NEXUS_PASSWORD") as String
3941
}
4042
}
4143
}
4244
publications {
43-
maven(MavenPublication) {
44-
groupId = this.group
45+
create<MavenPublication>("mavenJava") {
46+
groupId = group
4547
artifactId = rootProject.name
4648
version = this.version
4749

48-
from components.java
49-
50+
from(components["java"])
5051
pom {
5152
name = rootProject.name
5253
description = this.description
5354
url = "https://github.com/Adrigamer2950/AdriAPI"
5455

5556
licenses {
5657
license {
57-
name = 'GPL-3.0'
58-
url = 'https://www.gnu.org/licenses/gpl-3.0.html'
58+
name = "GPL-3.0"
59+
url = "https://www.gnu.org/licenses/gpl-3.0.html"
5960
}
6061
}
6162

@@ -71,8 +72,8 @@ if (project.hasProperty("NEXUS_USERNAME") && project.hasProperty("NEXUS_PASSWORD
7172
}
7273

7374
issueManagement {
74-
system = 'GitHub'
75-
url = 'https://github.com/Adrigamer2950/AdriAPI/issues'
75+
system = "GitHub"
76+
url = "https://github.com/Adrigamer2950/AdriAPI/issues"
7677
}
7778
}
7879
}
@@ -84,159 +85,160 @@ repositories {
8485
mavenCentral()
8586
maven {
8687
name = "sonatype"
87-
url = "https://oss.sonatype.org/content/groups/public/"
88+
url = uri("https://oss.sonatype.org/content/groups/public/")
8889
}
8990
maven {
90-
url = "https://repo.papermc.io/repository/maven-public/"
91+
url = uri("https://repo.papermc.io/repository/maven-public/")
9192
}
9293
maven {
9394
name = "AlessioDP"
94-
url = "https://repo.alessiodp.com/releases"
95+
url = uri("https://repo.alessiodp.com/releases")
9596
}
9697
}
9798

9899
dependencies {
99100
// JetBrains Annotations
100-
compileOnly libs.jetbrains.annotations
101+
compileOnly(libs.jetbrains.annotations)
101102

102103
// Folia API
103104
//noinspection VulnerableLibrariesLocal
104-
compileOnly libs.folia.api
105+
compileOnly(libs.folia.api)
105106

106107
// Lombok
107-
compileOnly libs.lombok
108-
annotationProcessor libs.lombok
108+
compileOnly(libs.lombok)
109+
annotationProcessor(libs.lombok)
109110

110111
// Ansi
111-
compileOnly libs.jansi
112+
compileOnly(libs.jansi)
112113

113114
// Adventure API
114-
compileOnly libs.adventure.platform.bukkit
115-
bukkitLibrary libs.adventure.platform.bukkit
115+
compileOnly(libs.adventure.platform.bukkit)
116+
bukkitLibrary(libs.adventure.platform.bukkit)
116117

117118
// Libby
118-
implementation libs.libby
119+
implementation(libs.libby)
119120
}
120121

121-
def targetJavaVersion = 17
122+
val targetJavaVersion = 17
122123

123-
tasks {
124-
tasks.withType(JavaCompile).configureEach {
125-
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
126-
options.release = targetJavaVersion
127-
options.encoding = 'UTF-8'
128-
}
124+
tasks.withType<JavaCompile>().configureEach {
125+
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
126+
options.release = targetJavaVersion
127+
options.encoding = "UTF-8"
129128
}
129+
}
130130

131-
java {
132-
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
133-
sourceCompatibility = javaVersion
134-
targetCompatibility = javaVersion
135-
if (JavaVersion.current() < javaVersion) {
136-
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
137-
}
131+
java {
132+
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
133+
sourceCompatibility = javaVersion
134+
targetCompatibility = javaVersion
135+
if (JavaVersion.current() < javaVersion) {
136+
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
138137
}
138+
}
139139

140-
bukkit {
141-
name = "AdriAPI"
142-
version = version
143-
main = "me.adrigamer2950.adriapi.AdriAPI"
144-
apiVersion = "1.18"
145-
author = author
146-
description = this.description
147-
website = "https://github.com/Adrigamer2950/AdriAPI"
148-
load = 'STARTUP'
149-
foliaSupported = true
150-
151-
commands {
152-
adriapi {
153-
description = "Main command"
154-
usage = "/adriapi"
155-
}
140+
bukkit {
141+
name = "AdriAPI"
142+
main = "me.adrigamer2950.adriapi.AdriAPI"
143+
apiVersion = "1.18"
144+
author = properties["author"] as String?
145+
description = properties["description"] as String?
146+
website = "https://github.com/Adrigamer2950/AdriAPI"
147+
load = BukkitPluginDescription.PluginLoadOrder.STARTUP
148+
foliaSupported = true
149+
150+
commands {
151+
register("adriapi") {
152+
description = "Main command"
153+
usage = "/adriapi"
156154
}
157155
}
156+
}
158157

159-
modrinth {
160-
token = System.getenv("MODRINTH_TOKEN")
161-
projectId = "adriapi"
162-
versionNumber = version
163-
versionName = rootProject.name + " " + version
164-
versionType = "release"
165-
uploadFile = jar
166-
gameVersions = [
167-
"1.18",
168-
"1.18.1",
169-
"1.18.2",
170-
"1.19",
171-
"1.19.1",
172-
"1.19.2",
173-
"1.19.3",
174-
"1.19.4",
175-
"1.20",
176-
"1.20.1",
177-
"1.20.2",
178-
"1.20.3",
179-
"1.20.4",
180-
"1.20.5",
181-
"1.20.6",
182-
"1.21",
183-
"1.21.1",
184-
"1.21.2",
185-
"1.21.3",
186-
"1.21.4"
187-
]
188-
loaders = [
189-
"bukkit",
190-
"folia",
191-
"paper",
192-
"purpur",
193-
"spigot"
194-
]
195-
syncBodyFrom = rootProject.file("README.md").text
196-
}
158+
modrinth {
159+
token = System.getenv("MODRINTH_TOKEN")
160+
projectId = "adriapi"
161+
versionNumber = version
162+
versionName = rootProject.name + " " + version
163+
versionType = "release"
164+
uploadFile.set(tasks.named("jar"))
165+
gameVersions.set(
166+
listOf(
167+
"1.18",
168+
"1.18.1",
169+
"1.18.2",
170+
"1.19",
171+
"1.19.1",
172+
"1.19.2",
173+
"1.19.3",
174+
"1.19.4",
175+
"1.20",
176+
"1.20.1",
177+
"1.20.2",
178+
"1.20.3",
179+
"1.20.4",
180+
"1.20.5",
181+
"1.20.6",
182+
"1.21",
183+
"1.21.1",
184+
"1.21.2",
185+
"1.21.3",
186+
"1.21.4"
187+
)
188+
)
189+
loaders.set(
190+
listOf(
191+
"bukkit",
192+
"folia",
193+
"paper",
194+
"purpur",
195+
"spigot"
196+
)
197+
)
198+
syncBodyFrom = rootProject.file("README.md").readText()
199+
}
197200

198-
runServer {
199-
minecraftVersion("1.20.2")
201+
tasks.named<RunServer>("runServer").configure {
202+
minecraftVersion("1.20.2")
200203

201-
downloadPlugins {
202-
// ViaVersion
203-
hangar("ViaVersion", "5.2.0")
204-
}
204+
downloadPlugins {
205+
// ViaVersion
206+
hangar("ViaVersion", "5.2.0")
205207
}
208+
}
206209

207-
tasks.withType(AbstractRun).configureEach {
208-
javaLauncher = javaToolchains.launcherFor {
209-
vendor = JvmVendorSpec.JETBRAINS
210-
languageVersion = JavaLanguageVersion.of(targetJavaVersion)
211-
}
212-
jvmArgs(
213-
// Hot Swap
214-
"-XX:+AllowEnhancedClassRedefinition",
215-
216-
// Aikar Flags
217-
"--add-modules=jdk.incubator.vector", "-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled",
218-
"-XX:MaxGCPauseMillis=200", "-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC",
219-
"-XX:+AlwaysPreTouch", "-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40",
220-
"-XX:G1HeapRegionSize=8M", "-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5",
221-
"-XX:G1MixedGCCountTarget=4", "-XX:InitiatingHeapOccupancyPercent=15",
222-
"-XX:G1MixedGCLiveThresholdPercent=90", "-XX:G1RSetUpdatingPauseTimePercent=5",
223-
"-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem", "-XX:MaxTenuringThreshold=1",
224-
"-Dusing.aikars.flags=https://mcflags.emc.gs", "-Daikars.new.flags=true"
225-
)
226-
210+
tasks.withType(AbstractRun::class) {
211+
javaLauncher = javaToolchains.launcherFor {
212+
vendor = JvmVendorSpec.JETBRAINS
213+
languageVersion = JavaLanguageVersion.of(targetJavaVersion)
227214
}
215+
jvmArgs(
216+
// Hot Swap
217+
"-XX:+AllowEnhancedClassRedefinition",
218+
219+
// Aikar Flags
220+
"--add-modules=jdk.incubator.vector", "-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled",
221+
"-XX:MaxGCPauseMillis=200", "-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC",
222+
"-XX:+AlwaysPreTouch", "-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40",
223+
"-XX:G1HeapRegionSize=8M", "-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5",
224+
"-XX:G1MixedGCCountTarget=4", "-XX:InitiatingHeapOccupancyPercent=15",
225+
"-XX:G1MixedGCLiveThresholdPercent=90", "-XX:G1RSetUpdatingPauseTimePercent=5",
226+
"-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem", "-XX:MaxTenuringThreshold=1",
227+
"-Dusing.aikars.flags=https://mcflags.emc.gs", "-Daikars.new.flags=true"
228+
)
228229

229-
shadowJar {
230-
archiveClassifier.set("")
230+
}
231231

232-
dependencies {
233-
relocate "net.byteflux.libby", "me.adrigamer2950.adriapi.lib.libby"
232+
tasks.named<ShadowJar>("shadowJar") {
233+
archiveClassifier.set("")
234234

235-
//relocate "com.iridium.iridiumcolorapi", "me.adrigamer2950.adriapi.libs.iridiumcolorapi"
236-
}
237-
}
235+
dependencies {
236+
relocate("net.byteflux.libby", "me.adrigamer2950.adriapi.lib.libby")
238237

239-
build {
240-
finalizedBy("shadowJar")
238+
//relocate("com.iridium.iridiumcolorapi", "me.adrigamer2950.adriapi.libs.iridiumcolorapi")
241239
}
240+
}
241+
242+
tasks.named("build") {
243+
finalizedBy(tasks.named("shadowJar"))
242244
}

0 commit comments

Comments
 (0)
Please sign in to comment.