maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brett Porter (JIRA)" <>
Subject [jira] Closed: (MNG-2127) mvn.bat always exits 0 on Windows 2000 and higher
Date Wed, 08 Mar 2006 13:12:23 GMT
     [ ]
Brett Porter closed MNG-2127:

     Resolution: Won't Fix
    Fix Version:     (was: 2.0.3)

this is a misunderstanding. I'm assuming you tested your fix by checking if errorlevel 1 echo

the missing if errorlevel 1 was already added to svn, and I've fixed the location of the original
setting of ERROR_CODE. Not using ERROR_CODE still works, setting the errorlevel correctly,
but should the script change to have an intervening command that resets it this would be lost
so it is good to keep, plus it allows returning "1" for the failure to set JAVA_HOME, etc.

Emmanuel was entirely correct, and you'll find running the new script inside Ant still succeeds,
as does running Ant inside Ant. The reason for this is that batch files are called like this:
cmd /c mvn.bat

The exit code of mvn.bat is swallowed by cmd.exe. However, if you use the "exit" command,
cmd.exe is terminated with the correct exit code. There doesn't appear to be any alternative
to this at this point. I'll keep looking.

I test this on both XP SP2 and XP SP1a. We don't support Win9x.

> mvn.bat always exits 0 on Windows 2000 and higher
> -------------------------------------------------
>          Key: MNG-2127
>          URL:
>      Project: Maven 2
>         Type: Bug

>   Components: Command Line
>     Versions: 2.0, 2.0.1, 2.0.2
>  Environment: I'm on Windows 2003 Server, but this will affect any OS for which the %OS%
environment variable is Windows_NT, including Windows XP and Windows 2000.
>     Reporter: Dan Fabulich
>     Assignee: Brett Porter
>     Priority: Blocker
>  Attachments: mvnfixed.bat, mvnfixed.bat
> Write the following ant script and run it on Windows 2000 or higher:  <project default="main"><target
 name="main"><exec executable="mvn.bat" failonerror="true" /></target></project>
> This will run "mvn" with no arguments, which will always fail.  But the ant script will
claim "build successful", because the exit value of mvn.bat was 0.  It is absolutely critical
that this work correctly, or else I can't integrate Maven into any other automated system.
> This is happening because mvn.bat is improperly abusing local scoping.  On line 130 of
mvn.bat, we execute maven, but we don't do anything with its exit value... we just always
goto end.  The fix for this is to add a line 131 that says "if errorlevel 1 goto error", which
will behave correctly.
> (I marked this as having a test case because I've included a test ant script, but technically
this isn't a JUnit test case, so it may be an inappropriate use of the "testcase included"

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message