Using recent Rhino in ant script

I'm trying to use the recent version of Rhino in the ant tag, but it seems to use the version of Rhino that comes with the JVM. I tried setting the classpath to indicate the jar of the Rhino script. I have currently tried the following:

<project default="hello" name="hello-world" basedir=".">

    <target name="hello">

        <script language="javascript">

        <classpath>

            <pathelement location="js.jar"/>

        </classpath><![CDATA[

            x=<hello><world/></hello>

        ]]></script>    
    </target>

</project>

Note the inclusion of E4X syntax in a script that should only work in Rhino from Mozilla, and not bundled with the JVM.

js.jar is in the same directory as ant script. I also tried renaming it to rhino.jar, since I think I saw documentation that suggested it was necessary.

When I run it, it gives the following error:

javax.script.ScriptException: sun.org.mozilla.javascript.EvaluatorException: syntax error (# 3)

, , Rhino, JVM. ?

+3
2

, Ant:

<project default="hello" name="helloworld" basedir=".">
   <target name="hello">
       <script language="javascript" manager="bsf">
       <classpath>
           <fileset dir="rhino-lib" includes="*.jar"></fileset>
       </classpath><![CDATA[
           x=<hello><world/></hello>
        echo = helloworld.createTask("echo");
        for (i=1; i<=10; i++) {

          echo.setMessage(i*i);
          echo.perform();
        }
        echo.setMessage(x);
        echo.perform();

       ]]></script>     
   </target>
</project>

. /rhino -lib:

, . , javax.script.

+6

Source: https://habr.com/ru/post/1760647/


All Articles