Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit 7a95481

Browse files
committed
loader dev env fix, document build.gradle.kts
1 parent 7dffd7d commit 7a95481

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

build.gradle.kts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

4-
// TODO: document this file
5-
64
plugins {
75
kotlin("jvm") version "1.7.0"
86
id("fabric-loom") version "0.12-SNAPSHOT"
@@ -18,7 +16,6 @@ version = "$modVersion+$minecraftVersion"
1816
val mavenGroup: String by project
1917
group = mavenGroup
2018

21-
val loaderVersion: String by project
2219
val fabricVersion: String by project
2320

2421
val requiredDependencyMods = dependencyModsOfType("required")
@@ -45,26 +42,29 @@ repositories {
4542

4643
val shade: Configuration by configurations.creating {
4744
isCanBeResolved = true
45+
// Exclude slf4j because it is already provided by Minecraft
4846
exclude(group = "org.slf4j")
4947
}
5048

5149
dependencies {
5250
minecraft("com.mojang:minecraft:$minecraftVersion")
5351
mappings(loom.officialMojangMappings())
5452

55-
modImplementation("net.fabricmc:fabric-loader:$loaderVersion")
53+
val loaderDevVersion: String by project
54+
modImplementation("net.fabricmc:fabric-loader:$loaderDevVersion")
5655
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricVersion")
5756

5857
shadeApi(kotlin("stdlib", "1.7.0"))
5958
shadeApi("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
6059

60+
// Declare mod dependencies listed in gradle.properties
6161
for (mod in requiredDependencyMods) includeModImpl("${mod.artifact}:${mod.version}")
6262
for (mod in optionalDependencyMods) modCompileOnly("${mod.artifact}:${mod.version}")
6363

64-
// discord rpc
64+
// Discord RPC TODO: remove
6565
shadeImpl("com.jagrosh:DiscordIPC:0.4")
6666

67-
// websocket TODO: clean this up
67+
// Websocket TODO: clean this up
6868
shadeImpl("org.java-websocket:Java-WebSocket:1.5.3")
6969
includeImpl("javax.websocket:javax.websocket-api:1.1")
7070
}
@@ -86,22 +86,26 @@ tasks {
8686
withType<KotlinCompile> {
8787
kotlinOptions {
8888
jvmTarget = "17"
89+
// Compile Kotlin interfaces with Java 8 default methods
8990
freeCompilerArgs = listOf("-Xjvm-default=all")
9091
}
9192
}
9293

9394
processResources {
95+
val loaderModVersion: String by project
96+
// These properties can be used in fabric_mod_json_template.txt in Groovy template syntax
9497
val exposedProperties = arrayOf(
9598
"modName" to modName,
9699
"version" to version,
97100
"minecraftVersion" to minecraftVersion,
98-
"loaderVersion" to loaderVersion,
101+
"loaderVersion" to loaderModVersion,
99102
"fabricVersion" to fabricVersion
100103
)
101104

102105
inputs.properties(*exposedProperties)
103106
inputs.properties(project.properties.filterKeys { it.startsWith("required.") })
104107

108+
// Evaluate fabric_mod_json_template.txt as a Groovy template
105109
filesMatching("fabric_mod_json_template.txt") {
106110
val metadataRegex = Regex("""\+[\d\.]+$""")
107111
expand(
@@ -122,19 +126,22 @@ tasks {
122126

123127
val relocate by registering(ConfigureShadowRelocation::class) {
124128
target = shadowJar.get()
129+
// Repackage shaded dependencies
125130
prefix = "$mavenGroup.recode.shaded"
126131
}
127132

128133
shadowJar {
129134
dependsOn(relocate)
130135
configurations = listOf(shade)
136+
// Output shaded jar in the correct destination to be used by remapJar
131137
destinationDirectory.set(file("build/devlibs"))
132138
archiveClassifier.set("dev")
133139

134140
from("LICENSE")
135141
}
136142

137143
remapJar {
144+
// Use the shaded jar with remapJar, since jar is disabled
138145
inputFile.value(shadowJar.get().archiveFile)
139146
}
140147
}
@@ -183,6 +190,9 @@ data class DependencyMod(
183190
val versionKey get() = ""
184191
}
185192

193+
/**
194+
* @return The list of [DependencyMod] values matching [type] in gradle.properties.
195+
*/
186196
fun dependencyModsOfType(type: String) = properties.mapNotNull { (key, value) ->
187197
Regex("""$type\.([a-z][a-z0-9-_]{1,63})\.artifact""").matchEntire(key)?.let { match ->
188198
val id = match.groupValues[1]

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ org.gradle.jvmargs = -Xmx1G
55
modVersion = 0.1.0-beta.4
66
minecraftVersion = 1.19.2
77
fabricVersion = 0.60.0+1.19.2
8+
# The version of Fabric Loader required by Fabric API
9+
loaderDevVersion = 0.14.9
810

911
# Required dependency mods
1012

@@ -22,4 +24,5 @@ optional.modmenu.version = 4.0.6
2224
modName = recode
2325
mavenGroup = io.github.homchom
2426

25-
loaderVersion = 0.13.3
27+
# The minimum version of Fabric Loader required by recode
28+
loaderModVersion = 0.13.3

0 commit comments

Comments
 (0)