@@ -94,15 +94,18 @@ allprojects {
9494 library " com.viaversion:viabackwards-common:5.8.0"
9595 library " com.viaversion:viarewind-common:4.0.15"
9696 library " com.viaversion:viaaprilfools-common:4.1.0"
97- library (" net.raphimc:ViaLegacy:3.0.14" ) {
97+ library(" net.raphimc:ViaLegacy:3.0.14" ) {
9898 exclude group : " com.google.code.gson" , module : " gson"
9999 }
100100 }
101101}
102102
103103subprojects {
104- apply plugin : " net.minecraftforge.gradle"
105- apply plugin : " org.spongepowered.mixin"
104+ def applyFg = project. hasProperty(" applyFg" ) ? Boolean . parseBoolean(project. applyFg) : true
105+ if (applyFg) {
106+ apply plugin : " net.minecraftforge.gradle"
107+ apply plugin : " org.spongepowered.mixin"
108+ }
106109 apply plugin : " me.modmuss50.mod-publish-plugin"
107110
108111 // Define the jar output attributes for all platforms
@@ -120,79 +123,56 @@ subprojects {
120123 // Used to execute code only for specific submodules
121124 def versionId = Integer . parseInt(mcVersion. replace(" ." , " " ))
122125
123- // Java 17 is default, set newer versions here
124- if (versionId >= 1_20_6) {
125- compileJava. setSourceCompatibility(" 21" )
126- compileJava. setTargetCompatibility(" 21" )
127- }
128126 compileJava. options. encoding = " UTF-8"
129127
130128 dependencies {
131129 library project(" :" ) // Include the base project
132130 }
133131
134- minecraft {
135- // Unify to mojang mappings for 1.14+, MCP for below
136- if (versionId >= 1_16_5) {
137- mappings channel : " official" , version : mcVersion
138- }
139-
140- // Official mappings at runtime for 1.20.5+
141- if (versionId >= 1_20_5) {
142- reobf = false
143- }
144-
145- runs {
146- client {
147- workingDirectory project. file(" run" )
148-
149- property " forge.logging.markers" , " REGISTRIES"
150- property " forge.logging.console.level" , " debug"
151-
152- // mixin
153- property " mixin.debug.export" , " true"
154- property " mixin.hotSwap" , " true"
155- property " fml.coreMods.load" , " com.viaversion.viaforge.mixin.MixinLoader"
156- // Only required for MC 1.12, but modern Forges skips this anyway
157- args " -mixin.config=" + " mixins.viaforge.json"
158-
159- // source set
160- mods {
161- " ${ project.name} " {
162- source sourceSets. main
132+ if (applyFg) {
133+ minecraft {
134+ runs {
135+ client {
136+ workingDirectory project. file(" run" )
137+
138+ property " forge.logging.markers" , " REGISTRIES"
139+ property " forge.logging.console.level" , " debug"
140+
141+ // mixin
142+ property " mixin.debug.export" , " true"
143+ property " mixin.hotSwap" , " true"
144+ property " fml.coreMods.load" , " com.viaversion.viaforge.mixin.MixinLoader"
145+ // Only required for MC 1.12, but modern Forges skips this anyway
146+ args " -mixin.config=" + " mixins.viaforge.json"
147+
148+ // source set
149+ mods {
150+ " ${ project.name} " {
151+ source sourceSets. main
152+ }
163153 }
164154 }
165155 }
166156 }
167- }
168157
169- sourceSets. main. resources {
170- srcDir " src/generated/resources"
171- }
172-
173- dependencies {
174- minecraft " net.minecraftforge:forge:${ forge_version} "
175- library " org.slf4j:slf4j-api:2.0.17"
176-
177- if (versionId >= 1_16_5 && versionId < 1_20_6) {
178- // Always include for refmap in versions that don't have official mappings at runtime,
179- // later exclude classes to prevent loading conflicts...
180- library " org.spongepowered:mixin:${ mixin_version} "
181- annotationProcessor " org.spongepowered:mixin:${ mixin_version} :processor"
158+ sourceSets. main. resources {
159+ srcDir " src/generated/resources"
182160 }
183161
184- if (versionId >= 1_20_6) {
185- // NeoForge, only to compile against
186- compileOnly(" net.neoforged.fancymodloader:loader:2.0.20" ) { transitive = false }
187- compileOnly(" net.neoforged:bus:8.0.5" ) { transitive = false }
162+ dependencies {
163+ minecraft " net.minecraftforge:forge:${ forge_version} "
164+
165+ if (versionId > 1_8_9) {
166+ library " org.slf4j:slf4j-api:2.0.17"
167+ library " org.spongepowered:mixin:${ mixin_version} "
168+ annotationProcessor " org.spongepowered:mixin:${ mixin_version} :processor"
169+ }
188170 }
189- }
190171
191- mixin {
192- add sourceSets. main, " mixins.viaforge.refmap.json"
193- }
172+ mixin {
173+ add sourceSets. main, " mixins.viaforge.refmap.json"
174+ }
194175
195- if (versionId < 1_20_6) { // Use official mappings at runtime, otherwise re-obfuscate output
196176 reobf {
197177 shadowJar {}
198178 }
@@ -239,25 +219,12 @@ subprojects {
239219 }
240220
241221 shadowJar {
242- if (versionId >= 1_17_1) {
243- archiveFileName = jar. archiveFileName
244- } else {
245- destinationDirectory = temporaryDir
246- }
222+ destinationDirectory = temporaryDir
247223 configurations = [project. configurations. library] // Include the dependencies from the include configuration
248224 duplicatesStrategy DuplicatesStrategy . EXCLUDE
249225
250226 // Prevent conflicts with Forge's weird service loading
251227 exclude(" META-INF/maven/**" )
252- if (versionId >= 1_13_2) {
253- // We don't need to package mixins into Forge 1.13+ jars, since Forge already has it
254- exclude(" org/spongepowered/**" )
255- }
256- if (versionId >= 1_16_5) {
257- // Get rid of the services folder, since Forge 1.16+ would conflict with some of the ForgeDev Environment's services
258- // And since we don't need them for Mixins anyway, we can just exclude them from the shadowJar
259- exclude(" META-INF/services/**" )
260- }
261228
262229 // Workaround GH-94
263230 relocate(" org.slf4j" , " com.viaversion.viaforge.libs.slf4j" )
@@ -269,23 +236,49 @@ subprojects {
269236 logLevel = " FATAL"
270237 }
271238
239+ if (! applyFg) {
240+ afterEvaluate {
241+ // Unimined creates remap tasks later; pick the remapped archive task dynamically.
242+ def remapArchiveTask = tasks. findAll {
243+ it. name. toLowerCase(). contains(" remap" ) && it. hasProperty(" archiveFile" )
244+ }. sort { it. name }. find { it. name. toLowerCase(). contains(" shadow" ) } ?: tasks. findAll {
245+ it. name. toLowerCase(). contains(" remap" ) && it. hasProperty(" archiveFile" )
246+ }. sort { it. name }. find()
247+
248+ if (remapArchiveTask == null ) {
249+ throw new GradleException (" No remap archive task found for ${ project.path} " )
250+ }
251+
252+ tasks. named(" downgradeJar" ) {
253+ dependsOn(remapArchiveTask)
254+ inputFile = remapArchiveTask. archiveFile
255+ }
256+
257+ // remapJar (from the dev jar) can overwrite the release artifact path in build/libs.
258+ def remapDevJarTask = tasks. findByName(" remapJar" )
259+ if (remapDevJarTask != null ) {
260+ remapDevJarTask. enabled = false
261+ }
262+
263+ tasks. matching { it. name == " publishCurseforge" || it. name == " publishModrinth" || it. name == " publishMods" }. configureEach {
264+ dependsOn(remapArchiveTask)
265+ dependsOn(tasks. named(" shadeDowngradedApi" ))
266+ }
267+ }
268+ }
269+
272270 shadeDowngradedApi {
273- archiveFileName = jar. archiveFileName
271+ // Keep publish artifact stable across toolchains; Unimined jar names can carry a -dev classifier.
272+ archiveFileName = " ${ project.name} -${ project.version} .jar"
274273 logLevel = " FATAL"
275274 }
276275
277276 jar. dependsOn(" shadowJar" )
278- if (versionId < 1_17_1) {
279- // Downgrade the jar to Java 8 for Minecraft 1.16.5 and below
280- jar. dependsOn(" shadeDowngradedApi" )
281- }
277+ // Downgrade the jar to Java 8 for Minecraft 1.16.5 and below
278+ jar. dependsOn(" shadeDowngradedApi" )
282279
283280 publishMods {
284- if (versionId < 1_17_1) { // FG's reobfuscation will rename the jar in place, so use the one *before* finalizing the jar
285- file = tasks. shadeDowngradedApi. archiveFile
286- } else {
287- file = tasks. shadowJar. archiveFile
288- }
281+ file = tasks. shadeDowngradedApi. archiveFile
289282 def commitHash = latestCommitHash(rootProject)
290283 def commitMessage = latestCommitMessage(rootProject). replaceAll(" \\ s+" , " " ). trim()
291284 if (commitHash == " unknown" || commitMessage == " unknown" ) {
@@ -296,22 +289,13 @@ subprojects {
296289 version = project. version. toString() + " +" + mcVersion
297290 displayName = version
298291 modLoaders. add(" forge" )
299- if (versionId == 1_20_1 || versionId >= 1_20_6) {
300- modLoaders. add(" neoforge" )
301- }
302292 type = ReleaseType . ALPHA
303293
304294 curseforge {
305295 accessToken = System . getenv(" CURSEFORGE_TOKEN" )
306296 projectId = " 418933"
307297
308- if (versionId < 1_17_1) {
309- javaVersions. add(JavaVersion . VERSION_1_8 )
310- } else if (versionId < 1_20_6) {
311- javaVersions. add(JavaVersion . VERSION_17 )
312- } else {
313- javaVersions. add(JavaVersion . VERSION_21 )
314- }
298+ javaVersions. add(JavaVersion . VERSION_1_8 )
315299 minecraftVersions. add(mcVersion. toString())
316300
317301 clientRequired = true
0 commit comments