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

Empty but existing <localRepository/> in settings.xml defaulting to current working directory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0-beta-4
    • 4.0.0-beta-5
    • Core, Settings
    • None

    Description

      If a ~/.m2/settings.xml with an empty <localRepository/> element exists in Maven 4, it downloads dependencies to the current working directory as opposed to ~/.m2/repository.

      Steps to reproduce:

      • Create a settings.xml with the exact content from the settings.xml in the quick overview. The important part is the empty <localRepository/>.
      • Run mvn verify or similar
      • Observe it downloading dependencies to the current repository as opposed to ~/.m2/repository

      Full reproducer using GitHub Actions: https://github.com/danthe1st/maven-repro/tree/wrong-local-repo
      build log with Maven 4 (actual result): https://github.com/danthe1st/maven-repro/actions/runs/11343337296/job/31545681467

      The output of mvn verify -X includes:

      [DEBUG] Using local repository at /home/runner/work/maven-repro/maven-repro 

      Files after mvn verify with Maven 4 (the maven.tar.gz and apache-maven-4.0.0-beta-4 directories aren't created from mvn verify):

      Run ls
      aopalliance
      apache-maven-4.0.0-beta-4
      com
      commons-codec
      commons-io
      javax
      maven.tar.gz
      net
      org
      pom.xml
      settings.template.xml
      src
      target
      

      build log with Maven 3 (expected result): https://github.com/danthe1st/maven-repro/actions/runs/11343337296/job/31545681854

      The output of mvn verify -X includes:

      [DEBUG] Using local repository at /home/runner/.m2/repository 

      Files after mvn verify with Maven 3:

      Run ls
      pom.xml
      settings.template.xml
      src
      target
      

      Attachments

        1. job_logs_mvn4.txt
          346 kB
          Daniel Schmid
        2. job_logs_mvn3.txt
          593 kB
          Daniel Schmid
        3. settings.template.xml
          0.4 kB
          Daniel Schmid

        Activity

          People

            cstamas Tamas Cservenak
            dan1st Daniel Schmid
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: