[ http://jira.codehaus.org/browse/MNG-2127?page=comments#action_60505 ] 

Dan Fabulich commented on MNG-2127:
-----------------------------------

Wow... I'm definitely surprised to see that ant.bat suffers from this same 
problem.  Let that teach me a valuable lesson.  :-)

I'm definitely surprised to hear that we don't support Win9x, because there's a 
bunch of code in this batch script designed to handle Win9x, including a batch 
label called :Win9xApp, which only triggers when %OS% is not equal to 
Windows_NT, which is always true on Windows_NT, Windows 2000, Windows XP, and 
Windows 2003.  Is any of that code necessary?

Anyway, using the current latest mvn.bat from SVN (384215) helps quite a bit.
http://svn.apache.org/viewcvs.cgi/maven/components/trunk/maven-core/src/bin/mvn.bat?rev=384215&view=markup

With that said, on line 154, it says "exit /b %ERROR_CODE%".  This breaks on 
Windows NT... the batch script always returns 1, because that's an invalid 
command on NT.  Does Maven support Windows NT?

Interestingly, since the latest SVN mvn.bat uses exit /b, but includes the "if 
errorlevel 1 goto error" fix, it works properly in Ant on Windows 2003 even 
without the MAVEN_TERMINATE_CMD environment variable.  Here's my test, which 
works on Windows 2003, but not on Windows XP:

<property name="maven.executable" location="mvnfixed.bat" />
<exec executable="${maven.executable}" failonerror="false" resultproperty="x">
</exec>
<echo message="x = ${x}" />
<condition property="should.have.failed">
        <equals arg1="0" arg2="${x}" />
</condition>
<fail if="should.have.failed" message="should have failed"/>
<exec executable="${maven.executable}" failonerror="true">
        <arg value="--help" />
</exec>

Anyway, I think I can live with this.

> mvn.bat always exits 0 on Windows 2000 and higher
> -------------------------------------------------
>
>          Key: MNG-2127
>          URL: http://jira.codehaus.org/browse/MNG-2127
>      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" marker.)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to