How to run perl and ruby ​​scripts as tasks in ant?

I would like to be able to run ruby ​​and perl scripts from build.xml in ant.

+3
source share
2 answers

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

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

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 ​​that support the JSR233 standard .

Unfortunately, there is no Java Perl version for Java. The only way to run Perl scripts is to access the interpreter directly:

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

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


All Articles