在ant脚本使用最近的犀牛 [英] using recent Rhino in ant script

查看:152
本文介绍了在ant脚本使用最近的犀牛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在蚂蚁标签使用最新的Rhino版本,但它似乎是使用自带的JVM捆绑,而不是犀牛的版本。我试着调整类路径指定犀牛脚本罐子。目前,我已经试过以下内容:

I'm trying to use a recent version of Rhino in an ant tag, but it seems to be using the version of Rhino that comes bundled with the JVM instead. I've tried adjusting the classpath to specify the Rhino script jar. Currently, I've 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>

注意E4X语法在脚本中列入,这应该从Mozilla的工作,只有工作犀牛,而不是一个具有JVM捆绑。

Notice the inclusion of E4X syntax in the script, which should work only work in Rhino from Mozilla, and not the one bundled with the JVM.

js.jar是在同一目录下ant脚本。我也试着重新命名它rhino.jar,因为我觉得我已经看到了建议,这是必要的文件。

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

当我运行它,它提供了以下错误:

When I run it, it gives the following error:

javax.script.ScriptException:sun.org.mozilla.javascript.EvaluatorException:语法错误(#3)

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

所以,仿佛它依然使用附带的JVM犀牛的版本,它确实出现。我怎样才能使它使用新版本?

So, it does appear as though it is still using the version of Rhino that comes with the JVM. How can I make it use the new version?

推荐答案

我得到它的工作使用以下Ant项目:

I've got it working using the following Ant project:

<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:

You need the following jars in ./rhino-lib:

  • bsf.jar (bsf 2.4.0)
  • commons-logging-1.1.1.jar
  • js.jar (rhino 1.7R2)

不是prettiest,但它的作品。我会尽量多一点,看看我能得到它与工作的javax.script

Not the prettiest, but it works. I will try a bit more to see if I can get it to work with javax.script.

这篇关于在ant脚本使用最近的犀牛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