diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
new file mode 100644
index 0000000000..b7da0d1a62
--- /dev/null
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorUtils.java
@@ -0,0 +1,81 @@
+package org.apache.maven.repository.internal;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.model.Repository;
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.repository.RemoteRepository;
+import org.sonatype.aether.repository.RepositoryPolicy;
+import org.sonatype.aether.util.artifact.DefaultArtifact;
+
+/**
+ * Warning: This is an internal utility class that is only public for technical reasons, it is not part
+ * of the public API. In particular, this class can be changed or deleted without prior notice.
+ *
+ * @author Benjamin Bentmann
+ */
+public class ArtifactDescriptorUtils
+{
+
+ public static Artifact toPomArtifact( Artifact artifact )
+ {
+ Artifact pomArtifact = artifact;
+
+ if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) )
+ {
+ pomArtifact =
+ new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), "pom", artifact.getVersion() );
+ }
+
+ return pomArtifact;
+ }
+
+ public static RemoteRepository toRemoteRepository( Repository repository )
+ {
+ RemoteRepository result =
+ new RemoteRepository( repository.getId(), repository.getLayout(), repository.getUrl() );
+ result.setPolicy( true, toRepositoryPolicy( repository.getSnapshots() ) );
+ result.setPolicy( false, toRepositoryPolicy( repository.getReleases() ) );
+ return result;
+ }
+
+ public static RepositoryPolicy toRepositoryPolicy( org.apache.maven.model.RepositoryPolicy policy )
+ {
+ boolean enabled = true;
+ String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN;
+ String updates = RepositoryPolicy.UPDATE_POLICY_DAILY;
+
+ if ( policy != null )
+ {
+ enabled = policy.isEnabled();
+ if ( policy.getUpdatePolicy() != null )
+ {
+ updates = policy.getUpdatePolicy();
+ }
+ if ( policy.getChecksumPolicy() != null )
+ {
+ checksums = policy.getChecksumPolicy();
+ }
+ }
+
+ return new RepositoryPolicy( enabled, updates, checksums );
+ }
+
+}
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
index 62bde969a1..2c8fdf8af7 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
@@ -64,10 +64,7 @@ import org.sonatype.aether.util.DefaultRequestTrace;
import org.sonatype.aether.util.artifact.ArtifactProperties;
import org.sonatype.aether.util.artifact.DefaultArtifact;
import org.sonatype.aether.util.artifact.DefaultArtifactType;
-import org.sonatype.aether.util.artifact.SubArtifact;
import org.sonatype.aether.util.listener.DefaultRepositoryEvent;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.repository.RepositoryPolicy;
import org.sonatype.aether.repository.WorkspaceRepository;
import org.sonatype.aether.resolution.ArtifactDescriptorException;
import org.sonatype.aether.resolution.ArtifactDescriptorRequest;
@@ -180,7 +177,7 @@ public class DefaultArtifactDescriptorReader
for ( Repository r : model.getRepositories() )
{
- result.addRepository( convert( r ) );
+ result.addRepository( ArtifactDescriptorUtils.toRemoteRepository( r ) );
}
for ( org.apache.maven.model.Dependency dependency : model.getDependencies() )
@@ -259,11 +256,7 @@ public class DefaultArtifactDescriptorReader
throw new ArtifactDescriptorException( result );
}
- Artifact pomArtifact = artifact;
- if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) )
- {
- pomArtifact = new SubArtifact( artifact, "", "pom" );
- }
+ Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( artifact );
ArtifactResult resolveResult;
try
@@ -411,37 +404,6 @@ public class DefaultArtifactDescriptorReader
return new Exclusion( exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*" );
}
- static RemoteRepository convert( Repository repository )
- {
- RemoteRepository result =
- new RemoteRepository( repository.getId(), repository.getLayout(), repository.getUrl() );
- result.setPolicy( true, convert( repository.getSnapshots() ) );
- result.setPolicy( false, convert( repository.getReleases() ) );
- return result;
- }
-
- private static RepositoryPolicy convert( org.apache.maven.model.RepositoryPolicy policy )
- {
- boolean enabled = true;
- String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN;
- String updates = RepositoryPolicy.UPDATE_POLICY_DAILY;
-
- if ( policy != null )
- {
- enabled = policy.isEnabled();
- if ( policy.getUpdatePolicy() != null )
- {
- updates = policy.getUpdatePolicy();
- }
- if ( policy.getChecksumPolicy() != null )
- {
- checksums = policy.getChecksumPolicy();
- }
- }
-
- return new RepositoryPolicy( enabled, updates, checksums );
- }
-
private void missingDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
Exception exception )
{
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
index a4de6a9ba5..96b9fc3652 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
@@ -99,7 +99,7 @@ class DefaultModelResolver
}
List newRepositories =
- Collections.singletonList( DefaultArtifactDescriptorReader.convert( repository ) );
+ Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) );
this.repositories =
remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true );
diff --git a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
index aff556de6f..f36d7f59db 100644
--- a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
+++ b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java
@@ -44,7 +44,6 @@ import org.sonatype.aether.RepositoryListener;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.SyncContext;
import org.sonatype.aether.util.DefaultRequestTrace;
-import org.sonatype.aether.util.artifact.SubArtifact;
import org.sonatype.aether.util.listener.DefaultRepositoryEvent;
import org.sonatype.aether.util.metadata.DefaultMetadata;
import org.sonatype.aether.artifact.Artifact;
@@ -455,11 +454,7 @@ public class DefaultVersionResolver
return true;
}
- Artifact pomArtifact = artifact;
- if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) )
- {
- pomArtifact = new SubArtifact( artifact, "", "pom" );
- }
+ Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( artifact );
return workspace.findArtifact( pomArtifact ) == null;
}
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index abee04e6ea..6ffec920b7 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -56,7 +56,6 @@
org.apache.maven
maven-aether-provider
- runtime
org.sonatype.aether
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
index d871778321..eaa98fe37f 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
@@ -44,6 +44,7 @@ import org.apache.maven.model.building.ModelSource;
import org.apache.maven.model.building.StringModelSource;
import org.apache.maven.model.resolution.ModelResolver;
import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.repository.internal.ArtifactDescriptorUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
@@ -58,7 +59,6 @@ import org.sonatype.aether.repository.WorkspaceRepository;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.util.DefaultRequestTrace;
-import org.sonatype.aether.util.artifact.SubArtifact;
/**
* @version $Id$
@@ -247,10 +247,7 @@ public class DefaultProjectBuilder
throws ProjectBuildingException
{
org.sonatype.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact );
- if ( !pomArtifact.getExtension().equals( "pom" ) )
- {
- pomArtifact = new SubArtifact( pomArtifact, "", "pom" );
- }
+ pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact );
InternalConfig config = new InternalConfig( request, null, null );
diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
index 62291969c8..e6cc41112a 100644
--- a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
@@ -32,13 +32,13 @@ import org.apache.maven.model.building.ModelSource;
import org.apache.maven.model.resolution.InvalidRepositoryException;
import org.apache.maven.model.resolution.ModelResolver;
import org.apache.maven.model.resolution.UnresolvableModelException;
+import org.apache.maven.repository.internal.ArtifactDescriptorUtils;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.RequestTrace;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.impl.RemoteRepositoryManager;
import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.repository.RepositoryPolicy;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;
@@ -113,7 +113,8 @@ class ProjectModelResolver
return;
}
- List newRepositories = Collections.singletonList( convert( repository ) );
+ List newRepositories =
+ Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) );
if ( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT.equals( repositoryMerging ) )
{
@@ -128,37 +129,6 @@ class ProjectModelResolver
}
}
- private static RemoteRepository convert( Repository repository )
- {
- RemoteRepository result =
- new RemoteRepository( repository.getId(), repository.getLayout(), repository.getUrl() );
- result.setPolicy( true, convert( repository.getSnapshots() ) );
- result.setPolicy( false, convert( repository.getReleases() ) );
- return result;
- }
-
- private static RepositoryPolicy convert( org.apache.maven.model.RepositoryPolicy policy )
- {
- boolean enabled = true;
- String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN;
- String updates = RepositoryPolicy.UPDATE_POLICY_DAILY;
-
- if ( policy != null )
- {
- enabled = policy.isEnabled();
- if ( policy.getUpdatePolicy() != null )
- {
- updates = policy.getUpdatePolicy();
- }
- if ( policy.getChecksumPolicy() != null )
- {
- checksums = policy.getChecksumPolicy();
- }
- }
-
- return new RepositoryPolicy( enabled, updates, checksums );
- }
-
public ModelResolver newCopy()
{
return new ProjectModelResolver( this );