From b3467d9f8d93aa2a4050359dfc3f8947fb9e9191 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:06:35 -0700 Subject: [PATCH 1/8] Guard against invalid remapJar configs (#256) Proactively throw an error when input and output paths match instead of letting tiny-remapper fail. --- .../main/kotlin/io/papermc/paperweight/tasks/RemapJar.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RemapJar.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RemapJar.kt index 033bbd50..4077c1db 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RemapJar.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RemapJar.kt @@ -76,6 +76,13 @@ abstract class RemapJar : JavaLauncherTask() { @TaskAction fun run() { + if (inputJar.path.absolute().normalize() == outputJar.path.absolute().normalize()) { + throw PaperweightException( + "Invalid configuration, inputJar and outputJar point to the same path: ${inputJar.path}\n" + + "Consider removing customization of output locations, following the default Gradle conventions." + ) + } + if (toNamespace.get() != fromNamespace.get()) { val logFile = layout.cache.resolve(paperTaskOutput("log")) TinyRemapper.run( From 4b9a233416ea0502ed6d0c41b740e96e6a5ec7d7 Mon Sep 17 00:00:00 2001 From: okx-code Date: Sat, 28 Sep 2024 03:22:32 +0100 Subject: [PATCH 2/8] Specify myers diff algorithm explicitly (#252) * Use myers diff algorithm This is the default Git diff algorithm and by specifying this explicitly we prevent git configs from overriding this setting. As Paper relies on patches generated with Myers, and breaks with other algorithms, it doesn't make sense to allow users to configure this. * Add diff algorithm in generatePatches * Also add to isUnfinishedPatch --- .../kotlin/io/papermc/paperweight/tasks/RebuildGitPatches.kt | 4 ++-- .../io/papermc/paperweight/tasks/patchremap/PatchApplier.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RebuildGitPatches.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RebuildGitPatches.kt index e09fb89c..c62c8c76 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RebuildGitPatches.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/RebuildGitPatches.kt @@ -97,7 +97,7 @@ abstract class RebuildGitPatches : ControllableOutputTask() { git("fetch", "--all", "--prune").runSilently(silenceErr = true) git( "format-patch", - "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N", + "--diff-algorithm=myers", "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N", "-o", patchFolder.absolutePathString(), baseRef.get() ).executeSilently() @@ -131,7 +131,7 @@ abstract class RebuildGitPatches : ControllableOutputTask() { try { for (patch in patchFiles) { futures += executor.submit { - val hasNoChanges = git("diff", "--staged", patch.name).getText().lineSequence() + val hasNoChanges = git("diff", "--diff-algorithm=myers", "--staged", patch.name).getText().lineSequence() .filter { it.startsWith('+') || it.startsWith('-') } .filterNot { it.startsWith("+++") || it.startsWith("---") } .all { it.startsWith("+index") || it.startsWith("-index") } diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/patchremap/PatchApplier.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/patchremap/PatchApplier.kt index 7b4ec9aa..8944f3f1 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/patchremap/PatchApplier.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/patchremap/PatchApplier.kt @@ -103,7 +103,7 @@ class PatchApplier( target.createDirectories() git("checkout", remappedBranch).executeSilently() git( - "format-patch", "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N", "-o", + "format-patch", "--diff-algorith=myers", "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N", "-o", target.absolutePathString(), remappedBaseTag ).executeOut() } @@ -114,7 +114,7 @@ class PatchApplier( } git("update-index", "--refresh").executeSilently() - if (git("diff-index", "--quiet", "HEAD", "--").runSilently() == 0) { + if (git("diff-index", "--diff-algorithm=myers", "--quiet", "HEAD", "--").runSilently() == 0) { return git("log", unmappedBranch, "-1", "--pretty=%B").getText().trim() != git("log", remappedBranch, "-1", "--pretty=%B").getText().trim() } From 4e08a00d652dd7626eabaa9482847121030d44f8 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:27:08 -0700 Subject: [PATCH 3/8] release: Version 1.7.3 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 72892d33..14f27a2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = io.papermc.paperweight -version = 1.7.3-SNAPSHOT +version = 1.7.3 org.gradle.caching = true org.gradle.parallel = true From 91fac7484b14d3c37167e8eb69d1cbbde2492369 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:29:41 -0700 Subject: [PATCH 4/8] 1.7.4-SNAPSHOT --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 14f27a2a..23ff1289 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = io.papermc.paperweight -version = 1.7.3 +version = 1.7.4-SNAPSHOT org.gradle.caching = true org.gradle.parallel = true From addb21de1bc1190c581126a5fe08e6171843a851 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:29:31 -0700 Subject: [PATCH 5/8] Add mainCapabilityAttribute to disambiguate project dependencies with multiple capabilities when bundling library jars (#257) --- .../io/papermc/paperweight/tasks/CreateBundlerJar.kt | 11 ++++++++--- .../main/kotlin/io/papermc/paperweight/util/utils.kt | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/CreateBundlerJar.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/CreateBundlerJar.kt index fcef177a..5dd61e21 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/CreateBundlerJar.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/CreateBundlerJar.kt @@ -200,9 +200,14 @@ abstract class CreateBundlerJar : ZippedTask() { return when (val ident = id.componentIdentifier) { is ModuleComponentIdentifier -> ModuleId.fromIdentifier(id) is ProjectComponentIdentifier -> { - val capability = variant.capabilities.first() - val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}") - ModuleId(capability.group, capability.name, version) + val mainCap = variant.attributes.getAttribute(mainCapabilityAttribute) + if (mainCap != null) { + ModuleId.parse(mainCap) + } else { + val capability = variant.capabilities.first() + val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}") + ModuleId(capability.group, capability.name, version) + } } else -> throw PaperweightException("Unknown artifact result type: ${ident::class.java.name}") } diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/util/utils.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/util/utils.kt index 961f1ddb..fa62d067 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/util/utils.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/util/utils.kt @@ -53,6 +53,7 @@ import kotlin.io.path.* import org.cadixdev.lorenz.merge.MergeResult import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.attributes.Attribute import org.gradle.api.file.FileCollection import org.gradle.api.file.FileSystemLocation import org.gradle.api.file.ProjectLayout @@ -416,3 +417,5 @@ fun modifyManifest(path: Path, create: Boolean = true, op: Manifest.() -> Unit) path.outputStream().buffered().use { mf.write(it) } } } + +val mainCapabilityAttribute: Attribute = Attribute.of("io.papermc.paperweight.main-capability", String::class.java) From 5f8df323838f8a6e06dd7c8a49dd63feea7e1215 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 25 Oct 2024 21:34:07 +0200 Subject: [PATCH 6/8] Always make mc-dev-sources when applying patches (#259) Always create the mc dev sources folder in the server project while applying patches, even if said patching failed. This change allows full sources in IDE during version updates without having to reload the project and rely on dependency resolution to populate the dev sources folder. --- .../io/papermc/paperweight/tasks/ApplyPaperPatches.kt | 8 +++++--- .../paperweight/patcher/tasks/PatcherApplyGitPatches.kt | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/ApplyPaperPatches.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/ApplyPaperPatches.kt index c45df651..36b4ab09 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/ApplyPaperPatches.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/ApplyPaperPatches.kt @@ -165,9 +165,11 @@ abstract class ApplyPaperPatches : ControllableOutputTask() { git("tag", "-d", "base").runSilently(silenceErr = true) git("tag", "base").executeSilently() - applyGitPatches(git, target, outputFile, patchDir.path, printOutput.get(), verbose.get()) - - makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, sourceDir, mcDataDir) + try { + applyGitPatches(git, target, outputFile, patchDir.path, printOutput.get(), verbose.get()) + } finally { + makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, sourceDir, mcDataDir) + } } } diff --git a/paperweight-patcher/src/main/kotlin/io/papermc/paperweight/patcher/tasks/PatcherApplyGitPatches.kt b/paperweight-patcher/src/main/kotlin/io/papermc/paperweight/patcher/tasks/PatcherApplyGitPatches.kt index 3107d846..c69b8033 100644 --- a/paperweight-patcher/src/main/kotlin/io/papermc/paperweight/patcher/tasks/PatcherApplyGitPatches.kt +++ b/paperweight-patcher/src/main/kotlin/io/papermc/paperweight/patcher/tasks/PatcherApplyGitPatches.kt @@ -161,8 +161,10 @@ abstract class PatcherApplyGitPatches : ControllableOutputTask() { git("tag", "-d", "base").runSilently(silenceErr = true) git("tag", "base").executeSilently() - applyGitPatches(git, target, output, patchDir.pathOrNull, printOutput.get(), verbose.get()) - - makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, srcDir, dataDir) + try { + applyGitPatches(git, target, output, patchDir.pathOrNull, printOutput.get(), verbose.get()) + } finally { + makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, srcDir, dataDir) + } } } From 5bcee63ede9f16475e61d49ec9bad74884c2e2b9 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:37:41 -0700 Subject: [PATCH 7/8] release: Version 1.7.4 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 23ff1289..70e8faa1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = io.papermc.paperweight -version = 1.7.4-SNAPSHOT +version = 1.7.4 org.gradle.caching = true org.gradle.parallel = true From 6408556fc236172df5e29859f04b221f1e0b3663 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:38:28 -0700 Subject: [PATCH 8/8] 1.7.5-SNAPSHOT --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 70e8faa1..c8006928 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = io.papermc.paperweight -version = 1.7.4 +version = 1.7.5-SNAPSHOT org.gradle.caching = true org.gradle.parallel = true