diff --git a/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java b/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java index 2591cac7a5..e2960b1fa8 100644 --- a/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java +++ b/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java @@ -19,12 +19,17 @@ import java.io.Serializable; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.NavigableMap; import java.util.Objects; import java.util.TreeMap; import java.util.function.Consumer; +import com.diffplug.spotless.Jvm; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +47,10 @@ private FreshMarkStep() {} private static final String DEFAULT_VERSION = "1.3.1"; private static final String NAME = "freshmark"; private static final String MAVEN_COORDINATE = "com.diffplug.freshmark:freshmark:"; + + private static final String NASHORN_MAVEN_COORDINATE = "org.openjdk.nashorn:nashorn-core:"; + + private static final String NASHORN_VERSION = "15.4"; private static final String FORMATTER_CLASS = "com.diffplug.freshmark.FreshMark"; private static final String FORMATTER_METHOD = "compile"; @@ -55,8 +64,15 @@ public static FormatterStep create(String version, Supplier> prop Objects.requireNonNull(version, "version"); Objects.requireNonNull(properties, "properties"); Objects.requireNonNull(provisioner, "provisioner"); + + List mavenCoordinates = new ArrayList<>(); + mavenCoordinates.add(MAVEN_COORDINATE + version); + if (Jvm.version() >= 15) { + mavenCoordinates.add(NASHORN_MAVEN_COORDINATE + NASHORN_VERSION); + } + return FormatterStep.createLazy(NAME, - () -> new State(JarState.from(MAVEN_COORDINATE + version, provisioner), properties.get()), + () -> new State(JarState.from(mavenCoordinates, provisioner), properties.get()), State::createFormat); } diff --git a/testlib/src/test/java/com/diffplug/spotless/markdown/FreshMarkStepTest.java b/testlib/src/test/java/com/diffplug/spotless/markdown/FreshMarkStepTest.java index 477642e247..14f3506ed4 100644 --- a/testlib/src/test/java/com/diffplug/spotless/markdown/FreshMarkStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/markdown/FreshMarkStepTest.java @@ -28,7 +28,6 @@ import com.diffplug.spotless.StepHarness; import com.diffplug.spotless.TestProvisioner; -@EnabledForJreRange(max = JAVA_14) class FreshMarkStepTest { @Test void behavior() throws Exception {