简体   繁体   中英

How can I run perl and ruby scripts as tasks in ant?

我希望能够从ant中的build.xml运行ruby和perl脚本。

Languages like Ruby have Java implementations.

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

See the list of languages supporting the JSR233 standard .

Unfortunately no Java version of Perl is available. The only way to run Perl scripts is to invoke the interpreter directly:

<project name="RunPerlExample">
    <exec executable="perl" failonerror="true">
        <arg value="-e" />
        <arg value="print 'hello world'" />
    </exec>
</project>

You can always use the ant`s exec task to run arbitrary programs, such as ruby and perl. For example and from the docs:

<target name="help">
  <exec executable="cmd">
    <arg value="/c"/>
    <arg value="ant.bat"/>
    <arg value="-p"/>
  </exec>
</target>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM