Skip to content

Commit

Permalink
Merge branch 'version/7.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jan 24, 2024
2 parents b5c5890 + d533be4 commit 062653e
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ val totalReport = tasks.register<JacocoReport>("jacocoTotalReport") {
proj.apply(plugin = "jacoco")
proj.plugins.withId("java") {
executionData(
fileTree(proj.buildDir.absolutePath).include("**/jacoco/*.exec")
fileTree(proj.layout.buildDirectory).include("**/jacoco/*.exec")
)
sourceSets(proj.the<JavaPluginExtension>().sourceSets["main"])
reports {
xml.required.set(true)
xml.outputLocation.set(rootProject.buildDir.resolve("reports/jacoco/report.xml"))
xml.outputLocation.set(rootProject.layout.buildDirectory.file("reports/jacoco/report.xml"))
html.required.set(true)
}
dependsOn(proj.tasks.named("test"))
Expand Down
9 changes: 4 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import java.util.Properties

plugins {
`kotlin-dsl`
kotlin("jvm") version embeddedKotlinVersion
}

repositories {
Expand Down Expand Up @@ -47,16 +46,16 @@ val mixinVersion: String = properties.getProperty("mixin.version")
dependencies {
implementation(gradleApi())
implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
implementation("org.ajoberstar.grgit:grgit-gradle:4.1.1")
implementation("org.ajoberstar.grgit:grgit-gradle:5.2.1")
implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.0")
implementation("com.github.johnrengelman:shadow:8.1.1")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.32.0")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.1.14")
implementation("org.spongepowered:spongegradle-plugin-development:2.2.0")
implementation("org.spongepowered:vanillagradle:0.2.1-20231105.223944-69")
implementation("net.minecraftforge.gradle:ForgeGradle:6.0.16")
implementation("net.minecraftforge.gradle:ForgeGradle:6.0.20")
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.2.0")
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.9")
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.11")
implementation("org.spongepowered:mixingradle:0.7.38")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version=7.3.0-SNAPSHOT
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

loom.version=1.4.4
loom.version=1.5.6
mixin.version=0.12.5+mixin.0.8.5
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

rootProject.name = "worldedit"

include("worldedit-libs")
Expand Down
2 changes: 1 addition & 1 deletion worldedit-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ tasks.named("sourcesJar") {

configure<LicenseExtension> {
exclude {
it.file.startsWith(project.buildDir)
it.file.startsWith(project.layout.buildDirectory.get().asFile)
}
}
tasks.withType<Checkstyle>().configureEach {
Expand Down
89 changes: 84 additions & 5 deletions worldedit-mod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,95 @@
import net.fabricmc.loom.task.RemapJarTask
import java.util.jar.Attributes
import java.util.jar.Manifest

plugins {
base
}

applyCommonConfiguration()

tasks.register<Jar>("jar") {
val remapFabric = project(":worldedit-fabric").tasks.named<RemapJarTask>("remapShadowJar")
open class MergeManifests : DefaultTask() {
@InputFiles
val inputManifests: ConfigurableFileCollection = project.objects.fileCollection()

@OutputFile
val outputManifest: RegularFileProperty = project.objects.fileProperty()

companion object {
private fun assertEqual(old: Any?, new: Any?, key: Attributes.Name): Any? {
assert(old == new) { "$key mismatch: $old != $new" }
return old
}

private fun throwException(old: Any?, new: Any?, key: Attributes.Name) {
throw IllegalStateException("Duplicate $key: $new")
}

private val MERGE_LOGIC = mapOf(
Attributes.Name.MANIFEST_VERSION to ::assertEqual,
Attributes.Name.IMPLEMENTATION_VERSION to ::assertEqual,
Attributes.Name.MAIN_CLASS to ::assertEqual,
Attributes.Name("WorldEdit-Version") to ::assertEqual,
Attributes.Name("WorldEdit-Kind") to ::assertEqual,
)
}

private fun mergeAttributes(aggregate: Attributes, input: Attributes) {
input.forEach { (key, value) ->
aggregate.merge(key, value) { old, new ->
val mergeLogic = MERGE_LOGIC[key] ?: ::throwException
mergeLogic(old, new, key as Attributes.Name)
}
}
}

@TaskAction
fun merge() {
val manifest = Manifest()
inputManifests.forEach { manifestFile ->
val inputManifest = manifestFile.inputStream().use { Manifest(it) }
mergeAttributes(manifest.mainAttributes, inputManifest.mainAttributes)
inputManifest.entries.forEach { (key, value) ->
val aggregate = manifest.entries.computeIfAbsent(key) { Attributes() }
mergeAttributes(aggregate, value)
}
}
outputManifest.asFile.get().outputStream().use {
manifest.write(it)
}
}
}

val fabricZipTree = zipTree(
project(":worldedit-fabric").tasks.named<RemapJarTask>("remapShadowJar").flatMap { it.archiveFile }
)
val forgeZipTree = zipTree(
project(":worldedit-forge").tasks.named("shadowJar").map { it.outputs.files.singleFile }
)

val mergeManifests = tasks.register<MergeManifests>("mergeManifests") {
dependsOn(
remapFabric,
project(":worldedit-fabric").tasks.named<RemapJarTask>("remapShadowJar"),
project(":worldedit-forge").tasks.named("reobfShadowJar")
)
from(zipTree({remapFabric.get().archiveFile}))
from(zipTree({project(":worldedit-forge").tasks.getByName("shadowJar").outputs.files.singleFile})) {
inputManifests.from(
fabricZipTree.matching { include("META-INF/MANIFEST.MF") },
forgeZipTree.matching { include("META-INF/MANIFEST.MF") }
)
outputManifest.set(project.layout.buildDirectory.file("mergeManifests/MANIFEST.MF"))
}

tasks.register<Jar>("jar") {
dependsOn(
project(":worldedit-fabric").tasks.named<RemapJarTask>("remapShadowJar"),
project(":worldedit-forge").tasks.named("reobfShadowJar"),
mergeManifests
)
from(fabricZipTree) {
exclude("META-INF/MANIFEST.MF")
}
from(forgeZipTree) {
exclude("META-INF/MANIFEST.MF")
// Duplicated first-party files
exclude("META-INF/services/org.enginehub.piston.CommandManagerService")
exclude("lang/")
Expand All @@ -36,6 +112,9 @@ tasks.register<Jar>("jar") {
exclude("defaults/worldedit.properties")
exclude("pack.mcmeta")
}
manifest {
from(mergeManifests.flatMap { it.outputManifest })
}

duplicatesStrategy = DuplicatesStrategy.FAIL
archiveClassifier.set("dist")
Expand Down

0 comments on commit 062653e

Please sign in to comment.