3434
3535import picocli .CommandLine ;
3636
37- @ CommandLine .Command (name = "eclipse-wtp" , description = "Runs Eclipse WTP formatter." )
37+ @ CommandLine .Command (
38+ name = "eclipse-wtp" ,
39+ description = "Runs Eclipse WTP formatter." ,
40+ defaultValueProvider = EclipseWtp .DefaultValueProvider .class )
3841@ SupportedFileTypes ({"css" , "html" , "js" , "json" , "xml" , "xhtml" })
3942@ AdditionalInfoLinks ({
4043 "https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-tools-platform" ,
4144 "https://projects.eclipse.org/projects/webtools"
4245})
4346public class EclipseWtp extends SpotlessFormatterStep {
4447
45- private static final String DEFAULT_VERSION_SYSPROP = "steps.eclipse-wtp.default-version" ;
46-
47- static {
48- // workaround for dynamic property values in annotations
49- System .setProperty (DEFAULT_VERSION_SYSPROP , EclipseWtpFormatterStep .defaultVersion ());
48+ static class DefaultValueProvider extends CustomVersion .CustomVersionDefaultValueProvider {
49+ DefaultValueProvider () {
50+ super (EclipseWtpFormatterStep ::defaultVersion );
51+ }
5052 }
5153
5254 @ CommandLine .Option (
@@ -63,11 +65,8 @@ public class EclipseWtp extends SpotlessFormatterStep {
6365 + OptionConstants .VALID_VALUES_SUFFIX )
6466 Type type ;
6567
66- @ CommandLine .Option (
67- names = {"--use-version" , "-v" },
68- defaultValue = "${sys:" + DEFAULT_VERSION_SYSPROP + "}" ,
69- description = "The version of Eclipse WTP formatter to use." + OptionConstants .DEFAULT_VALUE_SUFFIX )
70- String useVersion ;
68+ @ CommandLine .Mixin
69+ CustomVersion customVersion ;
7170
7271 public enum Type {
7372 CSS (EclipseWtpFormatterStep .CSS ),
@@ -104,7 +103,7 @@ public enum Type {
104103 public @ NotNull List <FormatterStep > prepareFormatterSteps (SpotlessActionContext context ) {
105104 EclipseWtpFormatterStep wtpType = type (context ::targetFileType ).toEclipseWtpType ();
106105 EclipseBasedStepBuilder builder = wtpType .createBuilder (context .provisioner ());
107- builder .setVersion (useVersion );
106+ builder .setVersion (customVersion . useVersion );
108107 if (configFiles != null && !configFiles .isEmpty ()) {
109108 builder .setPreferences (configFiles .stream ()
110109 .map (context ::resolvePath )
0 commit comments