Maven 2 & 3

incorrect M2_HOME guess in mvn.bat

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.2
  • Fix Version/s: 2.0.9, 3.0-alpha-1
  • Component/s: Bootstrap & Build
  • Labels:
    None
  • Environment:
    WXP
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

mvn.bat contains the following lines:

:chkMHome
if not "%M2_HOME%"=="" goto valMHome

if "%OS%"=="Windows_NT" SET M2_HOME=%~dps0\..
if not "%M2_HOME%"=="" goto valMHome

Guessing M2_HOME=%~dps0\.. leads to complaints later on, since the script expects m2.bat in bin/...:

if exist "%M2_HOME%\bin\m2.bat" goto init

Hence, the line should read:

if "%OS%"=="Windows_NT" SET M2_HOME=%~dps0\..\..

Issue Links

Activity

Hide
Thai Ha added a comment -

I believe that this issue should be fixed as below:

if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0..

This fix should be applied to Maven 2.0.3 too because Maven 2.0.3 is using (%~dp0\..) and the slash is redundant.

Note:
If you have Ant 1.6.5, you can open ant.bat and see (line 25) set DEFAULT_ANT_HOME=%~dp0..

Show
Thai Ha added a comment - I believe that this issue should be fixed as below: if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0.. This fix should be applied to Maven 2.0.3 too because Maven 2.0.3 is using (%~dp0\..) and the slash is redundant. Note: If you have Ant 1.6.5, you can open ant.bat and see (line 25) set DEFAULT_ANT_HOME=%~dp0..
Hide
Alexander Veit added a comment -

if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0.. seems to be correct.

This bug is probably more severe than it might seem, since child processes inherit the malformed path.

Show
Alexander Veit added a comment - if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0.. seems to be correct. This bug is probably more severe than it might seem, since child processes inherit the malformed path.
Hide
John Casey added a comment -

I can't actually test this fix, so if someone finds that it's still not working, reopen this.

Show
John Casey added a comment - I can't actually test this fix, so if someone finds that it's still not working, reopen this.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: