Class NashornCompatibilityStrategy
java.lang.Object
org.apache.maven.cling.invoker.mvnup.goals.AbstractUpgradeStrategy
org.apache.maven.cling.invoker.mvnup.goals.NashornCompatibilityStrategy
- All Implemented Interfaces:
UpgradeStrategy
@Named
@Singleton
@Priority(19)
public class NashornCompatibilityStrategy
extends AbstractUpgradeStrategy
Strategy for injecting the standalone OpenJDK Nashorn engine as a plugin dependency
when
maven-antrun-plugin uses inline JavaScript via <script language="javascript">.
Maven 4 requires JDK 17+, but the built-in Nashorn JavaScript engine was removed in JDK 15.
Plugins executing JavaScript in-process (particularly maven-antrun-plugin with
<script language="javascript">) fail with:
[ERROR] Unable to create javax script engine for javascript
Toolchains cannot help because the script runs in Maven's own JVM, not in a forked process.
The standalone OpenJDK Nashorn (org.openjdk.nashorn:nashorn-core) provides a drop-in
replacement that registers via ServiceLoader and restores JavaScript support.
This strategy both injects the Nashorn dependency as a quick fix and
warns that users should consider migrating to GraalVM JavaScript
(org.graalvm.js:js-scriptengine) for long-term support.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UpgradeResultdoApply(UpgradeContext context, Map<Path, eu.maveniverse.domtrip.Document> pomMap) Subclasses implement the actual upgrade logic here.Gets a description of what this strategy does.booleanisApplicable(UpgradeContext context) Checks if this strategy is applicable given the current options.Methods inherited from class org.apache.maven.cling.invoker.mvnup.goals.AbstractUpgradeStrategy
apply, buildEffectiveModel, computeAllArtifactCoordinates, extractArtifactCoordinatesWithParentResolution, findCommonRoot, getOptions, getSession, logSummary, remoteResolutionUnsupportedReasonMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.cling.invoker.mvnup.goals.UpgradeStrategy
isOptionEnabled
-
Constructor Details
-
NashornCompatibilityStrategy
public NashornCompatibilityStrategy()
-
-
Method Details
-
isApplicable
Description copied from interface:UpgradeStrategyChecks if this strategy is applicable given the current options.- Parameters:
context- the upgrade context- Returns:
- true if this strategy should be applied
-
getDescription
Description copied from interface:UpgradeStrategyGets a description of what this strategy does.- Returns:
- a human-readable description of the strategy
-
doApply
protected UpgradeResult doApply(UpgradeContext context, Map<Path, eu.maveniverse.domtrip.Document> pomMap) Description copied from class:AbstractUpgradeStrategySubclasses implement the actual upgrade logic here.- Specified by:
doApplyin classAbstractUpgradeStrategy- Parameters:
context- the upgrade contextpomMap- map of all POM files in the project- Returns:
- the result of the upgrade operation
-