24
24
25
25
package net .fabricmc .loom .task ;
26
26
27
- import java . io . File ;
28
-
27
+ import org . gradle . api . file . RegularFileProperty ;
28
+ import org . gradle . api . provider . Property ;
29
29
import org .gradle .api .tasks .Input ;
30
30
import org .gradle .api .tasks .InputFile ;
31
31
import org .gradle .api .tasks .Internal ;
35
35
import net .fabricmc .loom .util .SourceRemapper ;
36
36
37
37
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" ) ;
41
41
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 ) ;
44
44
45
45
public RemapSourcesJarTask () {
46
46
}
47
47
48
48
@ TaskAction
49
49
public void remap () throws Exception {
50
50
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 ());
52
53
} else {
53
- sourceRemapper .scheduleRemapSources (getInput (), getOutput () , reproducibleFileOrder , preserveFileTimestamps );
54
+ sourceRemapper .scheduleRemapSources (input . get (). getAsFile (), output . get (). getAsFile () , reproducibleFileOrder . get () , preserveFileTimestamps . get () );
54
55
}
55
56
}
56
57
@@ -65,47 +66,27 @@ public RemapSourcesJarTask setSourceRemapper(SourceRemapper sourceRemapper) {
65
66
}
66
67
67
68
@ InputFile
68
- public File getInput () {
69
- return getProject (). file ( input ) ;
69
+ public RegularFileProperty getInput () {
70
+ return input ;
70
71
}
71
72
72
73
@ OutputFile
73
- public File getOutput () {
74
- return getProject (). file ( output == null ? input : output ) ;
74
+ public RegularFileProperty getOutput () {
75
+ return output ;
75
76
}
76
77
77
78
@ 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 ;
92
81
}
93
82
94
83
@ Input
95
- public boolean isPreserveFileTimestamps () {
84
+ public Property < Boolean > getPreserveFileTimestamps () {
96
85
return preserveFileTimestamps ;
97
86
}
98
87
99
- public void setPreserveFileTimestamps (boolean preserveFileTimestamps ) {
100
- this .preserveFileTimestamps = preserveFileTimestamps ;
101
- }
102
-
103
88
@ Input
104
- public boolean isReproducibleFileOrder () {
89
+ public Property < Boolean > getReproducibleFileOrder () {
105
90
return reproducibleFileOrder ;
106
91
}
107
-
108
- public void setReproducibleFileOrder (boolean reproducibleFileOrder ) {
109
- this .reproducibleFileOrder = reproducibleFileOrder ;
110
- }
111
92
}
0 commit comments