0

Oracle has depreciated nashorn and I use it in my apache ant build scripts.

Here is a short example;

try{load("nashorn:mozilla_compat.js");}catch(e){;}
    importClass(java.io.File);
    var sourceName = project.getProperty("build.source.dir") + "/" +project.getProperty("teiFile") + ".xml";
    var targetName = project.getProperty("build.search.dir") + "/" + project.getProperty("teiFile") + ".xml";
    var sourceFile = new File("", sourceName);
    var targetFile = new File("", targetName);
    var uptodate = targetFile.exists() && sourceFile.lastModified() < targetFile.lastModified();
      var sourcePrefix = project.getProperty("teiFile");
      if(!uptodate & !sourcePrefix.startsWith("G")) {
         ......
       }
}

I've heard mentions of Rhino or graalVM as a replacement, but each seems to have a fairly long list of deficiencies.Suggestions for a library that is currently active and stable.

thanks, scott

1
  • While I don’t know what your ...... line represents, I suspect the parts you’ve shown can be done with regular Ant tasks. Commented Mar 3, 2020 at 1:32

1 Answer 1

1

GraalVM is currently active, stable, has a Nashorn compatibility mode. You can run your ant scripts with GraalVM, and the JS engine is included by default. Or you can include GraalVM's JavaScript as a few dependencies and run on OpenJDK, which will be slower, and might be an untested combination of OpenJDK and GraalVM's JavaScript, but can also work.

Sign up to request clarification or add additional context in comments.

1 Comment

Specifically, you should probably set that to your ANT_OPTS before calling ant: ANT_OPTS="-Dpolyglot.js.nashorn-compat=true" ant See our FAQ

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.