Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-8315

Failure of mvn.cmd if a .mvn directory is located at drive root

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.9.9
    • 3.9.10, 4.0.0-beta-5
    • Command Line
    • Windows 10

    Description

      When .mvn is located on filesystem root, on Windows, the command line created (in mvn.cmd) to run java fails.
      This is because the part concerning multiModuleProjectDirectory ends with a slash before the double quote which certainly means escaping and it messes the whole command. Example for drive o: :

      "-Dmaven.multiModuleProjectDirectory=o:\"

      In this case, java.exe displays its usage help as it thinks the command is wrong.

      The workaround is to add an additional escaping backslash:

      "-Dmaven.multiModuleProjectDirectory=o:\\"

      Note: this only happens in case there is a .mvn at root.

       

      This simple line added just before calling "%JAVACMD%" seems to do the job:

      if "%MAVEN_PROJECTBASEDIR:~-1%"=="\" set "MAVEN_PROJECTBASEDIR=%MAVEN_PROJECTBASEDIR%\"

      A workaround for users facing the problem is to define MAVEN_BASEDIR to the drive root with 2 backslash before running Maven:

      set MAVEN_BASEDIR=%tempDriveLetter%:\\

       

       

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            fmarot Francois MAROT
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: