@@ -4,8 +4,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
44plugins {
55 kotlin(" jvm" ) version " 2.2.10"
66 id(" fabric-loom" ) version " 1.11-SNAPSHOT"
7- id(" maven-publish" )
87 kotlin(" plugin.serialization" ) version " 1.9.10"
8+ id(" com.github.johnrengelman.shadow" ) version " 8.1.1"
9+
910}
1011
1112version = project.property(" mod_version" ) as String
1819val targetJavaVersion = 21
1920java {
2021 toolchain.languageVersion = JavaLanguageVersion .of(targetJavaVersion)
21- // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
22- // if it is present.
23- // If you remove this line, sources will not be generated.
2422 withSourcesJar()
2523}
2624
@@ -32,11 +30,6 @@ fabricApi {
3230}
3331
3432repositories {
35- // Add repositories to retrieve artifacts from in here.
36- // You should only use this when depending on other mods because
37- // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
38- // See https://docs.gradle.org/current/userguide/declaring_repositories.html
39- // for more information about repositories.
4033 maven (" https://maven.terraformersmc.com/" ) {
4134 name = " Terraformers"
4235 }
@@ -45,6 +38,7 @@ repositories {
4538 }
4639 maven(" https://maven.shedaniel.me/" )
4740 maven(" https://maven.isxander.dev/releases" )
41+ maven(" https://jitpack.io" )
4842 exclusiveContent {
4943 forRepository {
5044 maven(" https://api.modrinth.com/maven" )
@@ -56,31 +50,54 @@ repositories {
5650
5751}
5852
53+ val shade: Configuration by configurations.creating {
54+ isCanBeConsumed = false
55+ isCanBeResolved = true
56+ isVisible = false
57+ }
58+
59+ val mcVer = project.property(" minecraft_version" )
60+ val mappings = project.property(" yarn_mappings" )
61+
62+ val fabricVersion = project.property(" fabric_version" )
63+ val fabricLoader = project.property(" loader_version" )
64+ val kotlinLoader = project.property(" kotlin_loader_version" )
65+ val ktSere = project.property(" kt_sere" )
66+
67+ val xaerosVersion = project.property(" xaeros_version" )
68+ val clothVersion = project.property(" cloth_config" )
69+ val modmenu = project.property(" modmenu" )
70+ val placeholderVersion = project.property(" placeholder_api" )
71+
5972dependencies {
60- minecraft(" com.mojang:minecraft:${project.property( " minecraft_version " )} " )
61- mappings(" net.fabricmc:yarn:${project.property( " yarn_mappings " )} :v2" )
73+ minecraft(" com.mojang:minecraft:$mcVer " )
74+ mappings(" net.fabricmc:yarn:$mappings :v2" )
6275
6376 compileOnly(" org.jetbrains.kotlin:kotlin-stdlib" )
6477 compileOnly(" org.jetbrains.kotlin:kotlin-reflect" )
6578
66- compileOnly(" org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3 " )
79+ compileOnly(" org.jetbrains.kotlinx:kotlinx-serialization-json:$ktSere " )
6780
68- modImplementation(" net.fabricmc:fabric-loader:${project.property( " loader_version " )} " )
69- modImplementation(" net.fabricmc:fabric-language-kotlin: ${project.property( " kotlin_loader_version " )} " )
81+ modImplementation(" net.fabricmc:fabric-loader:$fabricLoader " )
82+ modImplementation(" net.fabricmc.fabric-api :fabric-api: $fabricVersion " )
7083
71- modImplementation(" net.fabricmc.fabric-api :fabric-api: ${project.property( " fabric_version " )} " )
84+ modImplementation(" net.fabricmc:fabric-language-kotlin: $kotlinLoader " )
7285
73- modImplementation(" eu.pb4:placeholder-api:${project.property( " placeholder_api " )} " )
86+ modImplementation(" eu.pb4:placeholder-api:$placeholderVersion " )
7487
75- modApi(" me.shedaniel.cloth:cloth-config-fabric:${project.property( " cloth_config " )} " ) {
88+ modApi(" me.shedaniel.cloth:cloth-config-fabric:$clothVersion " ) {
7689 exclude(" net.fabricmc.fabric-api" )
7790 }
7891
79- modApi(" com.terraformersmc:modmenu:${project.property(" modmenu" )} " )
92+ modApi(" com.terraformersmc:modmenu:$modmenu " )
93+
94+ implementation(" com.github.breakthebot:breakthelibrary:1.0.4" )
95+ shade(" com.github.breakthebot:breakthelibrary:1.0.4" ) {
96+ isTransitive = false
97+ }
98+
8099 modImplementation(" maven.modrinth:xaeros-minimap:${project.property(" xaeros_version" )} " )
81100
82- testImplementation(kotlin(" test" ))
83- testImplementation(" org.junit.jupiter:junit-jupiter:5.10.1" )
84101}
85102
86103tasks.processResources {
@@ -92,22 +109,68 @@ tasks.processResources {
92109 filesMatching(" fabric.mod.json" ) {
93110 expand(
94111 " version" to project.version,
95- " minecraft_version" to project.property(" minecraft_version" ),
96- " loader_version" to project.property(" loader_version" ),
97- " kotlin_loader_version" to project.property(" kotlin_loader_version" )
112+ " minecraft_version" to mcVer,
113+ " loader_version" to fabricLoader,
114+ " kotlin_loader_version" to kotlinLoader,
115+ " cloth_config" to clothVersion,
116+ " placeholder_api" to placeholderVersion,
117+ " modmenu" to modmenu
98118 )
99119 }
100120}
101121
102122tasks.withType<JavaCompile >().configureEach {
103- // ensure that the encoding is set to UTF-8, no matter what the system default is
104- // this fixes some edge cases with special characters not displaying correctly
105- // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
106- // If Javadoc is generated, this must be specified in that task too.
107123 options.encoding = " UTF-8"
108124 options.release.set(targetJavaVersion)
109125}
110126
127+ val headerText = file(" header.txt" ).readText()
128+
129+ val addHeader by tasks.registering {
130+ group = " build"
131+
132+ val targetFiles = fileTree(" src" ) {
133+ include(" **/*.kt" )
134+ include(" **/*.java" )
135+ }
136+
137+ doLast {
138+ targetFiles.forEach { file: File ->
139+ val content = file.readText()
140+ if (! content.startsWith(headerText)) {
141+ file.writeText(" $headerText \n $content " )
142+ }
143+ }
144+ }
145+ }
146+
147+ tasks.shadowJar {
148+ dependsOn(tasks.jar)
149+
150+ archiveClassifier.set(" shadow-dev" )
151+
152+ configurations = listOf (shade)
153+
154+ from(zipTree(tasks.jar.get().archiveFile))
155+
156+ relocate(
157+ " org.breakthebot.breakthelibrary" ,
158+ " net.chariskar.breakthebot.breakthelibrary"
159+ )
160+ }
161+
162+ val remapShadowJar by tasks.registering(net.fabricmc.loom.task.RemapJarTask ::class ) {
163+ dependsOn(tasks.shadowJar)
164+ inputFile.set(tasks.shadowJar.get().archiveFile)
165+ archiveClassifier.set(" shadowed" )
166+
167+ doLast {
168+ delete(tasks.shadowJar.get().archiveFile.get().asFile)
169+ }
170+ }
171+
172+ tasks[" build" ].dependsOn(addHeader, remapShadowJar)
173+
111174tasks.withType<KotlinCompile >().configureEach {
112175 compilerOptions.jvmTarget.set(JvmTarget .fromTarget(targetJavaVersion.toString()))
113176}
@@ -118,10 +181,6 @@ tasks.jar {
118181 }
119182}
120183
121- tasks.test {
122- useJUnitPlatform()
123- }
124-
125184kotlin {
126185 compilerOptions {
127186 allWarningsAsErrors.set(true )
0 commit comments