1
1
/*
2
- * Copyright 2020-2023 DiffPlug
2
+ * Copyright 2020-2024 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
37
37
import org .gradle .api .tasks .PathSensitivity ;
38
38
import org .gradle .work .Incremental ;
39
39
40
- import com .diffplug .gradle .spotless .JvmLocalCache .LiveCache ;
41
40
import com .diffplug .spotless .FormatExceptionPolicy ;
42
41
import com .diffplug .spotless .FormatExceptionPolicyStrict ;
43
42
import com .diffplug .spotless .Formatter ;
@@ -49,10 +48,6 @@ public abstract class SpotlessTask extends DefaultTask {
49
48
@ Internal
50
49
abstract Property <SpotlessTaskService > getTaskService ();
51
50
52
- protected <T > LiveCache <T > createLive (String keyName ) {
53
- return JvmLocalCache .createLive (this , keyName );
54
- }
55
-
56
51
// set by SpotlessExtension, but possibly overridden by FormatExtension
57
52
protected String encoding = "UTF-8" ;
58
53
@@ -65,15 +60,15 @@ public void setEncoding(String encoding) {
65
60
this .encoding = Objects .requireNonNull (encoding );
66
61
}
67
62
68
- protected final LiveCache < Provider <LineEnding .Policy >> lineEndingsPolicy = createLive ( "lineEndingsPolicy" ) ;
63
+ protected Provider <LineEnding .Policy > lineEndingsPolicy = null ;
69
64
70
65
@ Input
71
66
public Provider <LineEnding .Policy > getLineEndingsPolicy () {
72
- return lineEndingsPolicy . get () ;
67
+ return lineEndingsPolicy ;
73
68
}
74
69
75
70
public void setLineEndingsPolicy (Provider <LineEnding .Policy > lineEndingsPolicy ) {
76
- this .lineEndingsPolicy . set ( lineEndingsPolicy ) ;
71
+ this .lineEndingsPolicy = lineEndingsPolicy ;
77
72
}
78
73
79
74
/** The sha of the tree at repository root, used for determining if an individual *file* is clean according to git. */
@@ -155,22 +150,17 @@ public File getOutputDirectory() {
155
150
return outputDirectory ;
156
151
}
157
152
158
- protected final LiveCache <List <FormatterStep >> steps = createLive ("steps" );
159
- {
160
- steps .set (new ArrayList <FormatterStep >());
161
- }
153
+ protected final List <FormatterStep > steps = new ArrayList <>();
162
154
163
155
@ Input
164
156
public List <FormatterStep > getSteps () {
165
- return Collections .unmodifiableList (steps . get () );
157
+ return Collections .unmodifiableList (steps );
166
158
}
167
159
168
160
public void setSteps (List <FormatterStep > steps ) {
169
- this .steps .set (PluginGradlePreconditions .requireElementsNonNull (steps ));
170
- }
171
-
172
- public boolean addStep (FormatterStep step ) {
173
- return this .steps .get ().add (Objects .requireNonNull (step ));
161
+ this .steps .clear ();
162
+ PluginGradlePreconditions .requireElementsNonNull (steps );
163
+ this .steps .addAll (steps );
174
164
}
175
165
176
166
/** Returns the name of this format. */
@@ -186,10 +176,10 @@ String formatName() {
186
176
Formatter buildFormatter () {
187
177
return Formatter .builder ()
188
178
.name (formatName ())
189
- .lineEndingsPolicy (lineEndingsPolicy . get ().get ())
179
+ .lineEndingsPolicy (getLineEndingsPolicy ().get ())
190
180
.encoding (Charset .forName (encoding ))
191
181
.rootDir (getProjectDir ().get ().getAsFile ().toPath ())
192
- .steps (steps . get () )
182
+ .steps (steps )
193
183
.exceptionPolicy (exceptionPolicy )
194
184
.build ();
195
185
}
0 commit comments