You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Xavier Galleri <xa...@calyon.com> on 2006/02/10 11:37:57 UTC

Calling mvn from ant does not propagate errors

Hi,

I need to call mvn from ant and I tried to do that as follows:

    <exec executable="mvn.bat" failonerror="true">
      <arg line="install"/>
    </exec>

The problem is that the "failonerror" is not working when mvn fails. I'm
working under Windows XP.

After some investigations, I came to the conclusion that the errorlevel is
not correctly propagated back to ant when it execs the mvn.bat script.

To cope with that issue, I currently use a workaround, but it implies to
modify the "mvn.bat" script in order to:
  - trap errors slightly differently,
  - remove the /B from the final exit command.

Then, I renamed the modified "mvn.bat" file to "mvn-batch.bat" and create a
new "mvn.bat" file to do the following:

    @echo off
    cmd /c "mvn-batch.bat %*"

Eventually, I use the "mvn-batch.bat" file in my "exec" task:

    <exec executable="mvn-batch.bat" failonerror="true"/>

This way, the failonerror is working ok and ant failed as expected when mvn
fails!

To say the less, I'm a bit disappointed by the complexity of this solution!
Thus I would be pleased to get any feedback on this, especially if someone
could provide a better solution.

Any comments are welcome...

Rgds,
-Xavier 

Re: Calling mvn from ant does not propagate errors

Posted by Daniel Kulp <da...@iona.com>.
> Good to hear that you've made it work.  But then, I'm just curious as
> to why you have to invoke Maven using Ant in the first place. :)

Using cruisecontrol is one reason.   Cruisecontrol calls ant which forks 
maven.  In that case, you definitely want to know if Maven failed so you 
can get cruisecontrol to report the failure properly.

Don't bother mentioning continuum.  It's not usable (yet, give them time) 
for a lot of people.  

Enjoy!
-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727  C: 508-380-7194
daniel.kulp@iona.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Calling mvn from ant does not propagate errors

Posted by Napoleon Esmundo Ramirez <nr...@gmail.com>.
Hello,

Good to hear that you've made it work.  But then, I'm just curious as to why
you have to invoke Maven using Ant in the first place. :)

Cheers!
Nap

On 2/10/06, Xavier Galleri <xa...@calyon.com> wrote:
>
> Hi,
>
> I need to call mvn from ant and I tried to do that as follows:
>
>     <exec executable="mvn.bat" failonerror="true">
>       <arg line="install"/>
>     </exec>
>
> The problem is that the "failonerror" is not working when mvn fails. I'm
> working under Windows XP.
>
> After some investigations, I came to the conclusion that the errorlevel is
> not correctly propagated back to ant when it execs the mvn.bat script.
>
> To cope with that issue, I currently use a workaround, but it implies to
> modify the "mvn.bat" script in order to:
>   - trap errors slightly differently,
>   - remove the /B from the final exit command.
>
> Then, I renamed the modified "mvn.bat" file to "mvn-batch.bat" and create
> a new "mvn.bat" file to do the following:
>
>     @echo off
>     cmd /c "mvn-batch.bat %*"
>
> Eventually, I use the "mvn-batch.bat" file in my "exec" task:
>
>     <exec executable="mvn-batch.bat" failonerror="true"/>
>
> This way, the failonerror is working ok and ant failed as expected when
> mvn fails!
>
> To say the less, I'm a bit disappointed by the complexity of this
> solution! Thus I would be pleased to get any feedback on this, especially if
> someone could provide a better solution.
>
> Any comments are welcome...
>
> Rgds,
> -Xavier
>
> Ce message et ses pièces jointes (le "message") est destiné à l'usage
> exclusif de son destinataire.
> Si vous recevez ce message par erreur, merci d'en aviser immédiatement
> l'expéditeur  et de le détruire ensuite. Le présent message  pouvant
> être altéré à notre insu,  CALYON Corporate and Investment Bank
> ne peut pas être engagé par son contenu. Tous droits réservés.
>
> This message and/or any  attachments (the "message") is intended for
> the sole use of its addressee.
> If you are not the addressee, please immediately notify the sender and
> then destroy the message.  As this message and/or any attachments may
> have been altered without our knowledge,  its content  is not legally
> binding on CALYON Corporate and Investment Bank. All rights reserved.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>