Skip to content

Commit b0b7c17

Browse files
committed
Apply eclipse-jdt-4.8.1
The new version fixes module-info formatting.
1 parent 25178b2 commit b0b7c17

File tree

7 files changed

+18
-4
lines changed

7 files changed

+18
-4
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ 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+
### Fixed
14+
* [module-info formatting](https://github.com/diffplug/spotless/pull/958) in `eclipse-jdt` versions `4.20` and `4.21`. Note that the problem also affects older versions.
1315

1416
## [2.19.0] - 2021-10-02
1517
* Added `wildcardsLast` option for Java `ImportOrderStep` ([#954](https://github.com/diffplug/spotless/pull/954))

lib-extra/src/main/java/com/diffplug/spotless/extra/java/EclipseJdtFormatterStep.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ private static FormatterFunc apply(State state) throws Exception {
5050
Class<?> formatterClazz = getClass(state);
5151
Object formatter = formatterClazz.getConstructor(Properties.class).newInstance(state.getPreferences());
5252
Method method = formatterClazz.getMethod(FORMATTER_METHOD, String.class);
53-
return JVM_SUPPORT.suggestLaterVersionOnError(state.getSemanticVersion(), input -> (String) method.invoke(formatter, input));
53+
FormatterFunc formatterFunc = getFormatterFunc(formatter, method);
54+
return JVM_SUPPORT.suggestLaterVersionOnError(state.getSemanticVersion(), formatterFunc);
5455
}
5556

5657
private static Class<?> getClass(State state) {
@@ -59,4 +60,11 @@ private static Class<?> getClass(State state) {
5960
}
6061
return state.loadClass(FORMATTER_CLASS_OLD);
6162
}
63+
64+
private static FormatterFunc getFormatterFunc(Object formatter, Method method) {
65+
if (1 == method.getParameterCount()) {
66+
return input -> (String) method.invoke(formatter, input);
67+
}
68+
return (FormatterFunc.NeedsFile) (input, file) -> (String) method.invoke(formatter, input, file);
69+
}
6270
}

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.20.0.lockfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on JDT version 4.20.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/log/?h=R4_20 to determine core version.
3-
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
3+
com.diffplug.spotless:spotless-eclipse-jdt:4.8.1
44
com.diffplug.spotless:spotless-eclipse-base:3.5.0
55
com.github.spotbugs:spotbugs-annotations:4.0.2
66
com.google.code.findbugs:jsr305:3.0.2

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.21.0.lockfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on JDT version 4.21.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/log/?h=R4_21 to determine core version.
3-
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
3+
com.diffplug.spotless:spotless-eclipse-jdt:4.8.1
44
com.diffplug.spotless:spotless-eclipse-base:3.5.0
55
com.github.spotbugs:spotbugs-annotations:4.0.2
66
com.google.code.findbugs:jsr305:3.0.2

lib-extra/src/test/java/com/diffplug/spotless/extra/java/EclipseJdtFormatterStepTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
class EclipseJdtFormatterStepTest extends EclipseResourceHarness {
2828
private final static String NON_SEMANTIC_ECLIPSE_VERSION = "4.7.3a";
29-
private final static Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support("Oldest Version").add(8, "4.6.1");
29+
private final static Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support("Oldest Version").add(8, "4.6.1").add(11, "4.20.0");
3030
private final static String INPUT = "package p; class C{}";
3131
private final static String EXPECTED = "package p;\nclass C {\n}";
3232

plugin-gradle/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* [module-info formatting](https://github.com/diffplug/spotless/pull/958) in `eclipse-jdt` versions `4.20` and `4.21`. Note that the problem also affects older versions.
68

79
## [5.16.0] - 2021-10-02
810
* Added `wildcardsLast()` option for Java `importOrder` ([#954](https://github.com/diffplug/spotless/pull/954))

plugin-maven/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* [module-info formatting](https://github.com/diffplug/spotless/pull/958) in `eclipse-jdt` versions `4.20` and `4.21`. Note that the problem also affects older versions.
68

79
## [2.17.0] - 2021-10-04
810
### Added

0 commit comments

Comments
 (0)