diff --git a/buildSrc/src/main/kotlin/config-kotlin.gradle.kts b/buildSrc/src/main/kotlin/config-kotlin.gradle.kts index 0484cbf18..d79cda011 100644 --- a/buildSrc/src/main/kotlin/config-kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/config-kotlin.gradle.kts @@ -30,7 +30,7 @@ kotlin { repositories { maven("https://repo.papermc.io/repository/maven-public/") { mavenContent { - includeGroup("codechicken") + includeGroup("io.codechicken") includeGroup("net.fabricmc") includeGroupAndSubgroups("io.papermc") } diff --git a/buildSrc/src/main/kotlin/config-publish.gradle.kts b/buildSrc/src/main/kotlin/config-publish.gradle.kts index c7af047cf..0502fa2e5 100644 --- a/buildSrc/src/main/kotlin/config-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/config-publish.gradle.kts @@ -67,8 +67,8 @@ val shadowJar by tasks.existing(ShadowJar::class) { val prefix = "paper.libs" listOf( - "codechicken.diffpatch", - /* -> */ "codechicken.repack", + "io.codechicken.diffpatch", + /* -> */ "io.codechicken.repack", "com.github.salomonbrys.kotson", "com.google.gson", "dev.denwav.hypo", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c9ee39934..f1161de03 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -32,7 +32,7 @@ hypo-mappings = { module = "dev.denwav.hypo:hypo-mappings", version.ref = "hypo" lorenzTiny = "net.fabricmc:lorenz-tiny:3.0.0" jbsdiff = "io.sigpipe:jbsdiff:1.0" -diffpatch = "io.codechicken:DiffPatch:1.5.0.30" +diffpatch = "io.codechicken:DiffPatch:2.1.0.42" serialize-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialize" } serialize-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialize" } diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/UpstreamConfigTasks.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/UpstreamConfigTasks.kt index ab22724d8..fb6a6f9a4 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/UpstreamConfigTasks.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/UpstreamConfigTasks.kt @@ -22,7 +22,7 @@ package io.papermc.paperweight.core.taskcontainers -import codechicken.diffpatch.util.PatchMode +import io.codechicken.diffpatch.util.PatchMode import io.papermc.paperweight.core.extension.UpstreamConfig import io.papermc.paperweight.core.tasks.FilterRepo import io.papermc.paperweight.core.tasks.RunNestedBuild diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupMinecraftSources.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupMinecraftSources.kt index 70110a9c3..1bddceee4 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupMinecraftSources.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupMinecraftSources.kt @@ -22,9 +22,10 @@ package io.papermc.paperweight.core.tasks -import codechicken.diffpatch.cli.PatchOperation -import codechicken.diffpatch.util.LoggingOutputStream -import codechicken.diffpatch.util.archiver.ArchiveFormat +import io.codechicken.diffpatch.cli.PatchOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.Output as DiffOutput +import io.codechicken.diffpatch.util.archiver.ArchiveFormat import io.papermc.paperweight.PaperweightException import io.papermc.paperweight.core.util.ApplySourceATs import io.papermc.paperweight.tasks.* @@ -153,12 +154,12 @@ abstract class SetupMinecraftSources : JavaLauncherZippedTask() { println("Applying mache patches...") val result = PatchOperation.builder() - .logTo(LoggingOutputStream(logger, LogLevel.LIFECYCLE)) - .basePath(outputPath.convertToPath()) - .outputPath(outputPath.convertToPath()) - .patchesPath(mache.singleFile.toPath(), ArchiveFormat.ZIP) + .logTo(logger::lifecycle) + .baseInput(DiffInput.MultiInput.folder(outputPath.convertToPath())) + .patchedOutput(DiffOutput.MultiOutput.folder(outputPath.convertToPath())) + .patchesInput(DiffInput.MultiInput.archive(ArchiveFormat.ZIP, mache.singleFile.toPath())) .patchesPrefix("patches") - .level(codechicken.diffpatch.util.LogLevel.INFO) + .level(io.codechicken.diffpatch.util.LogLevel.INFO) .ignorePrefix(".git") .build() .operate() @@ -168,10 +169,10 @@ abstract class SetupMinecraftSources : JavaLauncherZippedTask() { } if (result.exit != 0) { - throw Exception("Failed to apply ${result.summary.failedMatches} mache patches") + throw Exception("Failed to apply ${result.summary?.failedMatches} mache patches") } - logger.lifecycle("Applied ${result.summary.changedFiles} mache patches") + logger.lifecycle("Applied ${result.summary?.changedFiles} mache patches") } if (atFile.isPresent) { diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatches.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatches.kt index 43d953242..f78431a2b 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatches.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatches.kt @@ -22,14 +22,14 @@ package io.papermc.paperweight.core.tasks.patching -import codechicken.diffpatch.cli.PatchOperation -import codechicken.diffpatch.match.FuzzyLineMatcher -import codechicken.diffpatch.util.LoggingOutputStream -import codechicken.diffpatch.util.PatchMode +import io.codechicken.diffpatch.cli.PatchOperation +import io.codechicken.diffpatch.match.FuzzyLineMatcher +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.Output as DiffOutput +import io.codechicken.diffpatch.util.PatchMode import io.papermc.paperweight.PaperweightException import io.papermc.paperweight.tasks.* import io.papermc.paperweight.util.* -import java.io.PrintStream import java.nio.file.Path import java.time.Instant import kotlin.io.path.* @@ -210,21 +210,20 @@ abstract class ApplyFilePatches : BaseTask() { return patchFiles.size } - private fun applyWithDiffPatch(): Int { - val printStream = PrintStream(LoggingOutputStream(logger, LogLevel.LIFECYCLE)) + private fun applyWithDiffPatch(): Int? { val builder = PatchOperation.builder() - .logTo(printStream) - .basePath(output.path) - .patchesPath(patches.path) - .outputPath(output.path) - .level(if (verbose.get()) codechicken.diffpatch.util.LogLevel.ALL else codechicken.diffpatch.util.LogLevel.INFO) + .logTo(logger::lifecycle) + .baseInput(DiffInput.MultiInput.folder(output.path)) + .patchesInput(DiffInput.MultiInput.folder(patches.path)) + .patchedOutput(DiffOutput.MultiOutput.folder(output.path)) + .level(if (verbose.get()) io.codechicken.diffpatch.util.LogLevel.ALL else io.codechicken.diffpatch.util.LogLevel.INFO) .mode(mode()) .minFuzz(minFuzz()) .summary(verbose.get()) .lineEnding("\n") .ignorePrefix(".git") if (rejectsDir.isPresent && emitRejects.get()) { - builder.rejectsPath(rejectsDir.path) + builder.rejectsOutput(DiffOutput.MultiOutput.folder(rejectsDir.path)) } val result = builder.build().operate() @@ -232,12 +231,12 @@ abstract class ApplyFilePatches : BaseTask() { commit() if (result.exit != 0) { - val total = result.summary.failedMatches + result.summary.exactMatches + - result.summary.accessMatches + result.summary.offsetMatches + result.summary.fuzzyMatches - throw Exception("Failed to apply ${result.summary.failedMatches}/$total hunks") + val total = (result.summary?.failedMatches ?: 0) + (result.summary?.exactMatches ?: 0) + + (result.summary?.accessMatches ?: 0) + (result.summary?.offsetMatches ?: 0) + (result.summary?.fuzzyMatches ?: 0) + throw Exception("Failed to apply ${result.summary?.failedMatches}/$total hunks") } - return result.summary.changedFiles + return result.summary?.changedFiles } private fun setupGitHook(outputPath: Path) { diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatchesFuzzy.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatchesFuzzy.kt index 091d8b7fe..df34318b9 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatchesFuzzy.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatchesFuzzy.kt @@ -22,7 +22,7 @@ package io.papermc.paperweight.core.tasks.patching -import codechicken.diffpatch.util.PatchMode +import io.codechicken.diffpatch.util.PatchMode import io.papermc.paperweight.core.util.defaultMinFuzz import javax.inject.Inject import org.gradle.api.provider.Property diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplySingleFilePatches.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplySingleFilePatches.kt index b54c03d68..79e832179 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplySingleFilePatches.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplySingleFilePatches.kt @@ -22,9 +22,11 @@ package io.papermc.paperweight.core.tasks.patching -import codechicken.diffpatch.cli.PatchOperation -import codechicken.diffpatch.util.LogLevel -import codechicken.diffpatch.util.PatchMode +import io.codechicken.diffpatch.cli.PatchOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.util.Output as DiffOutput +import io.codechicken.diffpatch.util.PatchMode import io.papermc.paperweight.PaperweightException import io.papermc.paperweight.core.util.defaultMinFuzz import io.papermc.paperweight.tasks.* @@ -129,10 +131,10 @@ abstract class ApplySingleFilePatches : BaseTask() { .mode(mode.get()) .minFuzz(minFuzz.get().toFloat()) .summary(false) - .basePath(tmpWork) - .patchesPath(tmpPatch) - .outputPath(tmpWork) - .rejectsPath(tmpRej) + .baseInput(DiffInput.MultiInput.folder(tmpWork)) + .patchesInput(DiffInput.MultiInput.folder(tmpPatch)) + .patchedOutput(DiffOutput.MultiOutput.folder(tmpWork)) + .rejectsOutput(DiffOutput.MultiOutput.folder(tmpRej)) .build() op.operate() diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildFilePatches.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildFilePatches.kt index 68c016b1d..ca4bdbe12 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildFilePatches.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildFilePatches.kt @@ -22,14 +22,14 @@ package io.papermc.paperweight.core.tasks.patching -import codechicken.diffpatch.cli.DiffOperation -import codechicken.diffpatch.util.LogLevel -import codechicken.diffpatch.util.LoggingOutputStream +import io.codechicken.diffpatch.cli.DiffOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.util.Output as DiffOutput import io.papermc.paperweight.PaperweightException import io.papermc.paperweight.core.util.ApplySourceATs import io.papermc.paperweight.tasks.* import io.papermc.paperweight.util.* -import java.io.PrintStream import java.nio.file.Path import kotlin.io.path.* import org.cadixdev.at.AccessTransformSet @@ -182,13 +182,12 @@ abstract class RebuildFilePatches : JavaLauncherTask() { baseDir: Path, inputDir: Path, patchDir: Path - ): Int { - val printStream = PrintStream(LoggingOutputStream(logger, org.gradle.api.logging.LogLevel.LIFECYCLE)) + ): Int? { val result = DiffOperation.builder() - .logTo(printStream) - .aPath(baseDir) - .bPath(inputDir) - .outputPath(patchDir) + .logTo(logger::lifecycle) + .baseInput(DiffInput.MultiInput.folder(baseDir)) + .changedInput(DiffInput.MultiInput.folder(inputDir)) + .patchesOutput(DiffOutput.MultiOutput.folder(patchDir)) .autoHeader(true) .level(if (verbose.get()) LogLevel.ALL else LogLevel.INFO) .lineEnding("\n") @@ -200,7 +199,7 @@ abstract class RebuildFilePatches : JavaLauncherTask() { .summary(verbose.get()) .build() .operate() - return result.summary.changedFiles + return result.summary?.changedFiles } private fun handleAts( diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildSingleFilePatches.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildSingleFilePatches.kt index 45cd14d5b..73b579b20 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildSingleFilePatches.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/RebuildSingleFilePatches.kt @@ -22,8 +22,10 @@ package io.papermc.paperweight.core.tasks.patching -import codechicken.diffpatch.cli.DiffOperation -import codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.cli.DiffOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.util.Output as DiffOutput import io.papermc.paperweight.tasks.* import io.papermc.paperweight.util.* import java.io.PrintStream @@ -80,9 +82,9 @@ abstract class RebuildSingleFilePatches : BaseTask() { val result = DiffOperation.builder() .logTo(logOut) - .aPath(tmpA) - .bPath(tmpB) - .outputPath(tmpPatch) + .baseInput(DiffInput.MultiInput.folder(tmpA)) + .changedInput(DiffInput.MultiInput.folder(tmpB)) + .patchesOutput(DiffOutput.MultiOutput.folder(tmpPatch)) .autoHeader(true) .level(LogLevel.ALL) .lineEnding("\n") diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt index 37266e025..897a993ca 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/GenerateDevBundle.kt @@ -22,8 +22,10 @@ package io.papermc.paperweight.tasks -import codechicken.diffpatch.cli.DiffOperation -import codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.cli.DiffOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.util.Output as DiffOutput import io.papermc.paperweight.util.* import io.papermc.paperweight.util.constants.* import java.io.PrintStream @@ -168,9 +170,9 @@ abstract class GenerateDevBundle : BaseTask() { PrintStream(logFile.toFile(), Charsets.UTF_8).use { logOut -> DiffOperation.builder() .logTo(logOut) - .aPath(a) - .bPath(b) - .outputPath(patchOut, null) + .baseInput(DiffInput.MultiInput.folder(a)) + .changedInput(DiffInput.MultiInput.folder(b)) + .patchesOutput(DiffOutput.MultiOutput.folder(patchOut)) .autoHeader(true) .level(LogLevel.ALL) .lineEnding("\n") diff --git a/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/ApplyDevBundlePatchesAction.kt b/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/ApplyDevBundlePatchesAction.kt index ee72c6b61..7c20d009a 100644 --- a/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/ApplyDevBundlePatchesAction.kt +++ b/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/ApplyDevBundlePatchesAction.kt @@ -22,9 +22,11 @@ package io.papermc.paperweight.userdev.internal.setup.action -import codechicken.diffpatch.cli.PatchOperation -import codechicken.diffpatch.util.LogLevel -import codechicken.diffpatch.util.archiver.ArchiveFormat +import io.codechicken.diffpatch.cli.PatchOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.util.Output as DiffOutput +import io.codechicken.diffpatch.util.archiver.ArchiveFormat import io.papermc.paperweight.PaperweightException import io.papermc.paperweight.userdev.internal.action.FileValue import io.papermc.paperweight.userdev.internal.action.Input @@ -68,9 +70,9 @@ class ApplyDevBundlePatchesAction( .logTo(logOut) .level(LogLevel.ALL) .summary(true) - .basePath(decompiledJar.get(), ArchiveFormat.ZIP) - .patchesPath(tempPatchDir) - .outputPath(outputDir) + .baseInput(DiffInput.MultiInput.archive(ArchiveFormat.ZIP, decompiledJar.get())) + .patchesInput(DiffInput.MultiInput.folder(tempPatchDir)) + .patchedOutput(DiffOutput.MultiOutput.folder(outputDir)) .build() try { op.operate().throwOnError() diff --git a/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/SetupMacheSourcesAction.kt b/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/SetupMacheSourcesAction.kt index 018029e77..c9e98d33b 100644 --- a/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/SetupMacheSourcesAction.kt +++ b/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/setup/action/SetupMacheSourcesAction.kt @@ -22,9 +22,11 @@ package io.papermc.paperweight.userdev.internal.setup.action -import codechicken.diffpatch.cli.PatchOperation -import codechicken.diffpatch.util.LogLevel -import codechicken.diffpatch.util.archiver.ArchiveFormat +import io.codechicken.diffpatch.cli.PatchOperation +import io.codechicken.diffpatch.util.Input as DiffInput +import io.codechicken.diffpatch.util.LogLevel +import io.codechicken.diffpatch.util.Output as DiffOutput +import io.codechicken.diffpatch.util.archiver.ArchiveFormat import io.papermc.paperweight.PaperweightException import io.papermc.paperweight.tasks.mache.macheDecompileJar import io.papermc.paperweight.userdev.internal.action.DirectoryValue @@ -72,9 +74,9 @@ class SetupMacheSourcesAction( val result = PrintStream(log.toFile(), Charsets.UTF_8).use { logOut -> PatchOperation.builder() .logTo(logOut) - .basePath(tempOut, ArchiveFormat.ZIP) - .outputPath(outputJar.get(), ArchiveFormat.ZIP) - .patchesPath(mache.get().singleFile.toPath(), ArchiveFormat.ZIP) + .baseInput(DiffInput.MultiInput.archive(ArchiveFormat.ZIP, tempOut)) + .patchedOutput(DiffOutput.MultiOutput.archive(ArchiveFormat.ZIP, outputJar.get())) + .patchesInput(DiffInput.MultiInput.archive(ArchiveFormat.ZIP, mache.get().singleFile.toPath())) .patchesPrefix("patches") .level(LogLevel.ALL) .summary(true)