1+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+ import org.apache.tools.ant.taskdefs.condition.Os
3+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+ import java.util.Calendar
5+ import java.util.TimeZone
6+
7+ plugins {
8+ val kotlin_version: String by System .getProperties()
9+ kotlin(" jvm" ).version(kotlin_version)
10+
11+ id(" com.gradleup.shadow" ) version " 8.3.6"
12+ }
13+
14+ val kotlin_version: String by System .getProperties()
15+ val ktor_version: String by project
16+
17+ group = " cc.modlabs"
18+ version = System .getenv(" VERSION_OVERRIDE" ) ? : Calendar .getInstance(TimeZone .getTimeZone(" UTC" )).run {
19+ " ${get(Calendar .YEAR )} .${get(Calendar .MONTH ) + 1 } .${get(Calendar .DAY_OF_MONTH )} .${
20+ String .format(" %02d%02d" , get(Calendar .HOUR_OF_DAY ), get(Calendar .MINUTE ))
21+ } "
22+ }
23+
24+ repositories {
25+ maven(" https://nexus.modlabs.cc/repository/maven-mirrors/" )
26+ }
27+
28+ val shadowDependencies = listOf (
29+ " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version " ,
30+ " org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version " ,
31+ " io.ktor:ktor-client-core:$ktor_version " ,
32+ " io.ktor:ktor-client-cio:$ktor_version "
33+ // "cc.modlabs:ktale:${project.ext["ktaleVersion"] as String}",
34+ // "cc.modlabs:KlassicX:2025.12.4.1928"
35+ )
36+
37+ dependencies {
38+ testImplementation(kotlin(" test" ))
39+ implementation(" com.hypixel.hytale:Server:2026.01.13-dcad8778f" )
40+
41+ shadowDependencies.forEach {
42+ shadow(it)
43+ implementation(it)
44+ }
45+ }
46+
47+ tasks.test {
48+ useJUnitPlatform()
49+ }
50+ kotlin {
51+ jvmToolchain {
52+ languageVersion.set(JavaLanguageVersion .of(25 ))
53+ }
54+
55+ compilerOptions {
56+ jvmTarget.set(JvmTarget .JVM_25 )
57+ }
58+
59+ }
60+
61+ java {
62+ toolchain {
63+ languageVersion.set(JavaLanguageVersion .of(25 ))
64+ }
65+ }
66+
67+ val cleanArtifacts = tasks.register<Exec >(" cleanArtifacts" ) {
68+ group = " build"
69+ description = " Runs cleanlibs.bat on Windows or cleanlibs.sh on *nix before build"
70+ workingDir = project.rootDir
71+ // choose the right command based on OS
72+ if (Os .isFamily(Os .FAMILY_WINDOWS )) {
73+ commandLine(" cmd" , " /c" , " cleanlibs.bat" )
74+ } else {
75+ commandLine(" sh" , " cleanlibs.sh" )
76+ }
77+ }
78+
79+ tasks {
80+ jar {
81+ dependsOn(cleanArtifacts)
82+ }
83+
84+ build {
85+ dependsOn(" shadowJar" )
86+ }
87+
88+ withType<ProcessResources > {
89+ filesMatching(" manifest.json" ) {
90+ expand(
91+ " version" to project.version,
92+ " name" to project.name,
93+ )
94+ }
95+ }
96+
97+ withType<ShadowJar > {
98+ mergeServiceFiles()
99+ configurations = listOf (project.configurations.shadow.get())
100+ archiveFileName.set(project.name + " -" + project.version + " -shaded.jar" )
101+ exclude(" _COROUTINE/**" )
102+ }
103+ }
0 commit comments