Skip to content

Commit ab51763

Browse files
committed
docs: document eclipse wtp formatter
1 parent a473521 commit ab51763

File tree

5 files changed

+84
-3
lines changed

5 files changed

+84
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added formatter [`eclipse-wtp`](https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-tools-platform)
13+
1014
## [0.2.0] - 2025-07-31
1115

1216
### Fixed

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Spotless CLI supports the following formatter steps in alphabetical order:
187187

188188
- [clang-format](#clang-format)
189189
- [clean-that](#clean-that)
190+
- [eclipse-wtp](#eclipse-wtp)
190191
- [format-annotations](#format-annotations)
191192
- [google-java-format](#google-java-format)
192193
- [license-header](#license-header)
@@ -312,6 +313,74 @@ Example usage:
312313
spotless --target '**/src/**/*.java' clean-that --exclude-mutator=StreamAnyMatch
313314
```
314315

316+
### eclipse-wtp
317+
318+
<!---freshmark eclipsewtpshields
319+
output = [
320+
link(shield('spotless eclipse wtp version', 'spotless-eclipse-wtp', '{{libs.versions.native.include.spotlessEclipseWtp}}', 'blue'), 'https://central.sonatype.com/artifact/com.diffplug.spotless/spotless-eclipse-wtp/{{libs.versions.native.include.spotlessEclipseWtp}}'),
321+
link(shield('eclipse wtp version', 'eclipse-wtp-formatter', '{{libs.versions.native.include.spotlessEclipseWtpFormatter}}', 'blue'), 'https://github.com/diffplug/spotless/blob/main/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_wtp_formatter/v{{libs.versions.native.include.spotlessEclipseWtpFormatter}}'),
322+
].join('\n')
323+
-->
324+
325+
[![spotless eclipse wtp version](https://img.shields.io/badge/spotless--eclipse--wtp-3.23.0-blue.svg)](https://central.sonatype.com/artifact/com.diffplug.spotless/spotless-eclipse-wtp/3.23.0)
326+
[![eclipse wtp version](https://img.shields.io/badge/eclipse--wtp--formatter-4.21.0-blue.svg)](https://github.com/diffplug/spotless/blob/main/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_wtp_formatter/v4.21.0)
327+
328+
<!---freshmark /eclipsewtpshields -->
329+
330+
The [eclipse web tools platform (WTP)](https://projects.eclipse.org/projects/webtools) formatter is a formatter for web files such as HTML, CSS, JavaScript, JSON, XML and XHTML.
331+
332+
It comes with reasonable defaults but can be configured using configuration files. For details see the [spotless documentation](https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-tools-platform).
333+
334+
To see usage instructions for the eclipse-wtp formatter, run: `spotless eclipse-wtp --help`
335+
336+
<!---freshmark usage_eclipse_wtp
337+
output =
338+
'```\n' +
339+
{{usage.eclipse-wtp.array}}.join('\n') +
340+
'\n```';
341+
-->
342+
343+
```
344+
Usage: spotless eclipse-wtp [-hV] [-f]... [-t=<type>]
345+
Runs Eclipse WTP formatter (4.21.0)
346+
-f, --config-file The path to the Eclipse WTP configuration file. For
347+
supported config file options see spotless
348+
documentation (additional info links).
349+
-h, --help Show this help message and exit.
350+
-t, --type=<type> The type of the Eclipse WTP formatter. If not provided,
351+
the type will be guessed based on the first few files
352+
we find. If that does not work, we fail the formatting
353+
run.
354+
One of: CSS, HTML, JS, JSON, XML, XHTML
355+
-V, --version Print version information and exit.
356+
357+
✅ This step supports the following file types:
358+
* css
359+
* html
360+
* js
361+
* json
362+
* xml
363+
* xhtml
364+
365+
🌎 Additional info:
366+
* https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-to
367+
ols-platform
368+
369+
* https://projects.eclipse.org/projects/webtools
370+
```
371+
372+
<!---freshmark /usage_eclipse_wtp -->
373+
374+
Example usage:
375+
376+
```shell
377+
# format all js files using (multiple) project-specific configuration files
378+
# for details regarding the configuration files see the spotless documentation
379+
spotless --target '**/*.js' eclipse-wtp --type js --config-file spotless.xml.prefs --config-file spotless.common.properties
380+
# or use defaults and infer type from files
381+
spotless --target '**/*.css' eclipse-wtp
382+
```
383+
315384
### format-annotations
316385

317386
In Java, type annotations should be on the same line as the type that they qualify. This formatter fixes this for you.

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import com.diffplug.spotless.FormatterStep;
2727
import com.diffplug.spotless.cli.core.SpotlessActionContext;
2828
import com.diffplug.spotless.cli.core.TargetFileTypeInferer;
29+
import com.diffplug.spotless.cli.help.AdditionalInfoLinks;
2930
import com.diffplug.spotless.cli.help.OptionConstants;
31+
import com.diffplug.spotless.cli.help.SupportedFileTypes;
3032
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
3133
import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep;
3234

@@ -35,16 +37,20 @@
3537
@CommandLine.Command(
3638
name = "eclipse-wtp",
3739
description = "Runs Eclipse WTP formatter (" + EclipseWtp.ECLIPSE_WTP_VERSION + ")")
40+
@SupportedFileTypes({"css", "html", "js", "json", "xml", "xhtml"})
41+
@AdditionalInfoLinks({
42+
"https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-tools-platform",
43+
"https://projects.eclipse.org/projects/webtools"
44+
})
3845
public class EclipseWtp extends SpotlessFormatterStep {
3946

4047
public static final String ECLIPSE_WTP_VERSION = "4.21.0"; // TODO we need to slurp in the lock file also
4148

4249
@CommandLine.Option(
4350
names = {"-f", "--config-file"},
4451
arity = "0",
45-
description =
46-
"The path to the Eclipse WTP configuration file.\n"
47-
+ "For supported config file options see <https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-web-tools-platform>")
52+
description = "The path to the Eclipse WTP configuration file. "
53+
+ "For supported config file options see spotless documentation (additional info links).")
4854
List<Path> configFiles;
4955

5056
@CommandLine.Option(

build-logic/src/main/groovy/com/diffplug/spotless/cli/picocli/usage/DocumentedUsages.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ enum DocumentedUsages {
44

55
CLANG_FORMAT(),
66
CLEAN_THAT(),
7+
ECLIPSE_WTP(),
78
FORMAT_ANNOTATIONS(),
89
MAIN(""),
910
GOOGLE_JAVA_FORMAT(),

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ native-include-palantirJavaFormat = "2.67.0"
1212
# to find required version here check eclipse_wtp_formatter/v4.21.0.lockfile
1313
# where <4.21.0> is the default version of com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep#defaultVersion
1414
native-include-spotlessEclipseWtp = "3.23.0"
15+
native-include-spotlessEclipseWtpFormatter = "4.21.0"
1516
picocli = "4.7.6"
1617
selfie = "2.5.1"
1718
slf4j = "2.0.17"

0 commit comments

Comments
 (0)