Tragedy of the commons

- Publish common vanillin artifacts
- Extend JarTaskSet publish to accept an action
This commit is contained in:
Jozufozu 2025-01-18 15:00:33 -06:00
parent 99d976fb59
commit 10d3923bf5
6 changed files with 67 additions and 25 deletions

View file

@ -4,6 +4,7 @@ import net.fabricmc.loom.task.AbstractRemapJarTask
import net.fabricmc.loom.task.RemapJarTask import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RemapSourcesJarTask import net.fabricmc.loom.task.RemapSourcesJarTask
import org.gradle.api.Action import org.gradle.api.Action
import org.gradle.api.NamedDomainObjectProvider
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.PublishingExtension
@ -30,22 +31,23 @@ class JarTaskSet(
val remapSources: TaskProvider<RemapSourcesJarTask> val remapSources: TaskProvider<RemapSourcesJarTask>
) { ) {
fun publishWithRawSources(artifactId: String) { fun publishWithRawSources(action: Action<MavenPublication>): NamedDomainObjectProvider<MavenPublication> {
publish(artifactId, sources) return publish(sources, action)
} }
fun publishWithRemappedSources(artifactId: String) { fun publishWithRemappedSources(action: Action<MavenPublication>): NamedDomainObjectProvider<MavenPublication> {
publish(artifactId, remapSources) return publish(remapSources, action)
} }
private fun publish(artifactId: String, sourceJar: TaskProvider<out Jar>) { private fun publish(
project.the<PublishingExtension>().publications { sourceJar: TaskProvider<out Jar>,
register<MavenPublication>("${name}RemapMaven") { action: Action<MavenPublication>
): NamedDomainObjectProvider<MavenPublication> {
return project.the<PublishingExtension>().publications.register<MavenPublication>("${name}RemapMaven") {
artifact(remapJar) artifact(remapJar)
artifact(sourceJar) artifact(sourceJar)
artifact(javadocJar) artifact(javadocJar)
this.artifactId = artifactId action.execute(this)
}
} }
} }

View file

@ -58,7 +58,9 @@ jarSets {
// For publishing. // For publishing.
create("api", api, lib).apply { create("api", api, lib).apply {
addToAssemble() addToAssemble()
publishWithRemappedSources("flywheel-common-intermediary-api-${property("artifact_minecraft_version")}") publishWithRemappedSources {
artifactId = "flywheel-common-intermediary-api-${property("artifact_minecraft_version")}"
}
configureJar { configureJar {
manifest { manifest {
@ -75,7 +77,38 @@ jarSets {
targetNamespace = "named" 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
}
} }
} }
} }

View file

@ -67,12 +67,16 @@ platform {
} }
jarSets { jarSets {
mainSet.publishWithRemappedSources("flywheel-fabric-${project.property("artifact_minecraft_version")}") mainSet.publishWithRemappedSources {
artifactId = "flywheel-fabric-${project.property("artifact_minecraft_version")}"
}
mainSet.outgoing("flywheel") mainSet.outgoing("flywheel")
create("api", api, lib).apply { create("api", api, lib).apply {
addToAssemble() addToAssemble()
publishWithRemappedSources("flywheel-fabric-api-${project.property("artifact_minecraft_version")}") publishWithRemappedSources {
artifactId = "flywheel-fabric-api-${project.property("artifact_minecraft_version")}"
}
configureJar { configureJar {
manifest { manifest {

View file

@ -65,12 +65,16 @@ platform {
} }
jarSets { jarSets {
mainSet.publishWithRawSources("flywheel-forge-${project.property("artifact_minecraft_version")}") mainSet.publishWithRawSources {
artifactId = "flywheel-forge-${project.property("artifact_minecraft_version")}"
}
mainSet.outgoing("flywheel") mainSet.outgoing("flywheel")
create("api", api, lib).apply { create("api", api, lib).apply {
addToAssemble() addToAssemble()
publishWithRawSources("flywheel-forge-api-${project.property("artifact_minecraft_version")}") publishWithRawSources {
artifactId = "flywheel-forge-api-${project.property("artifact_minecraft_version")}"
}
configureJar { configureJar {
manifest { manifest {

View file

@ -27,7 +27,9 @@ transitiveSourceSets {
} }
jarSets { jarSets {
mainSet.publishWithRemappedSources("vanillin-fabric-${project.property("artifact_minecraft_version")}") mainSet.publishWithRemappedSources {
artifactId = "vanillin-fabric-${project.property("artifact_minecraft_version")}"
}
} }
defaultPackageInfos { defaultPackageInfos {

View file

@ -27,7 +27,9 @@ transitiveSourceSets {
} }
jarSets { jarSets {
mainSet.publishWithRawSources("vanillin-forge-${project.property("artifact_minecraft_version")}") mainSet.publishWithRawSources {
artifactId = "vanillin-forge-${project.property("artifact_minecraft_version")}"
}
} }
defaultPackageInfos { defaultPackageInfos {
@ -40,11 +42,6 @@ loom {
add(main, "vanillin.refmap.json") add(main, "vanillin.refmap.json")
} }
forge {
// mixinConfig("flywheel.backend.mixins.json")
// mixinConfig("flywheel.impl.mixins.json")
}
runs { runs {
configureEach { configureEach {
property("forge.logging.markers", "") property("forge.logging.markers", "")