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

Current working directory is used as local repository (instead of ~/.m2/repository) when settings.xml contains empty <localRepository/> element

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0.0-alpha-2, 4.0.0-alpha-3
    • 4.0.0-alpha-5, 4.0.0
    • Settings
    • None
    • Linux x86_64 (Fedora 36)

    Description

      I have tried to build a sample project locally using Maven 4.0.0-alpha-3 and I am seeing one difference / inconsistency with the behavior of empty <localRepository/> tag in settings.xml file, when comparing to Maven 3.8.6.

      My settings.xml file looks like this:

      <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                            http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <localRepository/>
      </settings>
      

      When I run a build with Maven 3.8.6, everything works as I would expect and by default the ~/.m2/repository is chosen.

      However, if I build with Maven 4.0.0-alpha-3, it chooses the current working directory as the root directory for the local repository. So I end-up with directories like aopalliance, avalon-framework, etc., next to the pom.xml.

      If I remove the empty element <localRepository/> from the settings.xml, then ~/.m2/repository is chosen and it works the same as in Maven 3.x.

      I was doing some quick testing and git bisecting and assuming I did not mess anything up, the commit causing this behavior is https://github.com/apache/maven/commit/2a9f39336cec1d8e52d30cc48503d51ed8672536 - MNG-7553 New clean API with immutable model (#703)

      (and it's huge, so I haven't yet looked in detail at the changes).

      I am not 100% sure this is a bug, but it is at least a difference in behavior comparing to Maven 3.x.

       

      Edit: I also tried with -f <path-to-pom.xml>, so the local repository root really is <current-working-dir>, not <project-dir> (even if they are the same usually).

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            psiroky Petr Široký
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: