From 10d3923bf558c902199d9cbb4f34f3cc6376d9f2 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sat, 18 Jan 2025 15:00:33 -0600 Subject: [PATCH] Tragedy of the commons - Publish common vanillin artifacts - Extend JarTaskSet publish to accept an action --- .../engine_room/gradle/jarset/JarTaskSet.kt | 26 +++++++------ common/build.gradle.kts | 37 ++++++++++++++++++- fabric/build.gradle.kts | 8 +++- forge/build.gradle.kts | 8 +++- vanillinFabric/build.gradle.kts | 4 +- vanillinForge/build.gradle.kts | 9 ++--- 6 files changed, 67 insertions(+), 25 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt index 69cf75170..c2a079da1 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt @@ -4,6 +4,7 @@ import net.fabricmc.loom.task.AbstractRemapJarTask import net.fabricmc.loom.task.RemapJarTask import net.fabricmc.loom.task.RemapSourcesJarTask import org.gradle.api.Action +import org.gradle.api.NamedDomainObjectProvider import org.gradle.api.Project import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.publish.PublishingExtension @@ -30,22 +31,23 @@ class JarTaskSet( val remapSources: TaskProvider ) { - fun publishWithRawSources(artifactId: String) { - publish(artifactId, sources) + fun publishWithRawSources(action: Action): NamedDomainObjectProvider { + return publish(sources, action) } - fun publishWithRemappedSources(artifactId: String) { - publish(artifactId, remapSources) + fun publishWithRemappedSources(action: Action): NamedDomainObjectProvider { + return publish(remapSources, action) } - private fun publish(artifactId: String, sourceJar: TaskProvider) { - project.the().publications { - register("${name}RemapMaven") { - artifact(remapJar) - artifact(sourceJar) - artifact(javadocJar) - this.artifactId = artifactId - } + private fun publish( + sourceJar: TaskProvider, + action: Action + ): NamedDomainObjectProvider { + return project.the().publications.register("${name}RemapMaven") { + artifact(remapJar) + artifact(sourceJar) + artifact(javadocJar) + action.execute(this) } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index f90803543..e0baa3e4c 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -58,7 +58,9 @@ jarSets { // For publishing. create("api", api, lib).apply { addToAssemble() - publishWithRemappedSources("flywheel-common-intermediary-api-${property("artifact_minecraft_version")}") + publishWithRemappedSources { + artifactId = "flywheel-common-intermediary-api-${property("artifact_minecraft_version")}" + } configureJar { manifest { @@ -75,7 +77,38 @@ jarSets { targetNamespace = "named" } - publishWithRawSources("flywheel-common-mojmap-api-${property("artifact_minecraft_version")}") + publishWithRawSources { + artifactId = "flywheel-common-mojmap-api-${property("artifact_minecraft_version")}" + } + } + } + + create("vanillin", vanillin).apply { + addToAssemble() + publishWithRemappedSources { + artifactId = "vanillin-common-intermediary-${property("artifact_minecraft_version")}" + groupId = property("vanillin_group") as String + } + + configureJar { + manifest { + attributes("Fabric-Loom-Remap" to "true") + } + } + + // Don't publish the un-remapped jars because they don't have the correct manifest populated by Loom. + forkRemap("vanillinMojmap").apply { + addToAssemble() + configureRemap { + // "named" == mojmap + // We're probably remapping from named to named so Loom should noop this. + targetNamespace = "named" + } + + publishWithRawSources { + artifactId = "vanillin-common-mojmap-${property("artifact_minecraft_version")}" + groupId = property("vanillin_group") as String + } } } } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 20fd36821..e3a02f98d 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -67,12 +67,16 @@ platform { } jarSets { - mainSet.publishWithRemappedSources("flywheel-fabric-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRemappedSources { + artifactId = "flywheel-fabric-${project.property("artifact_minecraft_version")}" + } mainSet.outgoing("flywheel") create("api", api, lib).apply { addToAssemble() - publishWithRemappedSources("flywheel-fabric-api-${project.property("artifact_minecraft_version")}") + publishWithRemappedSources { + artifactId = "flywheel-fabric-api-${project.property("artifact_minecraft_version")}" + } configureJar { manifest { diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index fe113bfa3..694d7fd08 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -65,12 +65,16 @@ platform { } jarSets { - mainSet.publishWithRawSources("flywheel-forge-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRawSources { + artifactId = "flywheel-forge-${project.property("artifact_minecraft_version")}" + } mainSet.outgoing("flywheel") create("api", api, lib).apply { addToAssemble() - publishWithRawSources("flywheel-forge-api-${project.property("artifact_minecraft_version")}") + publishWithRawSources { + artifactId = "flywheel-forge-api-${project.property("artifact_minecraft_version")}" + } configureJar { manifest { diff --git a/vanillinFabric/build.gradle.kts b/vanillinFabric/build.gradle.kts index 2e036033b..3b2c08647 100644 --- a/vanillinFabric/build.gradle.kts +++ b/vanillinFabric/build.gradle.kts @@ -27,7 +27,9 @@ transitiveSourceSets { } jarSets { - mainSet.publishWithRemappedSources("vanillin-fabric-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRemappedSources { + artifactId = "vanillin-fabric-${project.property("artifact_minecraft_version")}" + } } defaultPackageInfos { diff --git a/vanillinForge/build.gradle.kts b/vanillinForge/build.gradle.kts index 4941a5106..12df3ba6a 100644 --- a/vanillinForge/build.gradle.kts +++ b/vanillinForge/build.gradle.kts @@ -27,7 +27,9 @@ transitiveSourceSets { } jarSets { - mainSet.publishWithRawSources("vanillin-forge-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRawSources { + artifactId = "vanillin-forge-${project.property("artifact_minecraft_version")}" + } } defaultPackageInfos { @@ -40,11 +42,6 @@ loom { add(main, "vanillin.refmap.json") } - forge { -// mixinConfig("flywheel.backend.mixins.json") -// mixinConfig("flywheel.impl.mixins.json") - } - runs { configureEach { property("forge.logging.markers", "")