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

Whitespaces matter in <mirrorOf> configuration can cause the incorrect repo to be selected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.1
    • 3.2.2
    • None
    • None

    Description

      Steps to reproduce the problem:

      1. Use the following settings.xml (replacing the URLs with valid URLs in your environment):
        <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">
        
           <mirrors>
              <mirror>
                 <id>mirror1</id>
                 <url>http://nexus:8081/nexus/content/repositories/releases/</url>
                 <mirrorOf>
                    external:*, !snapshots.repo
                 </mirrorOf>
              </mirror>
           </mirrors>
        
           <profiles>
              <profile>
                 <id>use-snapshots-repo</id>
                 <pluginRepositories>
                    <pluginRepository>
                       <id>snapshots.repo</id>
                       <url>http://nexus:8081/nexus/content/repositories/snapshots/</url>
                    </pluginRepository>
                 </pluginRepositories>
                 <repositories>
                    <repository>
                       <id>snapshots.repo</id>
                       <url>http://nexus:8081/nexus/content/repositories/snapshots/</url>
                    </repository>
                 </repositories>
              </profile>
           </profiles>
        
           <activeProfiles>
              <activeProfile>use-snapshots-repo</activeProfile>
           </activeProfiles>
        
        </settings>
        
      2. Set up a project which uses an artifact from snapshots.repo which is not available in the local Maven repository
      3. Build the project: The build fails because Maven only tries to download from the releases repository.

      Expected behaviour: Maven should have used the snapshots repo.

      The root cause of the problem is that whitespaces around the separators in the mirrorOf configuration are not trimmed. When changing the configuration to

               <mirrorOf>
                  external:*,!snapshots.repo
               </mirrorOf>
      

      the snapshots repository is used and the build passes.

      Attachments

        Activity

          People

            jvanzyl Jason van Zyl
            tobias.oberlies Tobias Oberlies
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: