Skip to content

Commit

Permalink
Tragedy of the commons
Browse files Browse the repository at this point in the history
- Publish common vanillin artifacts
- Extend JarTaskSet publish to accept an action
  • Loading branch information
Jozufozu committed Jan 18, 2025
1 parent 99d976f commit 10d3923
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,22 +31,23 @@ class JarTaskSet(
val remapSources: TaskProvider<RemapSourcesJarTask>
) {

fun publishWithRawSources(artifactId: String) {
publish(artifactId, sources)
fun publishWithRawSources(action: Action<MavenPublication>): NamedDomainObjectProvider<MavenPublication> {
return publish(sources, action)
}

fun publishWithRemappedSources(artifactId: String) {
publish(artifactId, remapSources)
fun publishWithRemappedSources(action: Action<MavenPublication>): NamedDomainObjectProvider<MavenPublication> {
return publish(remapSources, action)
}

private fun publish(artifactId: String, sourceJar: TaskProvider<out Jar>) {
project.the<PublishingExtension>().publications {
register<MavenPublication>("${name}RemapMaven") {
artifact(remapJar)
artifact(sourceJar)
artifact(javadocJar)
this.artifactId = artifactId
}
private fun publish(
sourceJar: TaskProvider<out Jar>,
action: Action<MavenPublication>
): NamedDomainObjectProvider<MavenPublication> {
return project.the<PublishingExtension>().publications.register<MavenPublication>("${name}RemapMaven") {
artifact(remapJar)
artifact(sourceJar)
artifact(javadocJar)
action.execute(this)
}
}

Expand Down
37 changes: 35 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion vanillinFabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions vanillinForge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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", "")
Expand Down

0 comments on commit 10d3923

Please sign in to comment.