diff --git a/build.xml b/build.xml
index e2c3c0471a..65824c9ea5 100644
--- a/build.xml
+++ b/build.xml
@@ -181,7 +181,7 @@ END SNIPPET: ant-bootstrap -->
-
+
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index 9adbcfefa7..0b2e4134e3 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -79,9 +79,24 @@
src/main/mdo/metadata.mdo
src/main/mdo/profiles.mdo
src/main/mdo/paramdoc.mdo
- src/main/mdo/settings.mdo
+
+
+ settings
+
+ java
+ xpp3-reader
+ xpp3-writer
+
+
+ 1.1.0
+
+ src/main/mdo/settings.mdo
+
+
+
+
org.apache.maven.plugins
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
index 9cba5f8426..9529f9f214 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
@@ -26,6 +26,7 @@ import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.settings.Mirror;
import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.util.StringUtils;
@Component( role = MirrorSelector.class )
public class DefaultMirrorSelector
@@ -44,7 +45,7 @@ public class DefaultMirrorSelector
{
for ( Mirror mirror : mirrors )
{
- if ( repoId.equals( mirror.getMirrorOf() ) )
+ if ( repoId.equals( mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) )
{
return mirror;
}
@@ -52,7 +53,7 @@ public class DefaultMirrorSelector
for ( Mirror mirror : mirrors )
{
- if ( matchPattern( repository, mirror.getMirrorOf() ) )
+ if ( matchPattern( repository, mirror.getMirrorOf() ) && matchesLayout( repository, mirror ) )
{
return mirror;
}
@@ -139,4 +140,63 @@ public class DefaultMirrorSelector
}
}
+ static boolean matchesLayout( ArtifactRepository repository, Mirror mirror )
+ {
+ return matchesLayout( repository.getLayout().getId(), mirror.getMirrorOfLayouts() );
+ }
+
+ /**
+ * Checks whether the layouts configured for a mirror match with the layout of the repository.
+ *
+ * @param repoLayout The layout of the repository, may be {@code null}.
+ * @param mirrorLayout The layouts supported by the mirror, may be {@code null}.
+ * @return {@code true} if the layouts associated with the mirror match the layout of the original repository,
+ * {@code false} otherwise.
+ */
+ static boolean matchesLayout( String repoLayout, String mirrorLayout )
+ {
+ boolean result = false;
+
+ // simple checks first to short circuit processing below.
+ if ( StringUtils.isEmpty( mirrorLayout ) || WILDCARD.equals( mirrorLayout ) )
+ {
+ result = true;
+ }
+ else if ( mirrorLayout.equals( repoLayout ) )
+ {
+ result = true;
+ }
+ else
+ {
+ // process the list
+ String[] layouts = mirrorLayout.split( "," );
+ for ( String layout : layouts )
+ {
+ // see if this is a negative match
+ if ( layout.length() > 1 && layout.startsWith( "!" ) )
+ {
+ if ( layout.substring( 1 ).equals( repoLayout ) )
+ {
+ // explicitly exclude. Set result and stop processing.
+ result = false;
+ break;
+ }
+ }
+ // check for exact match
+ else if ( layout.equals( repoLayout ) )
+ {
+ result = true;
+ break;
+ }
+ else if ( WILDCARD.equals( layout ) )
+ {
+ result = true;
+ // don't stop processing in case a future segment explicitly excludes this repo
+ }
+ }
+ }
+
+ return result;
+ }
+
}
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
index 06abc9d8a1..62807f20dd 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
@@ -474,6 +474,12 @@ public class LegacyRepositorySystem
{
repository.setId( mirror.getId() );
repository.setUrl( mirror.getUrl() );
+
+ ArtifactRepositoryLayout layout = layouts.get( mirror.getLayout() );
+ if ( layout != null )
+ {
+ repository.setLayout( layout );
+ }
}
}
}
diff --git a/maven-compat/src/main/mdo/settings.mdo b/maven-compat/src/main/mdo/settings.mdo
index eb9e6aa269..031d27ec7b 100644
--- a/maven-compat/src/main/mdo/settings.mdo
+++ b/maven-compat/src/main/mdo/settings.mdo
@@ -46,14 +46,14 @@
TrackableBase
- 1.0.0
+ 1.0.0+
common base class that contains code to track the source for
this instance (USER|GLOBAL)
- 1.0.0
+ 1.0.0+
IdentifiableBase
TrackableBase
- 1.0.0
+ 1.0.0+
Mirror
, Profile
, Proxy
and Server
.
@@ -99,7 +99,7 @@
id
- 1.0.0
+ 1.0.0+
String
default
true
@@ -108,7 +108,7 @@
Settings
- 1.0.0
+ 1.0.0+
TrackableBase
Root element of the user configuration file.
@@ -116,7 +116,7 @@
localRepository
- 1.0.0
+ 1.0.0+
true
interactiveMode
- 1.0.0
+ 1.0.0+
usePluginRegistry
- 1.0.0
+ 1.0.0+
offline
- 1.0.0
+ 1.0.0+
false
proxies
- 1.0.0
+ 1.0.0+
servers
- 1.0.0
+ 1.0.0+
mirrors
- 1.0.0
+ 1.0.0+
Configuration of download mirrors for repositories.
@@ -228,7 +228,7 @@
profiles
- 1.0.0
+ 1.0.0+
activeProfiles
- 1.0.0
+ 1.0.0+
pluginGroups
- 1.0.0
+ 1.0.0+
List of groupIds to search for a plugin when that plugin
groupId is not explicitly provided.
@@ -269,7 +269,7 @@
- 1.0.0
+ 1.0.0+
Proxy
- 1.0.0
+ 1.0.0+
IdentifiableBase
active
- 1.0.0
+ 1.0.0+
false
true
@@ -466,7 +466,7 @@
protocol
- 1.0.0
+ 1.0.0+
username
- 1.0.0
+ 1.0.0+
password
- 1.0.0
+ 1.0.0+
port
- 1.0.0
+ 1.0.0+
host
- 1.0.0
+ 1.0.0+
nonProxyHosts
- 1.0.0
+ 1.0.0+
Server
- 1.0.0
+ 1.0.0+
IdentifiableBase
username
- 1.0.0
+ 1.0.0+
password
- 1.0.0
+ 1.0.0+
privateKey
- 1.0.0
+ 1.0.0+
passphrase
- 1.0.0
+ 1.0.0+
filePermissions
- 1.0.0
+ 1.0.0+
directoryPermissions
- 1.0.0
+ 1.0.0+
Mirror
- 1.0.0
+ 1.0.0+
IdentifiableBase
A download mirror for a given repository.
@@ -620,7 +620,7 @@
mirrorOf
true
- 1.0.0
+ 1.0.0+
String
The server ID of the repository being mirrored, eg
@@ -630,7 +630,7 @@
name
false
- 1.0.0
+ 1.0.0+
String
The optional name that describes the mirror.
@@ -639,25 +639,30 @@
url
true
- 1.0.0
+ 1.0.0+
String
The URL of the mirror repository.
-
+
- 1.0.0
+ 1.0.0+
Profile
- 1.0.0
+ 1.0.0+
IdentifiableBase
activation
- 1.0.0
+ 1.0.0+
repositories
- 1.0.0
+ 1.0.0+
pluginRepositories
- 1.0.0
+ 1.0.0+
Activation
- 1.0.0
+ 1.0.0+
activeByDefault
- 1.0.0
+ 1.0.0+
boolean
Flag specifying whether this profile is active as a default.
@@ -770,7 +775,7 @@
jdk
- 1.0.0
+ 1.0.0+
String
os
- 1.0.0
+ 1.0.0+
property
- 1.0.0
+ 1.0.0+
file
- 1.0.0
+ 1.0.0+
RepositoryBase
- 1.0.0
+ 1.0.0+
id
- 1.0.0
+ 1.0.0+
name
- 1.0.0
+ 1.0.0+
url
- 1.0.0
+ 1.0.0+
layout
- 1.0.0
+ 1.0.0+
The type of layout this repository uses for locating and
storing artifacts - can be "legacy" or "default".
@@ -871,7 +876,7 @@
- 1.0.0
+ 1.0.0+
Repository
RepositoryBase
- 1.0.0
+ 1.0.0+
Repository contains the information needed for establishing
connections with remote repoistory
@@ -907,7 +912,7 @@
releases
- 1.0.0
+ 1.0.0+
How to handle downloading of releases from this repository
@@ -917,7 +922,7 @@
snapshots
- 1.0.0
+ 1.0.0+
How to handle downloading of snapshots from this repository
@@ -929,7 +934,7 @@
- 1.0.0
+ 1.0.0+
RepositoryPolicy
- 1.0.0
+ 1.0.0+
Download policy
enabled
- 1.0.0
+ 1.0.0+
Whether to use this repository for downloading this type of
artifact.
@@ -962,7 +967,7 @@
updatePolicy
- 1.0.0
+ 1.0.0+
The frequency for downloading updates - can be "always",
"daily" (default), "interval:XXX" (in minutes) or "never"
@@ -972,7 +977,7 @@
checksumPolicy
- 1.0.0
+ 1.0.0+
What to do when verification of an artifact checksum fails -
warn, fail, etc. Valid values are "fail" or "warn".
@@ -984,7 +989,7 @@
ActivationProperty
- 1.0.0
+ 1.0.0+
name
- 1.0.0
+ 1.0.0+
String
true
@@ -1004,7 +1009,7 @@
value
- 1.0.0
+ 1.0.0+
String
The value of the property to be used to activate a profile.
@@ -1014,7 +1019,7 @@
ActivationOS
- 1.0.0
+ 1.0.0+
name
- 1.0.0
+ 1.0.0+
String
The name of the OS to be used to activate a profile.
@@ -1032,7 +1037,7 @@
family
- 1.0.0
+ 1.0.0+
String
The general family of the OS to be used to activate a
@@ -1041,7 +1046,7 @@
arch
- 1.0.0
+ 1.0.0+
String
The architecture of the OS to be used to activate a profile.
@@ -1049,7 +1054,7 @@
version
- 1.0.0
+ 1.0.0+
String
The version of the OS to be used to activate a profile.
@@ -1059,7 +1064,7 @@
ActivationFile
- 1.0.0
+ 1.0.0+
missing
- 1.0.0
+ 1.0.0+
String
The name of the file that should be missing to activate a
@@ -1079,7 +1084,7 @@
exists
- 1.0.0
+ 1.0.0+
String
The name of the file that should exist to activate a profile.
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
index bb34c6ca97..296f5fb217 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
@@ -180,6 +180,42 @@ public class MirrorProcessorTest
assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) );
}
+ public void testLayoutPattern()
+ {
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", null ) );
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "" ) );
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "*" ) );
+
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default" ) );
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy" ) );
+
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "legacy,default" ) );
+ assertTrue( DefaultMirrorSelector.matchesLayout( "default", "default,legacy" ) );
+
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "legacy,!default" ) );
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,legacy" ) );
+
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "*,!default" ) );
+ assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,*" ) );
+ }
+
+ public void testMirrorLayoutConsideredForMatching()
+ {
+ ArtifactRepository repo = getRepo( "a" );
+
+ Mirror mirrorA = newMirror( "a", "a", null, "http://a" );
+ Mirror mirrorB = newMirror( "b", "a", "p2", "http://b" );
+
+ Mirror mirrorC = newMirror( "c", "*", null, "http://c" );
+ Mirror mirrorD = newMirror( "d", "*", "p2", "http://d" );
+
+ assertSame( mirrorA, mirrorSelector.getMirror( repo, Arrays.asList( mirrorA ) ) );
+ assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorB ) ) );
+
+ assertSame( mirrorC, mirrorSelector.getMirror( repo, Arrays.asList( mirrorC ) ) );
+ assertNull( mirrorSelector.getMirror( repo, Arrays.asList( mirrorD ) ) );
+ }
+
/**
* Build an ArtifactRepository object.
*
@@ -204,11 +240,17 @@ public class MirrorProcessorTest
}
private Mirror newMirror( String id, String mirrorOf, String url )
+ {
+ return newMirror( id, mirrorOf, null, url );
+ }
+
+ private Mirror newMirror( String id, String mirrorOf, String layouts, String url )
{
Mirror mirror = new Mirror();
mirror.setId( id );
mirror.setMirrorOf( mirrorOf );
+ mirror.setMirrorOfLayouts( layouts );
mirror.setUrl( url );
return mirror;