在 ant 脚本中使用最新的 Rhino
我试图在 ant 标签中使用最新版本的 Rhino,但它似乎使用与 JVM 捆绑在一起的 Rhino 版本。我尝试调整类路径以指定 Rhino 脚本 jar。目前,我已经尝试了以下操作:
<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 的 Rhino 中运行,而不是与 JVM 捆绑的语法。
js.jar 与 ant 脚本位于同一目录中。我还尝试将其重命名为 rhino.jar,因为我认为我已经看到了表明这是必要的文档。
当我运行它时,它给出以下错误:
javax.script.ScriptException: sun.org.mozilla.javascript.EvaluatorException: 语法错误 (#3)
因此,它看起来似乎仍在使用附带的 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>
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 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: syntax error (#3)
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经使用以下 Ant 项目使其工作:
您需要 ./rhino-lib 中的以下 jar:
不是最漂亮的,但它有效。我会多尝试一下,看看是否可以让它与 javax.script 一起工作。
I've got it working using the following Ant project:
You need the following jars in ./rhino-lib:
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 用户邮件列表中的以下响应: http:// /mail-archives.apache.org/mod_mbox/ant-user/201008.mbox/browser
See the following response on the Ant user's mailing list: http://mail-archives.apache.org/mod_mbox/ant-user/201008.mbox/browser