diff --git a/common/build.gradle b/common/build.gradle index 2e58fc876..ce57913cf 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -18,7 +18,7 @@ dependencies { api "org.apache.ivy:ivy:${project.ivy_artifact_version}" api "org.apache.httpcomponents:httpclient:${project.httpclient_version}" api "net.minecraftforge:srgutils:${project.srgutils_version}" - api "codechicken:DiffPatch:${project.diffpatch_version}" + api "io.codechicken:DiffPatch:${project.diffpatch_version}" api "commons-codec:commons-codec:${project.commons_codec_version}" api "net.neoforged:EclipseLaunchConfigs:${project.eclipse_launch_configs_version}" api "net.neoforged:JarJarMetadata:${project.jarjar_version}" diff --git a/gradle.properties b/gradle.properties index e6dcbc3f9..e912f02bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ maven_artifact_version=3.8.5 ivy_artifact_version=2.5.1 httpclient_version=4.5.13 srgutils_version=0.4.13 -diffpatch_version=1.5.0.29 +diffpatch_version=2.0.0.34 jarjar_version=0.4.1 jetbrains_annotations_version=23.0.0 gradle_idea_extension_version=1.1.6 diff --git a/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/Patch.java b/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/Patch.java index 5598e4e8b..6334edd10 100644 --- a/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/Patch.java +++ b/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/Patch.java @@ -1,9 +1,10 @@ package net.neoforged.gradle.neoform.runtime.tasks; -import codechicken.diffpatch.cli.CliOperation; -import codechicken.diffpatch.cli.PatchOperation; -import codechicken.diffpatch.util.LoggingOutputStream; -import codechicken.diffpatch.util.PatchMode; +import io.codechicken.diffpatch.cli.CliOperation; +import io.codechicken.diffpatch.cli.PatchOperation; +import io.codechicken.diffpatch.util.Input.MultiInput; +import io.codechicken.diffpatch.util.Output.MultiOutput; +import io.codechicken.diffpatch.util.PatchMode; import net.neoforged.gradle.common.CommonProjectPlugin; import net.neoforged.gradle.common.caching.CentralCacheService; import net.neoforged.gradle.common.runtime.tasks.DefaultRuntime; @@ -61,13 +62,13 @@ public File doRun() throws Exception { } PatchOperation.Builder builder = PatchOperation.builder() - .logTo(new LoggingOutputStream(getLogger(), LogLevel.LIFECYCLE)) - .basePath(input.toPath()) - .patchesPath(patchArchiveLocator.directory.toPath()) - .outputPath(output.toPath()) - .level(getIsVerbose().get() ? codechicken.diffpatch.util.LogLevel.ALL : codechicken.diffpatch.util.LogLevel.WARN) - .mode(PatchMode.OFFSET) - .rejectsPath(rejects.toPath()); + .logTo(getLogger()::lifecycle) + .baseInput(MultiInput.detectedArchive(input.toPath())) + .patchesInput(MultiInput.folder(patchArchiveLocator.directory.toPath())) + .patchedOutput(MultiOutput.detectedArchive(output.toPath())) + .rejectsOutput(MultiOutput.detectedArchive(rejects.toPath())) + .level(getIsVerbose().get() ? io.codechicken.diffpatch.util.LogLevel.ALL : io.codechicken.diffpatch.util.LogLevel.WARN) + .mode(PatchMode.OFFSET); if (getPatchesModifiedPrefix().isPresent()) { builder = builder.bPrefix(getPatchesModifiedPrefix().get()); diff --git a/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/extension/RuntimeDevRuntimeExtension.java b/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/extension/RuntimeDevRuntimeExtension.java index c8e81e54a..b36730686 100644 --- a/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/extension/RuntimeDevRuntimeExtension.java +++ b/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/extension/RuntimeDevRuntimeExtension.java @@ -1,6 +1,6 @@ package net.neoforged.gradle.platform.runtime.runtime.extension; -import codechicken.diffpatch.util.PatchMode; +import io.codechicken.diffpatch.util.PatchMode; import net.neoforged.gradle.common.runtime.extensions.CommonRuntimeExtension; import net.neoforged.gradle.dsl.common.extensions.Mappings; import net.neoforged.gradle.dsl.common.extensions.Minecraft; diff --git a/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/ApplyPatches.java b/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/ApplyPatches.java index 59c219b76..42c509c6d 100644 --- a/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/ApplyPatches.java +++ b/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/ApplyPatches.java @@ -5,11 +5,12 @@ package net.neoforged.gradle.platform.runtime.runtime.tasks; -import codechicken.diffpatch.cli.CliOperation; -import codechicken.diffpatch.cli.PatchOperation; -import codechicken.diffpatch.util.LoggingOutputStream; -import codechicken.diffpatch.util.PatchMode; -import codechicken.diffpatch.util.archiver.ArchiveFormat; +import io.codechicken.diffpatch.cli.CliOperation; +import io.codechicken.diffpatch.cli.PatchOperation; +import io.codechicken.diffpatch.util.Input.MultiInput; +import io.codechicken.diffpatch.util.Output.MultiOutput; +import io.codechicken.diffpatch.util.PatchMode; +import io.codechicken.diffpatch.util.archiver.ArchiveFormat; import net.neoforged.gradle.common.runtime.tasks.DefaultRuntime; import net.neoforged.gradle.dsl.common.tasks.WithOutput; import net.neoforged.gradle.dsl.common.tasks.WithWorkspace; @@ -49,15 +50,15 @@ public void doTask() throws Exception { Path rejectsPath = rejectsDir.getAsFile().toPath(); PatchOperation.Builder builder = PatchOperation.builder() - .logTo(new LoggingOutputStream(getLogger(), LogLevel.LIFECYCLE)) - .basePath(getBase().get().getAsFile().toPath()) - .patchesPath(getPatches().get().getAsFile().toPath()) - .outputPath(outputPath, ArchiveFormat.findFormat(outputPath.getFileName())) - .rejectsPath(rejectsPath, ArchiveFormat.findFormat(rejectsPath.getFileName())) + .logTo(getLogger()::lifecycle) + .baseInput(MultiInput.detectedArchive(getBase().get().getAsFile().toPath())) + .patchesInput(MultiInput.folder(getPatches().get().getAsFile().toPath())) + .patchedOutput(MultiOutput.detectedArchive(outputPath)) + .rejectsOutput(MultiOutput.folder(rejectsPath)) .mode(getPatchMode().get()) .aPrefix(getOriginalPrefix().get()) .bPrefix(getModifiedPrefix().get()) - .level(getShouldFailOnPatchFailure().get() ? codechicken.diffpatch.util.LogLevel.WARN : codechicken.diffpatch.util.LogLevel.ALL) + .level(getShouldFailOnPatchFailure().get() ? io.codechicken.diffpatch.util.LogLevel.WARN : io.codechicken.diffpatch.util.LogLevel.ALL) .patchesPrefix(getPatchesPrefix().get()); builder.minFuzz(getMinimalFuzzingQuality().get()); diff --git a/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/GenerateSourcePatches.java b/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/GenerateSourcePatches.java index 33d0241de..419f3134d 100644 --- a/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/GenerateSourcePatches.java +++ b/platform/src/main/java/net/neoforged/gradle/platform/runtime/runtime/tasks/GenerateSourcePatches.java @@ -5,10 +5,10 @@ package net.neoforged.gradle.platform.runtime.runtime.tasks; -import codechicken.diffpatch.cli.CliOperation; -import codechicken.diffpatch.cli.DiffOperation; -import codechicken.diffpatch.util.LoggingOutputStream; -import codechicken.diffpatch.util.archiver.ArchiveFormat; +import io.codechicken.diffpatch.cli.CliOperation; +import io.codechicken.diffpatch.cli.DiffOperation; +import io.codechicken.diffpatch.util.Input.MultiInput; +import io.codechicken.diffpatch.util.Output.MultiOutput; import net.neoforged.gradle.common.runtime.tasks.DefaultRuntime; import net.neoforged.gradle.dsl.common.tasks.WithOutput; import net.neoforged.gradle.dsl.common.tasks.WithWorkspace; @@ -40,12 +40,12 @@ public void doTask() throws Exception { getProject().getLogger().info("Modified: {}", modified); DiffOperation.Builder builder = DiffOperation.builder() - .logTo(new LoggingOutputStream(getLogger(), LogLevel.LIFECYCLE)) - .aPath(base) - .bPath(modified) - .outputPath(output, ArchiveFormat.findFormat(output.getFileName())) + .logTo(getLogger()::lifecycle) + .baseInput(MultiInput.detectedArchive(base)) + .changedInput(MultiInput.detectedArchive(modified)) + .patchesOutput(MultiOutput.detectedArchive(output)) .autoHeader(getShouldCreateAutomaticHeader().get()) - .level(getShouldOutputVerboseLogging().get() ? codechicken.diffpatch.util.LogLevel.ALL : codechicken.diffpatch.util.LogLevel.WARN) + .level(getShouldOutputVerboseLogging().get() ? io.codechicken.diffpatch.util.LogLevel.ALL : io.codechicken.diffpatch.util.LogLevel.WARN) .summary(getShouldPrintSummary().get()) .aPrefix(getOriginalPrefix().get()) .bPrefix(getModifiedPrefix().get()) diff --git a/platform/src/main/java/net/neoforged/gradle/platform/tasks/BakePatches.java b/platform/src/main/java/net/neoforged/gradle/platform/tasks/BakePatches.java index 75f9383ba..d39233253 100644 --- a/platform/src/main/java/net/neoforged/gradle/platform/tasks/BakePatches.java +++ b/platform/src/main/java/net/neoforged/gradle/platform/tasks/BakePatches.java @@ -1,9 +1,8 @@ package net.neoforged.gradle.platform.tasks; -import codechicken.diffpatch.cli.PatchOperation; -import codechicken.diffpatch.util.InputPath; -import codechicken.diffpatch.util.OutputPath; -import codechicken.diffpatch.util.archiver.ArchiveFormat; +import io.codechicken.diffpatch.cli.PatchOperation; +import io.codechicken.diffpatch.util.Input.MultiInput; +import io.codechicken.diffpatch.util.Output.MultiOutput; import net.neoforged.gradle.common.runtime.tasks.DefaultRuntime; import net.neoforged.gradle.dsl.common.tasks.WithOutput; import net.neoforged.gradle.dsl.common.tasks.WithWorkspace; @@ -25,12 +24,9 @@ public void doTask() throws Exception { final File input = getInput().get().getAsFile(); final File output = ensureFileWorkspaceReady(getOutput()); - final ArchiveFormat inputFormat = ArchiveFormat.findFormat(input.toPath()); - final ArchiveFormat outputFormat = ArchiveFormat.findFormat(output.toPath()); - PatchOperation.bakePatches( - new InputPath.FilePath(input.toPath(), inputFormat), - new OutputPath.FilePath(output.toPath(), outputFormat), + MultiInput.detectedArchive(input.toPath()), + MultiOutput.detectedArchive(output.toPath()), getLineEndings().get() ); }