Search code examples
antnant

Calling Ant from Nant without batch


We have an automated build process that uses Nant scripts, and we just inherited a Java project that has an existing, working Ant script. I have searched all over and it seems most people use a batch file to call Ant scripts from Nant. This seems a little hacky to me. Is there a way to call Ant scripts directly from Nant in task format?

This similar question addresses it with a batch file but I want to do it without.


Solution

  • <!-- calling the Ant build Process-->
        <target name="AntBuildProcess" description="Created to call the Ant build during this NAnt build process" >
            <echo message="Starting the Ant Build Process..." />
            <exec program="ant" commandline='-buildfile YourAntBuild.xml' failonerror="true"/>
        </target>
    

    Then during your Build process, you just call this target at the point you need it to be built. <call target="AntBuildProcess" />