How to run a Nant task with Ant?

2019-03-02 17:23发布

问题:

I am looking to do something that seems feasible, but searches on Google do not return something as precise as what I need.

We inherited Nant scripts from a previous company that localizes websites. They work great.

We have our own Ant scripts that compare two SVN repositories and then merge them. We would like to call the Nant script while the Ant scripts are run.

Anybody can provide some guidance as of how to do that? We are not looking to rewrite the Nant script in Ant, so please avoid that suggestion.

Thanks!

回答1:

You call put your ant scripts in a batch file (ant_tasks.bat) and then execute it from nant using exec.
Something like that:

<target name="run-command">
   <exec program="ant_tasks.bat" basedir="${test.dir}">
     <arg value="${args}" />
   </exec>
 </target>

Docs

Or you can put your nant scripts in a batch file and then execute it from ant using exec.

Example:

<existing ant task>

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

<another existing ant task>

Docs