Skip to content

Commit 7f90d65

Browse files
authored
Allow foreign executables to explicitly specify "use any found version" with '*' (#2758)
2 parents 24a9294 + de5469f commit 7f90d65

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ This document is intended for Spotless developers.
1010
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
1111

1212
## [Unreleased]
13+
### Added
14+
- Add the ability to specify a wildcard version (`*`) for external formatter executables. ([#2757](https://github.com/diffplug/spotless/issues/2757))
1315
### Changes
14-
* Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763))
16+
- Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763))
1517

1618
## [4.1.0] - 2025-11-18
1719
### Changes

lib/src/main/java/com/diffplug/spotless/ForeignExe.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
public class ForeignExe implements Serializable {
3737
@Serial
3838
private static final long serialVersionUID = 1L;
39+
private static final String VERSION_WILDCARD = "*";
3940
private @Nullable String pathToExe;
4041
private String versionFlag = "--version";
4142
private Pattern versionRegex = Pattern.compile("version (\\S*)");
@@ -111,7 +112,7 @@ public String confirmVersionAndGetAbsolutePath() throws IOException, Interrupted
111112
throw cantFind("Unable to parse version with /" + versionRegex + "/", cmdVersion);
112113
}
113114
String versionFound = versionMatcher.group(1);
114-
if (!versionFound.equals(version)) {
115+
if (!VERSION_WILDCARD.equals(versionFound) && !versionFound.equals(version)) {
115116
throw wrongVersion("You specified version " + version + ", but Spotless found " + versionFound, cmdVersion, versionFound);
116117
}
117118
return exeAbsPath;

plugin-gradle/CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Added
7+
- Add the ability to specify a wildcard version (`*`) for external formatter executables. ([#2757](https://github.com/diffplug/spotless/issues/2757))
68
### Changes
7-
* Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763))
9+
- Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763))
810

911
## [8.1.0] - 2025-11-18
1012
### Changes

plugin-gradle/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ spotless {
674674
[homepage](https://github.com/psf/black). [changelog](https://github.com/psf/black/blob/master/CHANGES.md).
675675

676676
```gradle
677-
black('19.10b0') // version is optional
677+
black('19.10b0') // version is optional. Explicitly allow "any found version" with '*'.
678678

679679
// if black is not on your path, you must specify its location manually
680680
black().pathToExe('C:/myuser/.pyenv/versions/3.8.0/scripts/black.exe')
@@ -1211,7 +1211,7 @@ When formatting shell scripts via `shfmt`, configure `shfmt` settings via `.edit
12111211
Refer to the `shfmt` [man page](https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd) for `.editorconfig` settings.
12121212
12131213
```gradle
1214-
shfmt('3.8.0') // version is optional
1214+
shfmt('3.8.0') // version is optional. Explicitly allow "any found version" with '*'.
12151215
12161216
// if shfmt is not on your path, you must specify its location manually
12171217
shfmt().pathToExe('/opt/homebrew/bin/shfmt')
@@ -1402,7 +1402,7 @@ spotless {
14021402
// you have to set the target manually
14031403
target 'src/**/*.cs'
14041404
1405-
clangFormat('10.0.1') // version is optional
1405+
clangFormat('10.0.1') // version is optional. Explicitly allow "any found version" with '*'.
14061406
14071407
// can also specify a code style
14081408
clangFormat().style('LLVM') // or Google, Chromium, Mozilla, WebKit

plugin-maven/CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6+
### Added
7+
- Add the ability to specify a wildcard version (`*`) for external formatter executables. ([#2757](https://github.com/diffplug/spotless/issues/2757))
68
### Changes
7-
* Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763))
9+
- Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763))
810

911
## [3.1.0] - 2025-11-18
1012
### Changes

plugin-maven/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ Additionally, `editorConfigOverride` options will override what's supplied in `.
606606

607607
```xml
608608
<clangFormat>
609-
<version>14.0.0-1ubuntu1.1</version> <!-- optional version of clang-format -->
609+
<version>14.0.0-1ubuntu1.1</version> <!-- optional version of clang-format. Explicitly allow "any found version" with '*'. -->
610610
<pathToExe>/path/to/buf</pathToExe> <!-- optional: if clang-format isn't in your path -->
611611
<style>LLVM</style> <!-- optional: can be LLVM, Google, Chromium, Mozilla, WebKit -->
612612
</clangFormat>
@@ -635,7 +635,7 @@ Additionally, `editorConfigOverride` options will override what's supplied in `.
635635

636636
```xml
637637
<black>
638-
<version>19.10b0</version> <!-- optional -->
638+
<version>19.10b0</version> <!-- optional. Explicitly allow "any found version" with '*'. -->
639639
<!-- if black is not on your path, you must specify its location manually -->
640640
<pathToExe>C:/myuser/.pyenv/versions/3.8.0/scripts/black.exe</pathToExe>
641641
<!--
@@ -1161,7 +1161,7 @@ When formatting shell scripts via `shfmt`, configure `shfmt` settings via `.edit
11611161

11621162
```xml
11631163
<shfmt>
1164-
<version>3.8.0</version> <!-- optional: Custom version of 'mvdan/sh' -->
1164+
<version>3.8.0</version> <!-- optional: Custom version of 'mvdan/sh'. Explicitly allow "any found version" with '*'. -->
11651165
<pathToExe>/opt/homebrew/bin/shfmt</pathToExe> <!-- optional: if shfmt is not on your path, you must specify its location manually -->
11661166
</shfmt>
11671167
```
@@ -1216,7 +1216,7 @@ Standard Go formatter, part of Go distribution.
12161216

12171217
```xml
12181218
<gofmt>
1219-
<version>go1.25.1</version>
1219+
<version>go1.25.1</version> <!-- Explicitly allow "any found version" with '*'. -->
12201220
<goExecutablePath>/opt/sdks/go1.25.1/bin/go</goExecutablePath>
12211221
</gofmt>
12221222
```
@@ -1303,7 +1303,7 @@ RDF parsing is done via [Apache Jena](https://jena.apache.org/) in the version t
13031303
[homepage](https://buf.build/) [buf repo](https://github.com/bufbuild/buf).
13041304
```xml
13051305
<buf>
1306-
<version>1.44.0</version> <!-- optional -->
1306+
<version>1.44.0</version> <!-- optional. Explicitly allow "any found version" with '*'. -->
13071307
<pathToExe>/path/to/buf</pathToExe> <!-- optional: if buf isn't in your path -->
13081308
</buf>
13091309
```

0 commit comments

Comments
 (0)