We use Apache Ant with Nashorn JavaScript Engine, which became deprecated and removed in jdk 15 and up. I trying find how to switch from Nashorn to Graal VM and didn't find any usable information even on Apache web-site. Please advise which jars I need and were should I put them. what need to be changed in code we have. If somebody already did it, please share your experience. I have a sample, which run against jdk1.8.0_311:
<?xml version="1.0" ?>
<project name="test" default="test">
<property environment="env"/>
<target name="test" >
<script language="javascript">
<![CDATA[
load("nashorn:mozilla_compat.js");
importPackage(java.time);
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
self.log("This script is for Test Of Nashorn Javascript Engine");
print ("Today is: " + date );
]]>
</script>
</target>
</project>
Result looks like:
test:
[script] Warning: Nashorn engine is planned to be removed from a future JDK release
[script] This script is for Test Of Nashorn Javascript Engine
[script] Today is: 2021-11-3
BUILD SUCCESSFUL
Total time: 0 seconds
<path id="javax.classpath">
<pathelement location="D:/dependencies/libs/nashorn/nashorn-core-15.4.jar" />?
<pathelement location="D:/dependencies/libs/nashorn/asm-9.7.jar" />
<pathelement location="D:/dependencies/libs/nashorn/asm-util-9.7.jar" />
</path>
<script language="javascript"
manager="javax"
classpathref="javax.classpath">
– Needs