emailantbuildautomated-deployautomated-deployment

How do you call another ant target with parameters (-logger org.apache.tools.ant.listener.MailLogger) from another ant script?


I have a main ant script, that is used to initiate multiple project's ant script, in a certain sequence.

For each sub-project, I would like to to send out an email, notifying me whether the build was successful or not.

I understand that I can use the flag -logger with org.apache.tools.ant.listener.MailLogger to send out an email after the build finishes.

However, if I have multiple scripts that I want to send out an email, I'm not sure how to pass that flag -logger org.apache.tools.ant.listener.MailLogger into the ant call.

Precisely, I would like to pass the logger flag into this ant call:

< ant antfile="build.xml" dir="subproject/build" target="build" />

I tried using param and args, but didn't succeed.


Solution

  • Good question. Personally I could not make it work with the ant target. It seems flags are not supported.

    However, this hack works.

    <exec executable="ant.bat">
        <arg value="-logger"/>
        <arg value="org.apache.tools.ant.listener.MailLogger"/>
        <arg value="-f"/>
        <arg value="other_build.xml"/>
    </exec>
    

    Two immediate issues with this approach:

    1. Not platform independent.
    2. Build reports success when sub-build fails (even with exec's failonerror='true')