Skip to content

Commit d368b7f

Browse files
committed
Simplify MinecraftVersion generics; misc updates
Convert MinecraftVersion from a generic interface to a non-generic one and update all usages (types, collections, parsing results, compareTo signatures, helpers and conditionals) to match. Bump com.gradleup.shadow plugin to 9.4.0 and project.version to 2.75.0; reduce org.gradle.jvmargs to -Xmx2G. Add extra runtime dependencies for drop versions in loom.gradle.kts and fix shadow fatJar configuration. Add debug logging when resolving MCData version and minor parser/validation tweaks in MinecraftDropVersion. Misc. import and utility adjustments (fabricId formatting, version utilities) to align with the API changes.
1 parent a035341 commit d368b7f

19 files changed

Lines changed: 92 additions & 94 deletions

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dependencies {
5454
implementation("com.github.breadmoirai:github-release:2.5.2")
5555

5656
// Other
57-
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:8.3.8")
57+
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.4.0")
5858
implementation("dev.deftu:Bloom:0.2.0")
5959
}
6060

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Project args
22
kotlin.code.style=official
33
kotlin.version=2.3.0
4-
org.gradle.jvmargs=-Xmx8G
4+
org.gradle.jvmargs=-Xmx2G
55

66
# Project properties
77
project.name=gradle-toolkit
8-
project.version=2.70.0
8+
project.version=2.75.0
99
project.group=dev.deftu.gradle

