diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 5d5ca736d2..6467ea0102 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -1846,7 +1846,7 @@ public class DefaultPluginManager MavenProject pluginProject = buildPluginProject( plugin, localRepository, project.getRemoteArtifactRepositories() ); - Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); + Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin ); checkRequiredMavenVersion( plugin, pluginProject, localRepository, project.getRemoteArtifactRepositories() ); diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java index 0d33cb5cc3..c04aa8b541 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java @@ -228,6 +228,8 @@ public class MavenProject this.projectBuilderConfiguration = projectBuilderConfiguration; this.repositorySystem = repositorySystem; originalModel = model; + + /* DistributionManagement dm = model.getDistributionManagement(); if ( dm != null ) @@ -235,12 +237,8 @@ public class MavenProject ArtifactRepository repo = repositorySystem.buildArtifactRepository( dm.getRepository() ); setReleaseArtifactRepository( repo ); - if ( dm.getSnapshotRepository() != null ) - { - repo = repositorySystem.buildArtifactRepository( dm.getSnapshotRepository() ); - setSnapshotArtifactRepository( repo ); - } } + */ setRemoteArtifactRepositories( projectBuilderConfiguration.getRemoteRepositories() ); } @@ -1098,7 +1096,7 @@ public class MavenProject version = p.getVersion(); } - Artifact artifact = repositorySystem.createPluginArtifact( p.getGroupId(), p.getArtifactId(), version ); + Artifact artifact = repositorySystem.createPluginArtifact( p ); if ( artifact == null ) { @@ -1152,7 +1150,11 @@ public class MavenProject version = p.getVersion(); } - Artifact artifact = repositorySystem.createPluginArtifact( p.getGroupId(), p.getArtifactId(), version ); + Plugin pp = new Plugin(); + pp.setGroupId( p.getGroupId() ); + pp.setArtifactId( p.getArtifactId() ); + pp.setVersion( version ); + Artifact artifact = repositorySystem.createPluginArtifact( pp ); if ( artifact != null ) { @@ -1915,11 +1917,33 @@ public class MavenProject protected ArtifactRepository getReleaseArtifactRepository() { + if ( getDistributionManagement().getRepository() != null ) + { + try + { + setReleaseArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository() ) ); + } + catch ( InvalidRepositoryException e ) + { + } + } + return releaseArtifactRepository; } protected ArtifactRepository getSnapshotArtifactRepository() { + if ( getDistributionManagement().getSnapshotRepository() != null ) + { + try + { + setSnapshotArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository() ) ); + } + catch ( InvalidRepositoryException e ) + { + } + } + return snapshotArtifactRepository; } @@ -2041,6 +2065,7 @@ public class MavenProject setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) ); } + /* if ( project.getReleaseArtifactRepository() != null ) { setReleaseArtifactRepository( project.getReleaseArtifactRepository() ); @@ -2050,6 +2075,7 @@ public class MavenProject { setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() ); } + */ } private void addArtifactPath( Artifact a, List list ) diff --git a/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java b/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java index 6b4b8f3b62..efe5d19adf 100644 --- a/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java +++ b/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java @@ -19,10 +19,7 @@ package org.apache.maven.project; * under the License. */ -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.repository.MavenRepositorySystem; import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; @Component(role=MavenProjectBuilder.class,hint="test") public class TestProjectBuilder diff --git a/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java b/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java index 52168bf205..0253d0a433 100644 --- a/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java +++ b/maven-repository/src/main/java/org/apache/maven/repository/LegacyMavenRepositorySystem.java @@ -45,6 +45,7 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; +import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.wagon.authentication.AuthenticationInfo; @@ -153,19 +154,19 @@ public class LegacyMavenRepositorySystem return artifactFactory.createParentArtifact( groupId, artifactId, version ); } - public Artifact createPluginArtifact( String groupId, String artifactId, String version ) + public Artifact createPluginArtifact( Plugin plugin ) { VersionRange versionRange; try { - versionRange = VersionRange.createFromVersionSpec( version ); + versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() ); } catch ( InvalidVersionSpecificationException e ) { return null; } - return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange ); + return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); } /** diff --git a/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java b/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java index 9753d0a34a..0d249d8de0 100644 --- a/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java +++ b/maven-repository/src/main/java/org/apache/maven/repository/MavenRepositorySystem.java @@ -32,6 +32,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; +import org.apache.maven.model.Plugin; import org.apache.maven.model.Repository; import org.apache.maven.wagon.events.TransferListener; @@ -40,15 +41,12 @@ import org.apache.maven.wagon.events.TransferListener; */ public interface MavenRepositorySystem { - // Artifact creation: This needs to be reduced to fewer, if not one, method. - Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ); Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId ); - Artifact createPluginArtifact( String groupId, String artifactId, String version ); - - // This is still only used in one place. + Artifact createPluginArtifact( Plugin plugin ); + Artifact createDependencyArtifact( Dependency dependency ); //REMOVE