Skip to content

Commit

Permalink
Update DiffPatch 2.0! (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
covers1624 authored Jun 24, 2024
1 parent 41bf68d commit 5565e87
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()
);
}
Expand Down

0 comments on commit 5565e87

Please sign in to comment.