File tree Expand file tree Collapse file tree 5 files changed +58
-0
lines changed
lib-extra/src/main/java/com/diffplug/spotless/extra
plugin-maven/src/main/java/com/diffplug/spotless/maven Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package com .diffplug .spotless .extra ;
17
17
18
+ import static java .util .stream .Collectors .toMap ;
19
+
18
20
import java .io .File ;
19
21
import java .io .IOException ;
20
22
import java .io .Serializable ;
21
23
import java .util .ArrayList ;
24
+ import java .util .Collection ;
22
25
import java .util .List ;
23
26
import java .util .Map ;
24
27
import java .util .Properties ;
@@ -76,6 +79,10 @@ public void setP2Mirrors(Map<String, String> p2Mirrors) {
76
79
this .p2Mirrors = Map .copyOf (p2Mirrors );
77
80
}
78
81
82
+ public void setP2Mirrors (Collection <P2Mirror > p2Mirrors ) {
83
+ this .p2Mirrors = p2Mirrors .stream ().collect (toMap (P2Mirror ::getPrefix , P2Mirror ::getUrl ));
84
+ }
85
+
79
86
/** Returns the FormatterStep (whose state will be calculated lazily). */
80
87
public FormatterStep build () {
81
88
return FormatterStep .createLazy (formatterName , this ::get , stateToFormatter );
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2023 DiffPlug
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package com .diffplug .spotless .extra ;
17
+
18
+ public class P2Mirror {
19
+
20
+ private String prefix ;
21
+ private String url ;
22
+
23
+ public String getPrefix () {
24
+ return prefix ;
25
+ }
26
+
27
+ public String getUrl () {
28
+ return url ;
29
+ }
30
+ }
Original file line number Diff line number Diff line change 16
16
package com .diffplug .spotless .maven .cpp ;
17
17
18
18
import java .io .File ;
19
+ import java .util .ArrayList ;
19
20
import java .util .Arrays ;
21
+ import java .util .List ;
20
22
21
23
import org .apache .maven .plugins .annotations .Parameter ;
22
24
23
25
import com .diffplug .spotless .FormatterStep ;
24
26
import com .diffplug .spotless .extra .EquoBasedStepBuilder ;
27
+ import com .diffplug .spotless .extra .P2Mirror ;
25
28
import com .diffplug .spotless .extra .cpp .EclipseCdtFormatterStep ;
26
29
import com .diffplug .spotless .maven .FormatterStepConfig ;
27
30
import com .diffplug .spotless .maven .FormatterStepFactory ;
@@ -34,6 +37,9 @@ public class EclipseCdt implements FormatterStepFactory {
34
37
@ Parameter
35
38
private String version ;
36
39
40
+ @ Parameter
41
+ private List <P2Mirror > p2Mirrors = new ArrayList <>();
42
+
37
43
@ Override
38
44
public FormatterStep newFormatterStep (FormatterStepConfig stepConfig ) {
39
45
EquoBasedStepBuilder eclipseConfig = EclipseCdtFormatterStep .createBuilder (stepConfig .getProvisioner ());
@@ -42,6 +48,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
42
48
File settingsFile = stepConfig .getFileLocator ().locateFile (file );
43
49
eclipseConfig .setPreferences (Arrays .asList (settingsFile ));
44
50
}
51
+ eclipseConfig .setP2Mirrors (p2Mirrors );
45
52
return eclipseConfig .build ();
46
53
}
47
54
}
Original file line number Diff line number Diff line change 16
16
package com .diffplug .spotless .maven .groovy ;
17
17
18
18
import java .io .File ;
19
+ import java .util .ArrayList ;
19
20
import java .util .Arrays ;
21
+ import java .util .List ;
20
22
21
23
import org .apache .maven .plugins .annotations .Parameter ;
22
24
23
25
import com .diffplug .spotless .FormatterStep ;
24
26
import com .diffplug .spotless .extra .EquoBasedStepBuilder ;
27
+ import com .diffplug .spotless .extra .P2Mirror ;
25
28
import com .diffplug .spotless .extra .groovy .GrEclipseFormatterStep ;
26
29
import com .diffplug .spotless .maven .FormatterStepConfig ;
27
30
import com .diffplug .spotless .maven .FormatterStepFactory ;
@@ -34,6 +37,9 @@ public class GrEclipse implements FormatterStepFactory {
34
37
@ Parameter
35
38
private String version ;
36
39
40
+ @ Parameter
41
+ private List <P2Mirror > p2Mirrors = new ArrayList <>();
42
+
37
43
@ Override
38
44
public FormatterStep newFormatterStep (FormatterStepConfig stepConfig ) {
39
45
EquoBasedStepBuilder grEclipseConfig = GrEclipseFormatterStep .createBuilder (stepConfig .getProvisioner ());
@@ -42,6 +48,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
42
48
File settingsFile = stepConfig .getFileLocator ().locateFile (file );
43
49
grEclipseConfig .setPreferences (Arrays .asList (settingsFile ));
44
50
}
51
+ grEclipseConfig .setP2Mirrors (p2Mirrors );
45
52
return grEclipseConfig .build ();
46
53
}
47
54
}
Original file line number Diff line number Diff line change 16
16
package com .diffplug .spotless .maven .java ;
17
17
18
18
import java .io .File ;
19
+ import java .util .ArrayList ;
19
20
import java .util .Arrays ;
21
+ import java .util .List ;
20
22
21
23
import org .apache .maven .plugins .annotations .Parameter ;
22
24
23
25
import com .diffplug .spotless .FormatterStep ;
24
26
import com .diffplug .spotless .extra .EquoBasedStepBuilder ;
27
+ import com .diffplug .spotless .extra .P2Mirror ;
25
28
import com .diffplug .spotless .extra .java .EclipseJdtFormatterStep ;
26
29
import com .diffplug .spotless .maven .FormatterStepConfig ;
27
30
import com .diffplug .spotless .maven .FormatterStepFactory ;
@@ -34,6 +37,9 @@ public class Eclipse implements FormatterStepFactory {
34
37
@ Parameter
35
38
private String version ;
36
39
40
+ @ Parameter
41
+ private List <P2Mirror > p2Mirrors = new ArrayList <>();
42
+
37
43
@ Override
38
44
public FormatterStep newFormatterStep (FormatterStepConfig stepConfig ) {
39
45
EquoBasedStepBuilder eclipseConfig = EclipseJdtFormatterStep .createBuilder (stepConfig .getProvisioner ());
@@ -42,6 +48,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
42
48
File settingsFile = stepConfig .getFileLocator ().locateFile (file );
43
49
eclipseConfig .setPreferences (Arrays .asList (settingsFile ));
44
50
}
51
+ eclipseConfig .setP2Mirrors (p2Mirrors );
45
52
return eclipseConfig .build ();
46
53
}
47
54
}
You can’t perform that action at this time.
0 commit comments