Maven 1
  1. Maven 1
  2. MAVEN-666

maven.bat dosen't work when JAVA_HOME or MAVEN_HOME contains space character

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0-beta-10
    • Fix Version/s: 1.0-rc1
    • Component/s: core
    • Labels:
      None
    • Environment:
      OS : Windows 2003 Server
    • Number of attachments :
      0

      Description

      It's normal to use some space characters at file name or directory name these days,

      But maven won't support it in the maven.bat script.

      here is how to reproduce

      0. Windows 2003 Server, run cmd.exe and enter follows
      1. set JAVA_HOME=C:\Program Files\Java\JDK\
      2. set MAVEN_HOME=C:\Some Directory Name That Has A Space Character\Maven\
      3. set PATH=%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%PATH%
      4. set MAVEN_BATCH_ECHO=on
      5. maven.bat

      and here is the generated error when I run with space containing MAVEN_HOME

      C:\Documents and Settings\HeartBit>maven

      C:\Documents and Settings\HeartBit>if exist "\mavenrc_pre.bat" call "\mavenrc_pr
      e.bat"

      C:\Documents and Settings\HeartBit>if "Windows_NT" == "Windows_NT"

      C:\Documents and Settings\HeartBit>set MAVEN_COMMAND_COM="cmd.exe"

      C:\Documents and Settings\HeartBit>if exist "C:\WINDOWS\system32\cmd.exe" set MA
      VEN_COMMAND_COM="C:\WINDOWS\system32\cmd.exe"

      C:\Documents and Settings\HeartBit>if exist "C:\WINDOWS\command.com" set MAVEN_C
      OMMAND_COM="C:\WINDOWS\command.com"

      C:\Documents and Settings\HeartBit>set MAVEN_FIND_EXE="find.exe"

      C:\Documents and Settings\HeartBit>if exist "C:\WINDOWS\system32\find.exe" set M
      AVEN_FIND_EXE="C:\WINDOWS\system32\find.exe"

      C:\Documents and Settings\HeartBit>if exist "C:\WINDOWS\command\find.exe" set MA
      VEN_FIND_EXE="C:\WINDOWS\command\find.exe"

      C:\Documents and Settings\HeartBit>if not "C:\Progra~1\Java\j2re1.4.2" == "" got
      o OkJHome

      C:\Documents and Settings\HeartBit>"C:\WINDOWS\system32\cmd.exe" /C DIR "C:\Prog
      ra~1\Java\j2re1.4.2" 2>&1 | "C:\WINDOWS\system32\find.exe" /I /C "C:\Progra~1
      \Java\j2re1.4.2" 1>nul

      C:\Documents and Settings\HeartBit>if not errorlevel 1 goto chkMHome
      and was unexpected at this time.

      C:\Documents and Settings\HeartBit>if not ""C:\Documents and Settings\HeartBit\M
      y Documents\My Program Files\maven""=="" goto valMHome

      C:\Documents and Settings\HeartBit>

        Activity

        Hide
        dion gillard added a comment -

        The sample given wasn't using an actual directory for MAVEN_HOME, as it was a quoted value, that's simply wrong.

        I'll test the tilde'd version

        Show
        dion gillard added a comment - The sample given wasn't using an actual directory for MAVEN_HOME, as it was a quoted value, that's simply wrong. I'll test the tilde'd version
        Hide
        dion gillard added a comment -

        Maven home with '~' in the name does work. Here's output:

        C:\source\maven>maven clean

        C:\source\maven>if exist "\mavenrc_pre.bat" call "\mavenrc_pre.bat"

        C:\source\maven>if "Windows_NT" == "Windows_NT"

        C:\source\maven>set MAVEN_COMMAND_COM="cmd.exe"

        C:\source\maven>if exist "C:\WINDOWS\system32\cmd.exe" set MAVEN_COMMAND_COM="C:
        \WINDOWS\system32\cmd.exe"

        C:\source\maven>if exist "C:\WINDOWS\command.com" set MAVEN_COMMAND_COM="C:\WIND
        OWS\command.com"

        C:\source\maven>set MAVEN_FIND_EXE="find.exe"

        C:\source\maven>if exist "C:\WINDOWS\system32\find.exe" set MAVEN_FIND_EXE="C:\W
        INDOWS\system32\find.exe"

        C:\source\maven>if exist "C:\WINDOWS\command\find.exe" set MAVEN_FIND_EXE="C:\WI
        NDOWS\command\find.exe"

        C:\source\maven>if not "c:\j2sdk1.4.2" == "" goto OkJHome

        C:\source\maven>"C:\WINDOWS\system32\cmd.exe" /C DIR "c:\j2sdk1.4.2" 2>&1 | "
        C:\WINDOWS\system32\find.exe" /I /C "c:\j2sdk1.4.2" 1>nul

        C:\source\maven>if not errorlevel 1 goto chkMHome

        C:\source\maven>if not "c:\progra~1\maven" == "" goto valMHome

        C:\source\maven>"C:\WINDOWS\system32\cmd.exe" /C DIR "c:\progra~1\maven" 2>&1

        "C:\WINDOWS\system32\find.exe" /I /C "c:\progra~1\maven" 1>nul

        C:\source\maven>if not errorlevel 1 goto init

        C:\source\maven>if NOT "Windows_NT" == "Windows_NT" goto Win9xArg

        C:\source\maven>if "eval[2+2]" == "4" goto 4NTArgs

        C:\source\maven>set MAVEN_CMD_LINE_ARGS="-Dmaven.home.local=C:\Documents and Set
        tings\dion/.maven" clean

        C:\source\maven>goto endInit

        C:\source\maven>if "" == "" SET MAVEN_OPTS="-Xmx160m"

        C:\source\maven>SET MAVEN_JAVA_EXE="c:\j2sdk1.4.2\bin\java.exe"

        C:\source\maven>SET MAVEN_CLASSPATH="c:\progra~1\maven\lib\forehead-1.0-beta-4.j
        ar"

        C:\source\maven>SET MAVEN_MAIN_CLASS="com.werken.forehead.Forehead"

        C:\source\maven>SET MAVEN_ENDORSED="-Djava.endorsed.dirs=c:\j2sdk1.4.2\lib\endor
        sed;c:\progra~1\maven\lib\endorsed"

        C:\source\maven>if not "C:\Documents and Settings\dion/.maven" == "" goto StartM
        HL

        C:\source\maven>"c:\j2sdk1.4.2\bin\java.exe" -Djavax.xml.parsers.DocumentBuilder
        Factory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SA
        XParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl "-Dmaven.home=c:\prog
        ra~1\maven" "-Dmaven.home.local=C:\Documents and Settings\dion/.maven" "-Dtools.
        jar=c:\j2sdk1.4.2\lib\tools.jar" "-Dforehead.conf.file=c:\progra~1\maven\bin\for
        ehead.conf" "-Djava.endorsed.dirs=c:\j2sdk1.4.2\lib\endorsed;c:\progra~1\maven\l
        ib\endorsed" "-Xmx160m" -classpath "c:\progra~1\maven\lib\forehead-1.0-beta-4.ja
        r" "com.werken.forehead.Forehead" "-Dmaven.home.local=C:\Documents and Settings\
        dion/.maven" clean

        Show
        dion gillard added a comment - Maven home with '~' in the name does work. Here's output: C:\source\maven>maven clean C:\source\maven>if exist "\mavenrc_pre.bat" call "\mavenrc_pre.bat" C:\source\maven>if "Windows_NT" == "Windows_NT" C:\source\maven>set MAVEN_COMMAND_COM="cmd.exe" C:\source\maven>if exist "C:\WINDOWS\system32\cmd.exe" set MAVEN_COMMAND_COM="C: \WINDOWS\system32\cmd.exe" C:\source\maven>if exist "C:\WINDOWS\command.com" set MAVEN_COMMAND_COM="C:\WIND OWS\command.com" C:\source\maven>set MAVEN_FIND_EXE="find.exe" C:\source\maven>if exist "C:\WINDOWS\system32\find.exe" set MAVEN_FIND_EXE="C:\W INDOWS\system32\find.exe" C:\source\maven>if exist "C:\WINDOWS\command\find.exe" set MAVEN_FIND_EXE="C:\WI NDOWS\command\find.exe" C:\source\maven>if not "c:\j2sdk1.4.2" == "" goto OkJHome C:\source\maven>"C:\WINDOWS\system32\cmd.exe" /C DIR "c:\j2sdk1.4.2" 2>&1 | " C:\WINDOWS\system32\find.exe" /I /C "c:\j2sdk1.4.2" 1>nul C:\source\maven>if not errorlevel 1 goto chkMHome C:\source\maven>if not "c:\progra~1\maven" == "" goto valMHome C:\source\maven>"C:\WINDOWS\system32\cmd.exe" /C DIR "c:\progra~1\maven" 2>&1 "C:\WINDOWS\system32\find.exe" /I /C "c:\progra~1\maven" 1>nul C:\source\maven>if not errorlevel 1 goto init C:\source\maven>if NOT "Windows_NT" == "Windows_NT" goto Win9xArg C:\source\maven>if "eval [2+2] " == "4" goto 4NTArgs C:\source\maven>set MAVEN_CMD_LINE_ARGS="-Dmaven.home.local=C:\Documents and Set tings\dion/.maven" clean C:\source\maven>goto endInit C:\source\maven>if "" == "" SET MAVEN_OPTS="-Xmx160m" C:\source\maven>SET MAVEN_JAVA_EXE="c:\j2sdk1.4.2\bin\java.exe" C:\source\maven>SET MAVEN_CLASSPATH="c:\progra~1\maven\lib\forehead-1.0-beta-4.j ar" C:\source\maven>SET MAVEN_MAIN_CLASS="com.werken.forehead.Forehead" C:\source\maven>SET MAVEN_ENDORSED="-Djava.endorsed.dirs=c:\j2sdk1.4.2\lib\endor sed;c:\progra~1\maven\lib\endorsed" C:\source\maven>if not "C:\Documents and Settings\dion/.maven" == "" goto StartM HL C:\source\maven>"c:\j2sdk1.4.2\bin\java.exe" -Djavax.xml.parsers.DocumentBuilder Factory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SA XParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl "-Dmaven.home=c:\prog ra~1\maven" "-Dmaven.home.local=C:\Documents and Settings\dion/.maven" "-Dtools. jar=c:\j2sdk1.4.2\lib\tools.jar" "-Dforehead.conf.file=c:\progra~1\maven\bin\for ehead.conf" "-Djava.endorsed.dirs=c:\j2sdk1.4.2\lib\endorsed;c:\progra~1\maven\l ib\endorsed" "-Xmx160m" -classpath "c:\progra~1\maven\lib\forehead-1.0-beta-4.ja r" "com.werken.forehead.Forehead" "-Dmaven.home.local=C:\Documents and Settings\ dion/.maven" clean
        Hide
        dion gillard added a comment -

        Bdaly specified files, such as those with quotes in them, that aren't really part of the file name, are the users problem, and maven is right to fail if someone has given it a bogus home.

        Show
        dion gillard added a comment - Bdaly specified files, such as those with quotes in them, that aren't really part of the file name, are the users problem, and maven is right to fail if someone has given it a bogus home.
        Hide
        Marcin S. added a comment -

        The problem is not in spaces or tildes. The problem occurs when you have MAVEN_HOME finished by "\". Remove trailing slash from MAVEN_HOME and maven should work.

        The same problems occurs in ant.

        Show
        Marcin S. added a comment - The problem is not in spaces or tildes. The problem occurs when you have MAVEN_HOME finished by "\". Remove trailing slash from MAVEN_HOME and maven should work. The same problems occurs in ant.
        Hide
        Adam Monsen added a comment -

        Actually, I think the problem might be double-quoting the value of JAVA_HOME.

        set JAVA_HOME="C:\Program Files\Java\jdk1.6.0_20"
        

        doesn't work for me, but this does:

        set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20
        
        Show
        Adam Monsen added a comment - Actually, I think the problem might be double-quoting the value of JAVA_HOME . set JAVA_HOME= "C:\Program Files\Java\jdk1.6.0_20" doesn't work for me, but this does: set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20

          People

          • Assignee:
            Unassigned
            Reporter:
            Uijin Hong
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: