Skip to content

Commit 66c235b

Browse files
committed
Update userdev config
Strips empty lists except for extra dependencies (doesn't need to be stripped, as it is ignored otherwise)
1 parent 6a16f5c commit 66c235b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/main/groovy/net/minecraftforge/forgedev/ForgeDevExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ private void setup(ForgeDevPlugin plugin, Project project) {
429429
//UserDev Config Default Values
430430
userdevConfig.configure(task -> {
431431
task.getMCPConfig().set(legacyMcp.getConfig());
432-
task.getBinpatcherVersion().set(Constants.BINPATCH_VERSION);
432+
task.getBinpatcherVersion().set("net.minecraft:binarypatcher:" + Constants.BINPATCH_VERSION + ":fatjar");
433433
task.getBinpatcherArguments().addAll("--clean", "{clean}", "--output", "{output}", "--apply", "{patch}");
434434
task.getUniversal().convention(universalJar.flatMap(t ->
435435
t.getArchiveBaseName().flatMap(baseName ->

src/main/groovy/net/minecraftforge/forgedev/tasks/generation/GeneratePatcherConfigV2.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,21 @@ public abstract class GeneratePatcherConfigV2 extends DefaultTask implements For
6565
public abstract @Input Property<String> getBinpatcherVersion();
6666
public abstract @Input ListProperty<String> getBinpatcherArguments();
6767

68+
public abstract @Input @Optional ListProperty<String> getExtraRuntimeDeps();
69+
public abstract @Input @Optional ListProperty<String> getExtraCompileDeps();
70+
public abstract @Input @Optional ListProperty<String> getExtraAnnotationProcessorDeps();
71+
6872
protected abstract @Inject ObjectFactory getObjects();
6973

7074
@Inject
7175
public GeneratePatcherConfigV2() {
72-
this.getSourceFileEncoding().convention(StandardCharsets.UTF_8.name());
7376
this.getOutput().convention(this.getDefaultOutputFile("json"));
77+
78+
this.getPatchesOriginalPrefix().convention("a/");
79+
this.getPatchesModifiedPrefix().convention("b/");
80+
this.getSourceFileEncoding().convention(StandardCharsets.UTF_8.name());
81+
this.getInject().convention("inject/");
82+
this.getPatches().convention("patches/");
7483
}
7584

7685
@TaskAction
@@ -85,9 +94,12 @@ protected void exec() throws IOException {
8594
config.inject = this.getInject().filter(Util.IS_NOT_BLANK).getOrNull();
8695
config.libraries = this.getLibraries().get();
8796
config.ats = DefaultGroovyMethods.collect(this.getATs(), Closures.<File, String>function(f -> "ats/" + f.getName()));
97+
if (config.ats.isEmpty()) config.ats = null;
8898
config.sass = DefaultGroovyMethods.collect(this.getSASs(), Closures.<File, String>function(f -> "sas/" + f.getName()));
99+
if (config.sass.isEmpty()) config.sass = null;
89100
config.srgs = DefaultGroovyMethods.collect(this.getSRGs(), Closures.<File, String>function(f -> "srgs/" + f.getName()));
90101
config.srgs.addAll(this.getSRGLines().get());
102+
if (config.srgs.isEmpty()) config.srgs = null;
91103
config.mcp = this.getMCPConfig().filter(Util.IS_NOT_BLANK).get();
92104

93105
config.runs = this.getRuns().get();
@@ -100,12 +112,18 @@ protected void exec() throws IOException {
100112
var v2 = (PatcherConfig.V2) (config = new PatcherConfig.V2(config));
101113
v2.spec = 2;
102114
v2.modules = this.getModules().get();
115+
if (v2.modules.isEmpty()) v2.modules = null;
103116
v2.processor = this.getProcessor().getOrNull();
104117
v2.patchesOriginalPrefix = this.getPatchesOriginalPrefix().filter(Util.IS_NOT_BLANK).getOrNull();
105118
v2.patchesModifiedPrefix = this.getPatchesModifiedPrefix().filter(Util.IS_NOT_BLANK).getOrNull();
106119
v2.notchObf = this.getNotchObf().filter(b -> b).getOrNull();
107120
v2.sourceFileCharset = this.getSourceFileEncoding().filter(Util.IS_NOT_BLANK).getOrNull();
108121
v2.universalFilters = this.getUniversalFilters().get();
122+
if (v2.universalFilters.isEmpty()) v2.universalFilters = null;
123+
v2.extraDependencies = new PatcherConfig.V2.ScopedDependencies();
124+
v2.extraDependencies.compileOnly = new ArrayList<>(getExtraCompileDeps().get());
125+
v2.extraDependencies.runtimeOnly = new ArrayList<>(getExtraRuntimeDeps().get());
126+
v2.extraDependencies.annotationProcessor = new ArrayList<>(getExtraAnnotationProcessorDeps().get());
109127
}
110128

111129
JsonData.toJson(config, this.getOutput().getAsFile().get());

0 commit comments

Comments
 (0)