src/main/kotlin/dev/deftu/gradle/tools/minecraft/ReleasingExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class ReleasingExtension(
2020
abstract val version: Property<String>
2121
abstract val versionType: Property<VersionType>
2222
abstract val detectVersionType: Property<Boolean>
23-
abstract val gameVersions: ListProperty<MinecraftVersion<*>>
23+
abstract val gameVersions: ListProperty<MinecraftVersion>
2424
abstract val loaders: ListProperty<ModLoader>
2525
abstract val file: Property<Zip>
2626

src/main/kotlin/dev/deftu/gradle/tools/minecraft/ReleasingV2Extension.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class ReleasingV2Extension @Inject constructor(private val project: Pro
2525
abstract val debugMode: Property<Boolean>
2626
abstract val releaseName: Property<String>
2727
abstract val releaseVersion: Property<String>
28-
abstract val gameVersions: ListProperty<MinecraftVersion<*>>
28+
abstract val gameVersions: ListProperty<MinecraftVersion>
2929
abstract val loaders: ListProperty<ModLoader>
3030

3131
val versionType: Property<VersionType> = this.objects.property()
@@ -138,7 +138,7 @@ abstract class ReleasingV2Extension @Inject constructor(private val project: Pro
138138
return "${version}${suffix}"
139139
}
140140

141-
private fun defaultGameVersions(): List<MinecraftVersion<*>> {
141+
private fun defaultGameVersions(): List<MinecraftVersion> {
142142
val mcData = MCData.from(project)
143143
return listOf(mcData.version)
144144
}

src/main/kotlin/dev/deftu/gradle/tools/minecraft/loom.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import dev.deftu.gradle.utils.*
88
import dev.deftu.gradle.utils.mcinfo.MinecraftInfo
99
import dev.deftu.gradle.utils.version.MinecraftDropVersion
1010
import dev.deftu.gradle.utils.version.MinecraftVersions
11+
import org.gradle.kotlin.dsl.version
1112

1213
// Set XML parsers so Gradle stops complaining.
1314
extra.set("systemProp.javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl")
@@ -191,6 +192,14 @@ dependencies {
191192
mcData.isNeoForge -> "neoForge"("net.neoforged:neoforge:${mcData.dependencies.neoForged.neoForgeVersion}")
192193
}
193194
}
195+
196+
if (mcData.version.isDrop) {
197+
// These aren't on the classpath for some reason? So we'll just add them manually for now
198+
implementation("net.fabricmc:sponge-mixin:0.17.0+mixin.0.8.7")
199+
implementation("io.github.llamalad7:mixinextras-fabric:0.5.0")
200+
implementation("org.ow2.asm:asm:9.9")
201+
implementation("org.ow2.asm:asm-tree:9.9")
202+
}
194203
}
195204

196205
// https://github.com/architectury/architectury-loom/pull/10

src/main/kotlin/dev/deftu/gradle/tools/minecraft/releases-v2.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fun setupModrinth(token: String) {
7171
if (extension.jars.isUsingSourcesJar) this.additionalFiles.add(extension.jars.uploadedSourcesJar)
7272
if (extension.jars.isUsingJavadocJar) this.additionalFiles.add(extension.jars.uploadedJavadocJar)
7373

74-
this.gameVersions.addAll(extension.gameVersions.get().map(MinecraftVersion<*>::toString))
74+
this.gameVersions.addAll(extension.gameVersions.get().map(MinecraftVersion::toString))
7575
this.loaders.addAll(extension.loaders.get().map(ModLoader::toString))
7676

7777
this.dependencies.addAll(extension.dependencies.map { dependency ->
@@ -116,7 +116,7 @@ fun setupCurseForge(token: String) {
116116
if (extension.jars.isUsingSourcesJar) withAdditionalFile(extension.jars.uploadedSourcesJar)
117117
if (extension.jars.isUsingJavadocJar) withAdditionalFile(extension.jars.uploadedJavadocJar)
118118

119-
extension.gameVersions.get().map(MinecraftVersion<*>::toString).forEach(this::addGameVersion)
119+
extension.gameVersions.get().map(MinecraftVersion::toString).forEach(this::addGameVersion)
120120
extension.loaders.get().map(ModLoader::toString).forEach(this::addModLoader)
121121

122122
extension.dependencies.forEach { dependency ->

src/main/kotlin/dev/deftu/gradle/tools/minecraft/releases.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fun setupModrinth(token: String) {
164164
}
165165

166166
changelog.set(extension.changelog.get())
167-
gameVersions.addAll(extension.getGameVersions().map(MinecraftVersion<*>::toString))
167+
gameVersions.addAll(extension.getGameVersions().map(MinecraftVersion::toString))
168168
loaders.addAll(extension.getLoaders().map(ModLoader::toString))
169169
if (mcData.isFabric && extension.describeFabricWithQuilt.getOrElse(false)) {
170170
loaders.add("quilt")

src/main/kotlin/dev/deftu/gradle/tools/shadow.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ val fatJar = tasks.register<ShadowJar>("fatJar") {
2020
description = "Builds a fat JAR with all dependencies shaded in"
2121

2222
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
23-
configurations = mutableListOf(shade) as List<FileCollection>? // Complains about useless cast but also complains about not being a compatible type... Okay...
23+
configurations.add(shade)
2424
archiveVersion.set(project.version.toString())
2525
archiveClassifier.set("all")
2626

src/main/kotlin/dev/deftu/gradle/utils/MCData.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class MCDependencies(
248248
data class MCData(
249249
val project: Project,
250250
val isPresent: Boolean,
251-
val version: MinecraftVersion<*>,
251+
val version: MinecraftVersion,
252252
val loader: ModLoader
253253
) {
254254
val isFabric: Boolean get() = loader == ModLoader.FABRIC
@@ -296,6 +296,7 @@ data class MCData(
296296
}
297297

298298
val version = MinecraftVersions.get(project, project.minecraftVersion)
299+
project.logger.debug("Determined Minecraft version for project {} as {} [{}]", project.name, version, version::class.java)
299300
val data = MCData(project, true, version, project.modLoader)
300301
project.extensions.add("mcData", data)
301302
return data

src/main/kotlin/dev/deftu/gradle/utils/mcinfo/MinecraftInfo.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,27 @@ sealed class MinecraftInfo {
7070
this.parchmentVersions.putAll(other.parchmentVersions)
7171
}
7272

73-
fun getFabricYarnVersion(version: MinecraftVersion<*>): String {
73+
fun getFabricYarnVersion(version: MinecraftVersion): String {
7474
return fabricYarnVersions[version]
7575
?: throw IllegalArgumentException("No Fabric Yarn version found for $version")
7676
}
7777

78-
fun getFabricApiVersion(version: MinecraftVersion<*>): String {
78+
fun getFabricApiVersion(version: MinecraftVersion): String {
7979
return fabricApiVersions[version]
8080
?: throw IllegalArgumentException("No Fabric API version found for $version")
8181
}
8282

83-
fun getFabricModMenuDefinition(version: MinecraftVersion<*>): Pair<String, String> {
83+
fun getFabricModMenuDefinition(version: MinecraftVersion): Pair<String, String> {
8484
return fabricModMenuDefinitions[version]
8585
?: throw IllegalArgumentException("No Fabric Mod Menu definition found for $version")
8686
}
8787

88-
fun getLegacyFabricYarnVersion(version: MinecraftVersion<*>): String {
88+
fun getLegacyFabricYarnVersion(version: MinecraftVersion): String {
8989
return legacyFabricYarnVersions[version]
9090
?: throw IllegalArgumentException("No Legacy Fabric Yarn version found for $version")
9191
}
9292

93-
fun getLegacyFabricApiVersion(version: MinecraftVersion<*>): String {
93+
fun getLegacyFabricApiVersion(version: MinecraftVersion): String {
9494
return legacyFabricApiVersions[version]
9595
?: throw IllegalArgumentException("No Legacy Fabric API version found for $version")
9696
}
@@ -99,30 +99,30 @@ sealed class MinecraftInfo {
9999
* we need to do a comparison here as we don't expect all versions to be filled out. rather,
100100
* it's a range, where we just match the closest version that is less than or equal to the given version.
101101
*/
102-
fun getKotlinForForgeVersion(version: MinecraftVersion<*>): String {
102+
fun getKotlinForForgeVersion(version: MinecraftVersion): String {
103103
return kotlinForForgeVersions
104104
.filter { it.key <= version }
105105
.maxByOrNull { it.key }?.value
106106
?: throw IllegalArgumentException("No Kotlin for Forge version found for $version")
107107
}
108108

109-
fun getForgeVersion(version: MinecraftVersion<*>): String {
109+
fun getForgeVersion(version: MinecraftVersion): String {
110110
return forgeVersions[version]
111111
?: throw IllegalArgumentException("No Forge version found for $version")
112112
}
113113

114-
fun getMcpDefinition(version: MinecraftVersion<*>): String {
114+
fun getMcpDefinition(version: MinecraftVersion): String {
115115
val definition = mcpDefinitions[version]
116116
?: throw IllegalArgumentException("No MCP definition found for $version")
117117
return "de.oceanlabs.mcp:mcp_$definition"
118118
}
119119

120-
fun getNeoForgeVersion(version: MinecraftVersion<*>): String {
120+
fun getNeoForgeVersion(version: MinecraftVersion): String {
121121
return neoForgeVersions[version]
122122
?: throw IllegalArgumentException("No NeoForge version found for $version")
123123
}
124124

125-
fun getParchmentVersion(version: MinecraftVersion<*>): String {
125+
fun getParchmentVersion(version: MinecraftVersion): String {
126126
return parchmentVersions[version]
127127
?: throw IllegalArgumentException("No Parchment version found for $version")
128128
}

0 commit comments

Comments
 (0)