3
我希望能够从ant中的build.xml运行ruby和perl脚本。如何在ant中运行perl和ruby脚本作为任务?
我希望能够从ant中的build.xml运行ruby和perl脚本。如何在ant中运行perl和ruby脚本作为任务?
您可以随时使用ant的exec任务来运行任意程序,例如ruby和perl。例如,从文档:
<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="ant.bat"/>
<arg value="-p"/>
</exec>
</target>
像Ruby这样的语言有Java实现。
<project name="RunRubyExample">
<property environment="env" />
<script language="ruby" manager="bsf">
<classpath>
<fileset dir="${env.JRUBY_HOME}/lib" includes="*.jar" />
</classpath>
print 'hello world'
</script>
</project>
请参阅list of languages supporting the JSR233 standard。
不幸的是没有Java版本的Perl可用。运行Perl脚本的唯一方法是直接调用解释器:
<project name="RunPerlExample">
<exec executable="perl" failonerror="true">
<arg value="-e" />
<arg value="print 'hello world'" />
</exec>
</project>
我完全不知道'
您到目前为止尝试过了什么?你有关于Ant文档的具体问题吗? – Ether 2010-08-20 21:26:12