diff --git a/maven-repository-mercury/pom.xml b/maven-repository-mercury/pom.xml
new file mode 100644
index 0000000000..a10d60a9b6
--- /dev/null
+++ b/maven-repository-mercury/pom.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+ maven
+ org.apache.maven
+ 3.0-SNAPSHOT
+
+ 4.0.0
+ maven-repository-mercury
+ Mercury Repository
+ Mercury implementation for the Maven Repository System
+
+
+ 1.0-alpha-6-SNAPSHOT
+ 1.1
+
+
+
+
+
+ org.apache.maven
+ maven-repository
+
+
+
+ org.codehaus.plexus
+ plexus-utils
+
+
+
+ org.codehaus.plexus
+ plexus-container-default
+
+
+
+ org.apache.maven.mercury
+ mercury-plexus
+ ${mercury.version}
+
+
+
+ org.apache.maven.mercury
+ mercury-repo-remote-m2
+ ${mercury.version}
+
+
+
+ org.codehaus.plexus
+ plexus-lang
+ ${plexus.lang.version}
+
+
+
+
+
+
+ org.codehaus.plexus
+ plexus-component-metadata
+
+
+
+
diff --git a/maven-repository-mercury/src/main/java/org/apache/maven/repository/mercury/MercuryAdaptor.java b/maven-repository-mercury/src/main/java/org/apache/maven/repository/mercury/MercuryAdaptor.java
new file mode 100644
index 0000000000..4f27ef5480
--- /dev/null
+++ b/maven-repository-mercury/src/main/java/org/apache/maven/repository/mercury/MercuryAdaptor.java
@@ -0,0 +1,124 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+ */
+
+package org.apache.maven.repository.mercury;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.builder.api.DependencyProcessor;
+import org.apache.maven.mercury.repository.api.Repository;
+import org.apache.maven.mercury.repository.local.m2.LocalRepositoryM2;
+import org.apache.maven.mercury.repository.remote.m2.RemoteRepositoryM2;
+import org.apache.maven.mercury.transport.api.Server;
+import org.apache.maven.mercury.util.Util;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class MercuryAdaptor
+{
+ public static List toMercuryRepos( ArtifactRepository localRepository,
+ List remoteRepositories,
+ DependencyProcessor dependencyProcessor )
+ {
+ if ( localRepository == null && Util.isEmpty( remoteRepositories ) )
+ return null;
+
+ int nRepos =
+ ( localRepository == null ? 0 : 1 ) + ( Util.isEmpty( remoteRepositories ) ? 0 : remoteRepositories.size() );
+
+ List res = new ArrayList( nRepos );
+
+ if ( localRepository != null )
+ {
+ LocalRepositoryM2 lr =
+ new LocalRepositoryM2( localRepository.getId(), new File( localRepository.getBasedir() ),
+ dependencyProcessor );
+ res.add( lr );
+ }
+
+ if ( !Util.isEmpty( remoteRepositories ) )
+ {
+ for ( ArtifactRepository ar : remoteRepositories )
+ {
+ Server server;
+ try
+ {
+ server = new Server( ar.getId(), new URL( ar.getUrl() ) );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new IllegalArgumentException( e );
+ }
+ RemoteRepositoryM2 rr = new RemoteRepositoryM2( server, dependencyProcessor );
+
+ res.add( rr );
+ }
+ }
+
+ return res;
+ }
+
+ public static ArtifactBasicMetadata toBasicMetadata( Artifact a )
+ {
+ ArtifactBasicMetadata md = new ArtifactBasicMetadata();
+ md.setGroupId( a.getGroupId() );
+ md.setArtifactId( a.getArtifactId() );
+ md.setVersion( a.getVersion() );
+ md.setType( a.getType() );
+ md.setScope( a.getScope() );
+
+ return md;
+ }
+
+ public static ArtifactMetadata toMetadata( Artifact a )
+ {
+ ArtifactMetadata md = new ArtifactMetadata();
+ md.setGroupId( a.getGroupId() );
+ md.setArtifactId( a.getArtifactId() );
+ md.setVersion( a.getVersion() );
+ md.setType( a.getType() );
+ md.setScope( a.getScope() );
+
+ return md;
+ }
+
+ public static Artifact toMavenArtifact( org.apache.maven.mercury.artifact.Artifact a )
+ {
+ VersionRange vr = VersionRange.createFromVersion( a.getVersion() );
+ Artifact ma =
+ new DefaultArtifact( a.getGroupId(), a.getArtifactId(), vr, a.getScope(), a.getType(), a.getClassifier(),
+ null );
+
+ return ma;
+ }
+
+}
diff --git a/maven-repository-mercury/src/main/java/org/apache/maven/repository/mercury/MercuryRepositorySystem.java b/maven-repository-mercury/src/main/java/org/apache/maven/repository/mercury/MercuryRepositorySystem.java
new file mode 100644
index 0000000000..bad827f1ba
--- /dev/null
+++ b/maven-repository-mercury/src/main/java/org/apache/maven/repository/mercury/MercuryRepositorySystem.java
@@ -0,0 +1,113 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+ */
+
+package org.apache.maven.repository.mercury;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.metadata.ResolutionGroup;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.mercury.artifact.ArtifactMetadata;
+import org.apache.maven.mercury.builder.api.DependencyProcessor;
+import org.apache.maven.mercury.plexus.PlexusMercury;
+import org.apache.maven.mercury.repository.api.Repository;
+import org.apache.maven.mercury.repository.api.RepositoryException;
+import org.apache.maven.mercury.repository.local.m2.LocalRepositoryM2;
+import org.apache.maven.mercury.repository.remote.m2.RemoteRepositoryM2;
+import org.apache.maven.mercury.transport.api.Server;
+import org.apache.maven.mercury.util.Util;
+import org.apache.maven.repository.LegacyMavenRepositorySystem;
+import org.apache.maven.repository.MavenRepositorySystem;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.lang.DefaultLanguage;
+import org.codehaus.plexus.lang.Language;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+@Component( role = MavenRepositorySystem.class, hint = "mercury" )
+public class MercuryRepositorySystem
+ extends LegacyMavenRepositorySystem
+ implements MavenRepositorySystem
+{
+ private static final Language LANG = new DefaultLanguage( MercuryRepositorySystem.class );
+
+ @Requirement( hint = "maven" )
+ DependencyProcessor _dependencyProcessor;
+
+ @Requirement
+ PlexusMercury _mercury;
+
+ @Override
+ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
+ {
+ if ( request == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.request" ) );
+
+ if ( request.getArtifact() == null )
+ throw new IllegalArgumentException( LANG.getMessage( "null.request.artifact" ) );
+
+ ArtifactResolutionResult result = new ArtifactResolutionResult();
+
+ List repos =
+ MercuryAdaptor.toMercuryRepos( request.getLocalRepository(), request.getRemoteRepostories(),
+ _dependencyProcessor );
+
+ try
+ {
+ List mercuryMetadataList =
+ _mercury.resolve( repos, null, MercuryAdaptor.toMetadata( request.getArtifact() ) );
+
+ List mercuryArtifactList =
+ _mercury.read( repos, mercuryMetadataList );
+
+ if ( !Util.isEmpty( mercuryArtifactList ) )
+ for ( org.apache.maven.mercury.artifact.Artifact a : mercuryArtifactList )
+ result.addArtifact( MercuryAdaptor.toMavenArtifact( a ) );
+ }
+ catch ( RepositoryException e )
+ {
+ result.addErrorArtifactException( new ArtifactResolutionException( e.getMessage(), request.getArtifact(),
+ request.getRemoteRepostories() ) );
+ }
+
+ return result;
+ }
+
+ @Override
+ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
+ List remoteRepositories )
+ throws ArtifactMetadataRetrievalException
+ {
+ // TODO Auto-generated method stub
+ return super.retrieve( artifact, localRepository, remoteRepositories );
+ }
+
+}
diff --git a/maven-repository-mercury/src/test/java/org/apache/maven/repository/mercury/Messages.properties b/maven-repository-mercury/src/test/java/org/apache/maven/repository/mercury/Messages.properties
new file mode 100644
index 0000000000..e2bf6cf5d2
--- /dev/null
+++ b/maven-repository-mercury/src/test/java/org/apache/maven/repository/mercury/Messages.properties
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+null.request=null request - too bad
+null.request.artifact=null artifact in the request - too bad