gnodet opened a new issue, #12988:
URL: https://github.com/apache/maven/issues/12988

   ## Problem
   
   Maven 4 requires JDK 17+, but the Nashorn JavaScript engine was removed in 
JDK 15. Plugins that execute JavaScript in-process (particularly 
`maven-antrun-plugin` with `<script language=\"javascript\">`) fail:
   
   ```
   [ERROR] Unable to create javax script engine for javascript
   javax.script.ScriptException: Unable to create javax script engine for 
javascript
       at 
org.apache.tools.ant.taskdefs.optional.script.JavaxScriptRunner.evaluateScript(...)
   ```
   
   Toolchains cannot help because the script runs **in Maven's own JVM** 
(in-process), not in a forked process using the toolchain JDK.
   
   ## Affected projects (14)
   
   All 14 are Apache Sling projects inheriting from `org.apache.sling:sling:22` 
which has a `set-bundle-required-execution-environment` execution running 
inline JavaScript via antrun:
   
   ```xml
   <script language="javascript"><![CDATA[
       var System = java.lang.System;
       var bree = "J2SE-1.5";
       var slingJavaVersion = System.getProperty("sling.java.version");
       ...
       project.setProperty("sling.bree", bree);
   ]]></script>
   ```
   
   sling-org-apache-sling-{hapi, jcr-js-nodetypes, 
jcr-repository-it-resource-versioning, jms, jobs-it-services, jobs-it, 
launchpad-api, launchpad-installer, paxexam-util, performance, scripting-esx, 
scripting-xproc, tail, urlrewriter}
   
   ## Notes
   
   - These are legacy projects on Sling parent POM v22 (current is v46+, which 
removed the antrun JS execution)
   - The standalone OpenJDK Nashorn (`org.openjdk.nashorn:nashorn-core`) 
provides a drop-in replacement that registers via ServiceLoader
   - All 14 build successfully with Maven 3 (which uses the project's native 
JDK, often JDK 8 or 11)
   
   ## Possible fixes
   
   1. **mvnup could inject standalone Nashorn**: When mvnup detects `<script 
language="javascript">` in antrun executions, it could add 
`org.openjdk.nashorn:nashorn-core` as a dependency of the antrun plugin
   2. **Maven 4 could bundle standalone Nashorn** as an optional compatibility 
module
   3. **`-Dmaven.antrun.skip=true`** could be used as a build flag for legacy 
projects (the BREE property calculation is harmless to skip for compatibility 
testing)
   
   ## Context
   
   Data from [maven4-testing](https://github.com/gnodet/maven4-testing) run 
#13307 testing `maven-4.0.x` against all Apache projects.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to