Skip to content

Commit 45df861

Browse files
authored
Improve message when prompting user to upgrade their JVM (#995)
Upgrade Message: Print current version
2 parents 8f8951e + 445971c commit 45df861

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1616
* Added `skipLinesMatching` option to `licenseHeader` to support formats where license header cannot be immediately added to the top of the file (e.g. xml, sh). ([#1441](https://github.com/diffplug/spotless/pull/1441)).
1717
* Add YAML support through Jackson ([#1478](https://github.com/diffplug/spotless/pull/1478))
1818
* Added support for npm-based [ESLint](https://eslint.org/)-formatter for javascript and typescript ([#1453](https://github.com/diffplug/spotless/pull/1453))
19+
* Better suggested messages when user's default is set by JVM limitation. ([#995](https://github.com/diffplug/spotless/pull/995))
1920
### Fixed
2021
* Support `ktlint` 0.48+ new rule disabling syntax ([#1456](https://github.com/diffplug/spotless/pull/1456)) fixes ([#1444](https://github.com/diffplug/spotless/issues/1444))
21-
2222
### Changes
2323
* Bump default version for `prettier` from `2.0.5` to `2.8.1` ([#1453](https://github.com/diffplug/spotless/pull/1453))
2424
* Bump the dev version of Gradle from `7.5.1` to `7.6` ([#1409](https://github.com/diffplug/spotless/pull/1409))

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 DiffPlug
2+
* Copyright 2016-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -198,8 +198,9 @@ private String buildUpgradeFormatterMessage(V fmtVersion) {
198198
StringBuilder builder = new StringBuilder();
199199
V recommendedFmtVersionOrNull = getRecommendedFormatterVersion();
200200
if (null != recommendedFmtVersionOrNull && (fmtVersionComparator.compare(fmtVersion, recommendedFmtVersionOrNull) < 0)) {
201-
builder.append(String.format("You are not using latest version on JVM %d+.%n", getRequiredJvmVersion(recommendedFmtVersionOrNull)));
202-
builder.append(String.format("Try to upgrade to %s %s, which may have fixed this problem.", fmtName, getRecommendedFormatterVersion()));
201+
builder.append(String.format("%s %s is currently being used, but outdated.%n", fmtName, fmtVersion));
202+
builder.append(String.format("%s %s is the recommended version, which may have fixed this problem.%n", fmtName, recommendedFmtVersionOrNull));
203+
builder.append(String.format("%s %s requires JVM %d+.", fmtName, recommendedFmtVersionOrNull, getRequiredJvmVersion(recommendedFmtVersionOrNull)));
203204
} else {
204205
V higherFormatterVersionOrNull = fmt2jvmVersion.higherKey(fmtVersion);
205206
if (null != higherFormatterVersionOrNull) {

plugin-gradle/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
88
* **POTENTIALLY BREAKING** `ktlint` step now modifies license headers. Make sure to put `licenseHeader` *after* `ktlint`.
99
* Added `skipLinesMatching` option to `licenseHeader` to support formats where license header cannot be immediately added to the top of the file (e.g. xml, sh). ([#1441](https://github.com/diffplug/spotless/pull/1441))
1010
* Added support for npm-based [ESLint](https://eslint.org/) formatter for javascript and typescript ([#1453](https://github.com/diffplug/spotless/pull/1453))
11+
* Better suggested messages when user's default is set by JVM limitation. ([#995](https://github.com/diffplug/spotless/pull/995))
1112
### Fixed
1213
* Prevent tool configurations from being resolved outside project ([#1447](https://github.com/diffplug/spotless/pull/1447) fixes [#1215](https://github.com/diffplug/spotless/issues/1215))
1314
* Support `ktlint` 0.48+ new rule disabling syntax ([#1456](https://github.com/diffplug/spotless/pull/1456)) fixes ([#1444](https://github.com/diffplug/spotless/issues/1444))

plugin-maven/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1010
* Add JSON support ([#1446](https://github.com/diffplug/spotless/pull/1446))
1111
* Add YAML support through Jackson ([#1478](https://github.com/diffplug/spotless/pull/1478))
1212
* Added support for npm-based [ESLint](https://eslint.org/)-formatter for javascript and typescript ([#1453](https://github.com/diffplug/spotless/pull/1453))
13+
* Better suggested messages when user's default is set by JVM limitation. ([#995](https://github.com/diffplug/spotless/pull/995))
1314
### Fixed
1415
* Support `ktlint` 0.48+ new rule disabling syntax ([#1456](https://github.com/diffplug/spotless/pull/1456)) fixes ([#1444](https://github.com/diffplug/spotless/issues/1444))
1516
### Changes

testlib/src/test/java/com/diffplug/spotless/JvmTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -140,9 +140,9 @@ void supportProposesFormatterUpgrade() {
140140
throw new Exception("Some test exception");
141141
}).apply("");
142142
}).getMessage();
143-
assertThat(proposal).contains("not using latest version");
144-
assertThat(proposal).contains(String.format("on JVM %d+", requiredJvm));
145-
assertThat(proposal).contains(String.format("upgrade to %s %s", TEST_NAME, "2"));
143+
assertThat(proposal).isEqualTo("My Test Formatter " + fmtVersion + " is currently being used, but outdated.\n" +
144+
"My Test Formatter 2 is the recommended version, which may have fixed this problem.\n" +
145+
"My Test Formatter 2 requires JVM 10+.");
146146
}
147147
}
148148

0 commit comments

Comments
 (0)