Skip to content

Commit d1d3a9e

Browse files
committed
feat: allow dynamic version selection for clean-that
1 parent 11adc82 commit d1d3a9e

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,6 @@ spotless --target '**/src/**/*.cpp' clang-format --clang-version=20.1.2 --style=
248248
249249
### clean-that
250250

251-
<!---freshmark ctshields
252-
output = [
253-
link(shield('CleanThat version', 'clean-that', '{{libs.versions.native.include.cleanThat}}', 'blue'), 'https://github.com/solven-eu/cleanthat'),
254-
].join('\n')
255-
-->
256-
257-
[![CleanThat version](https://img.shields.io/badge/clean--that-2.23-blue.svg)](https://github.com/solven-eu/cleanthat)
258-
259-
<!---freshmark /ctshields -->
260-
261251
Cleanthat is a project enabling automatic code cleaning, from formatting to refactoring.
262252

263253
To see usage instructions for the clean-that formatter, run: `spotless clean-that --help`
@@ -270,8 +260,9 @@ output =
270260
-->
271261

272262
```
273-
Usage: spotless clean-that [-dDhV] [-s=<sourceCompatibility>] [-a[=mutator[,
274-
mutator...]...]]... [-e[=mutator[,mutator...]...]]...
263+
Usage: spotless clean-that [-dDhV] [-s=<sourceCompatibility>] [-v=<useVersion>]
264+
[-a[=mutator[,mutator...]...]]... [-e[=mutator[,
265+
mutator...]...]]...
275266
CleanThat enables automatic refactoring of Java code.
276267
-a, --add-mutator[=mutator[,mutator...]...]
277268
Add a mutator to the list of mutators to use. Mutators are
@@ -296,6 +287,9 @@ CleanThat enables automatic refactoring of Java code.
296287
This is used to determine the Java language features
297288
available.
298289
(default: 1.8)
290+
-v, --use-version=<useVersion>
291+
The version of CleanThat to use.
292+
(default: 2.24)
299293
-V, --version Print version information and exit.
300294
301295
✅ This step supports the following file type: Java

app/src/main/java/com/diffplug/spotless/cli/steps/CleanThat.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ public class CleanThat extends SpotlessFormatterStep {
4141

4242
public static final String DEFAULT_MUTATORS = String.join(", ", CleanthatJavaStep.defaultMutators());
4343

44+
private static final String DEFAULT_VERSION_SYSPROP = "steps.clean-that.default-version";
45+
4446
static {
4547
// workaround for dynamic property resolution in help messages
4648
System.setProperty("usage.cleanthat.defaultMutators", DEFAULT_MUTATORS);
49+
System.setProperty(DEFAULT_VERSION_SYSPROP, CleanthatJavaStep.defaultVersion());
4750
}
4851

4952
@CommandLine.Option(
@@ -88,11 +91,17 @@ public class CleanThat extends SpotlessFormatterStep {
8891
+ OptionConstants.DEFAULT_VALUE_SUFFIX)
8992
String sourceCompatibility;
9093

94+
@CommandLine.Option(
95+
names = {"--use-version", "-v"},
96+
defaultValue = "${sys:" + DEFAULT_VERSION_SYSPROP + "}",
97+
description = "The version of CleanThat to use." + OptionConstants.DEFAULT_VALUE_SUFFIX)
98+
String useVersion;
99+
91100
@Override
92101
public @NotNull List<FormatterStep> prepareFormatterSteps(SpotlessActionContext context) {
93102
return Collections.singletonList(CleanthatJavaStep.create(
94103
CleanthatJavaStep.defaultGroupArtifact(),
95-
CleanthatJavaStep.defaultVersion(),
104+
useVersion,
96105
this.sourceCompatibility,
97106
includedMutators(),
98107
excludedMutators(),

gradle/libs.versions.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ durian = "1.2.0"
77
junit = "5.8.1"
88
maven-resolver = "2.0.13"
99
mockito = "5.17.0"
10-
native-include-cleanThat = "2.23"
1110
# to find required version here check eclipse_wtp_formatter/v4.21.0.lockfile
1211
# where <4.21.0> is the default version of com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep#defaultVersion
1312
native-include-spotlessEclipseWtp = "3.23.0"
@@ -37,7 +36,6 @@ maven-resolver-transport-apache = { module = "org.apache.maven.resolver:maven-re
3736
maven-resolver-transport-file = { module = "org.apache.maven.resolver:maven-resolver-transport-file" } # version from bom
3837
maven-resolver-util = { module = "org.apache.maven.resolver:maven-resolver-util" } # version from bom
3938
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
40-
native-include-cleanThat = { module = "io.github.solven-eu.cleanthat:java", version.ref = "native-include-cleanThat" }
4139
native-include-spotlessEclipseWtp = { module = "com.diffplug.spotless:spotless-eclipse-wtp", version.ref = "native-include-spotlessEclipseWtp" }
4240
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
4341
picocli-codegen = { module = "info.picocli:picocli-codegen", version.ref = "picocli" }
@@ -61,7 +59,6 @@ maven-resolver-impl-libs = [
6159
"maven-resolver-supplier-mvn4",
6260
]
6361
native-includes = [
64-
"native-include-cleanThat",
6562
"native-include-spotlessEclipseWtp",
6663
]
6764
spotless-libs = ["spotless-lib", "spotless-lib-extra"]

0 commit comments

Comments
 (0)