Skip to content

Commit 523a601

Browse files
authored
Fix Freshmark compatibility with JDK 15+ (#1304 fixes #803)
2 parents 1774837 + e9d72aa commit 523a601

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1212
## [Unreleased]
1313
### Changes
1414
* **POTENTIALLY BREAKING** Bump bytecode from Java 8 to 11 ([#1530](https://github.com/diffplug/spotless/pull/1530) part 2 of [#1337](https://github.com/diffplug/spotless/issues/1337))
15+
### Fixed
1516
* **POTENTIALLY BREAKING** `sortByKeys` for JSON formatting now takes into account objects inside arrays ([#1546](https://github.com/diffplug/spotless/pull/1546))
17+
* `freshmark` fixed on java 15+ ([#1304](https://github.com/diffplug/spotless/pull/1304) fixes [#803](https://github.com/diffplug/spotless/issues/803))
1618

1719
## [2.34.0] - 2023-01-26
1820
### Added

lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java

+17-2
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.
@@ -19,6 +19,8 @@
1919

2020
import java.io.Serializable;
2121
import java.lang.reflect.Method;
22+
import java.util.ArrayList;
23+
import java.util.List;
2224
import java.util.Map;
2325
import java.util.NavigableMap;
2426
import java.util.Objects;
@@ -31,6 +33,7 @@
3133
import com.diffplug.spotless.FormatterFunc;
3234
import com.diffplug.spotless.FormatterStep;
3335
import com.diffplug.spotless.JarState;
36+
import com.diffplug.spotless.Jvm;
3437
import com.diffplug.spotless.Provisioner;
3538
import com.diffplug.spotless.ThrowingEx.Supplier;
3639

@@ -42,6 +45,10 @@ private FreshMarkStep() {}
4245
private static final String DEFAULT_VERSION = "1.3.1";
4346
private static final String NAME = "freshmark";
4447
private static final String MAVEN_COORDINATE = "com.diffplug.freshmark:freshmark:";
48+
49+
private static final String NASHORN_MAVEN_COORDINATE = "org.openjdk.nashorn:nashorn-core:";
50+
51+
private static final String NASHORN_VERSION = "15.4";
4552
private static final String FORMATTER_CLASS = "com.diffplug.freshmark.FreshMark";
4653
private static final String FORMATTER_METHOD = "compile";
4754

@@ -55,8 +62,16 @@ public static FormatterStep create(String version, Supplier<Map<String, ?>> prop
5562
Objects.requireNonNull(version, "version");
5663
Objects.requireNonNull(properties, "properties");
5764
Objects.requireNonNull(provisioner, "provisioner");
65+
66+
List<String> mavenCoordinates = new ArrayList<>();
67+
mavenCoordinates.add(MAVEN_COORDINATE + version);
68+
if (Jvm.version() >= 15) {
69+
mavenCoordinates.add("com.diffplug.jscriptbox:jscriptbox:3.0.1");
70+
mavenCoordinates.add(NASHORN_MAVEN_COORDINATE + NASHORN_VERSION);
71+
}
72+
5873
return FormatterStep.createLazy(NAME,
59-
() -> new State(JarState.from(MAVEN_COORDINATE + version, provisioner), properties.get()),
74+
() -> new State(JarState.from(mavenCoordinates, provisioner), properties.get()),
6075
State::createFormat);
6176
}
6277

plugin-gradle/CHANGES.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +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-
### Changes
6+
### Fixed
7+
* `freshmark` fixed on java 15+ ([#1304](https://github.com/diffplug/spotless/pull/1304) fixes [#803](https://github.com/diffplug/spotless/issues/803))
78
* **POTENTIALLY BREAKING** `sortByKeys` for JSON formatting now takes into account objects inside arrays ([#1546](https://github.com/diffplug/spotless/pull/1546))
89

910
## [6.14.0] - 2023-01-26

plugin-maven/CHANGES.md

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
77
* A synthesis log with the number of considered files is added after each formatter execution ([#1507](https://github.com/diffplug/spotless/pull/1507))
88
### Fixed
99
* Respect `sourceDirectory` and `testSourceDirectory` POM configurations for Java formatters ([#1553](https://github.com/diffplug/spotless/pull/1553))
10-
### Changes
1110
* **POTENTIALLY BREAKING** `sortByKeys` for JSON formatting now takes into account objects inside arrays ([#1546](https://github.com/diffplug/spotless/pull/1546))
1211
* Any commit of the Spotless maven plugin now available via JitPack ([#1547](https://github.com/diffplug/spotless/pull/1547))
1312

testlib/src/test/java/com/diffplug/spotless/markdown/FreshMarkStepTest.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 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.
@@ -15,20 +15,16 @@
1515
*/
1616
package com.diffplug.spotless.markdown;
1717

18-
import static org.junit.jupiter.api.condition.JRE.JAVA_14;
19-
2018
import java.util.HashMap;
2119
import java.util.Map;
2220

2321
import org.junit.jupiter.api.Test;
24-
import org.junit.jupiter.api.condition.EnabledForJreRange;
2522

2623
import com.diffplug.spotless.FormatterStep;
2724
import com.diffplug.spotless.SerializableEqualityTester;
2825
import com.diffplug.spotless.StepHarness;
2926
import com.diffplug.spotless.TestProvisioner;
3027

31-
@EnabledForJreRange(max = JAVA_14)
3228
class FreshMarkStepTest {
3329
@Test
3430
void behavior() throws Exception {

0 commit comments

Comments
 (0)