Skip to content

Commit f9a06cb

Browse files
authored
Make RemapSourcesJarTask use properties (FabricMC#459)
1 parent 2f4cf35 commit f9a06cb

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ private static void setupRemap(Project project, boolean isDefaultRemap, String j
139139

140140
RemapSourcesJarTask remapSourcesJarTask = (RemapSourcesJarTask) project.getTasks().findByName(remapSourcesJarTaskName);
141141
Preconditions.checkNotNull(remapSourcesJarTask, "Could not find " + remapSourcesJarTaskName + " in " + project.getName());
142-
remapSourcesJarTask.setInput(sourcesTask.getArchivePath());
143-
remapSourcesJarTask.setOutput(sourcesTask.getArchivePath());
142+
remapSourcesJarTask.getInput().set(sourcesTask.getArchiveFile());
143+
remapSourcesJarTask.getOutput().set(sourcesTask.getArchiveFile());
144144
remapSourcesJarTask.dependsOn(project.getTasks().getByName(sourcesJarTaskName));
145145

146146
if (isDefaultRemap) {

src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java

+18-37
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
package net.fabricmc.loom.task;
2626

27-
import java.io.File;
28-
27+
import org.gradle.api.file.RegularFileProperty;
28+
import org.gradle.api.provider.Property;
2929
import org.gradle.api.tasks.Input;
3030
import org.gradle.api.tasks.InputFile;
3131
import org.gradle.api.tasks.Internal;
@@ -35,22 +35,23 @@
3535
import net.fabricmc.loom.util.SourceRemapper;
3636

3737
public class RemapSourcesJarTask extends AbstractLoomTask {
38-
private Object input;
39-
private Object output;
40-
private String direction = "intermediary";
38+
private final RegularFileProperty input = getProject().getObjects().fileProperty();
39+
private final RegularFileProperty output = getProject().getObjects().fileProperty().convention(input);
40+
private final Property<String> targetNamespace = getProject().getObjects().property(String.class).convention("intermediary");
4141
private SourceRemapper sourceRemapper = null;
42-
private boolean preserveFileTimestamps = true;
43-
private boolean reproducibleFileOrder = false;
42+
private final Property<Boolean> preserveFileTimestamps = getProject().getObjects().property(Boolean.class).convention(true);
43+
private final Property<Boolean> reproducibleFileOrder = getProject().getObjects().property(Boolean.class).convention(false);
4444

4545
public RemapSourcesJarTask() {
4646
}
4747

4848
@TaskAction
4949
public void remap() throws Exception {
5050
if (sourceRemapper == null) {
51-
SourceRemapper.remapSources(getProject(), getInput(), getOutput(), direction.equals("named"), reproducibleFileOrder, preserveFileTimestamps);
51+
String direction = targetNamespace.get();
52+
SourceRemapper.remapSources(getProject(), input.get().getAsFile(), output.get().getAsFile(), direction.equals("named"), reproducibleFileOrder.get(), preserveFileTimestamps.get());
5253
} else {
53-
sourceRemapper.scheduleRemapSources(getInput(), getOutput(), reproducibleFileOrder, preserveFileTimestamps);
54+
sourceRemapper.scheduleRemapSources(input.get().getAsFile(), output.get().getAsFile(), reproducibleFileOrder.get(), preserveFileTimestamps.get());
5455
}
5556
}
5657

@@ -65,47 +66,27 @@ public RemapSourcesJarTask setSourceRemapper(SourceRemapper sourceRemapper) {
6566
}
6667

6768
@InputFile
68-
public File getInput() {
69-
return getProject().file(input);
69+
public RegularFileProperty getInput() {
70+
return input;
7071
}
7172

7273
@OutputFile
73-
public File getOutput() {
74-
return getProject().file(output == null ? input : output);
74+
public RegularFileProperty getOutput() {
75+
return output;
7576
}
7677

7778
@Input
78-
public String getTargetNamespace() {
79-
return direction;
80-
}
81-
82-
public void setInput(Object input) {
83-
this.input = input;
84-
}
85-
86-
public void setOutput(Object output) {
87-
this.output = output;
88-
}
89-
90-
public void setTargetNamespace(String value) {
91-
this.direction = value;
79+
public Property<String> getTargetNamespace() {
80+
return targetNamespace;
9281
}
9382

9483
@Input
95-
public boolean isPreserveFileTimestamps() {
84+
public Property<Boolean> getPreserveFileTimestamps() {
9685
return preserveFileTimestamps;
9786
}
9887

99-
public void setPreserveFileTimestamps(boolean preserveFileTimestamps) {
100-
this.preserveFileTimestamps = preserveFileTimestamps;
101-
}
102-
10388
@Input
104-
public boolean isReproducibleFileOrder() {
89+
public Property<Boolean> getReproducibleFileOrder() {
10590
return reproducibleFileOrder;
10691
}
107-
108-
public void setReproducibleFileOrder(boolean reproducibleFileOrder) {
109-
this.reproducibleFileOrder = reproducibleFileOrder;
110-
}
11192
}

0 commit comments

Comments
 (0)