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 e15ba5fb8f..1f2e5feeaf 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 @@ -56,6 +56,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.lifecycle.model.MojoBinding; import org.apache.maven.lifecycle.statemgmt.StateManagementUtils; +import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; @@ -366,24 +367,27 @@ public class DefaultPluginManager InvalidDependencyVersionException ee = new InvalidDependencyVersionException( e.getProjectId(), e.getDependency(), e.getPomFile(), e.getCauseException() ); throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), ee ); } - - ResolutionGroup resolutionGroup; - - try - { - resolutionGroup = repositorySystem.retrieve( pluginArtifact, localRepository, project.getRemoteArtifactRepositories() ); - } - catch ( ArtifactMetadataRetrievalException e ) - { - throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" + pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e ); - } - + /* get plugin managed versions */ Map pluginManagedDependencies = new HashMap(); + + // This is really crappy that we have to do this. The repository system should deal with this. The retrieval of the transitive dependencies. + + List pluginArtifacts = new ArrayList(); + try { - MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( pluginArtifact, project.getRemoteArtifactRepositories(), localRepository ); - + Artifact pluginPomArtifact = repositorySystem.createProjectArtifact( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() ); + + // This does not populate the artifacts of the dependenct projects + MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( pluginPomArtifact, project.getRemoteArtifactRepositories(), localRepository ); + + // This needs to be changed so that the resolver deals with this + for ( Dependency d : pluginProject.getDependencies() ) + { + pluginArtifacts.add( repositorySystem.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(), d.getType() ) ); + } + if ( pluginProject != null ) { pluginManagedDependencies = pluginProject.getManagedVersionMap(); @@ -391,7 +395,7 @@ public class DefaultPluginManager } catch ( ProjectBuildingException e ) { - // this can't happen, it would have blowed up at artifactMetadataSource.retrieve() + throw new InvalidPluginException( "Error resolving plugin POM " + e.getMessage() ); } Set dependencies = new LinkedHashSet(); @@ -400,7 +404,7 @@ public class DefaultPluginManager dependencies.addAll( projectPluginDependencies ); // followed by the plugin's default artifact set - dependencies.addAll( resolutionGroup.getArtifacts() ); + dependencies.addAll( pluginArtifacts ); ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setArtifact( pluginArtifact ) @@ -1791,24 +1795,8 @@ public class DefaultPluginManager Artifact artifact = repositorySystem.createProjectArtifact( groupId, artifactId, metaVersionId ); - String key = artifact.getDependencyConflictId(); - String version = null; - // This takes the spec version and resolves a real version - try - { - ResolutionGroup resolutionGroup = repositorySystem.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() ); - - // switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom - // artifact. - artifact = resolutionGroup.getPomArtifact(); - } - catch ( ArtifactMetadataRetrievalException e ) - { - throw new PluginVersionResolutionException( groupId, artifactId, e.getMessage(), e ); - } - String artifactVersion = artifact.getVersion(); // make sure this artifact was transformed to a real version, and actually resolved to a file in the repo... @@ -1819,7 +1807,9 @@ public class DefaultPluginManager while ( !pluginValid && ( artifactVersion != null ) ) { pluginValid = true; + MavenProject pluginProject; + try { artifact = repositorySystem.createProjectArtifact( groupId, artifactId, artifactVersion ); 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 005d7422be..cf0a62b2c3 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 @@ -461,12 +461,6 @@ public class LegacyMavenRepositorySystem serverPermissionsMap.put( repositoryId, permissions ); } } - - public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException - { - return artifactMetadataSource.retrieveRelocatedArtifact( artifact, localRepository, remoteRepositories ); - } // Mirror 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 16a2df531f..844b9d5b59 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 @@ -61,7 +61,7 @@ public interface MavenRepositorySystem Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, String inheritedScope ); Set createArtifacts( List dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor ) - throws VersionNotFoundException; + throws VersionNotFoundException; // Repository creation @@ -74,18 +74,8 @@ public interface MavenRepositorySystem ArtifactResolutionResult resolve( ArtifactResolutionRequest request ); - // Metadata - //MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request ); - - ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException; - - // Relocated artifacts are stupid. If you you want to move your shit then too bad. You have to support all your users and leave your stuff - // there. This is just so problematic because it makes Maven folk responsible and makes the system complicated. - public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException; - + // Network enablement: this needs to go as we will know at a higher level from the embedder if the system is offline or not, we should not have to // deal with this here. void setOnline( boolean online );