make sure plugin repositories don't get used to resolve parents and dependencies

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@227164 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-08-03 05:11:16 +00:00
parent 786091aa6c
commit b072910ab3
4 changed files with 55 additions and 39 deletions

View File

@ -1,5 +1,21 @@
package org.apache.maven.artifact.metadata; package org.apache.maven.artifact.metadata;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed 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.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import java.util.List; import java.util.List;
@ -9,7 +25,9 @@ public class ResolutionGroup
{ {
private final Set artifacts; private final Set artifacts;
private final List resolutionRepositories; private final List resolutionRepositories;
private final Artifact pomArtifact; private final Artifact pomArtifact;
public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories ) public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories )

View File

@ -232,8 +232,8 @@ public class PrepareReleaseMojo
{ {
if ( isSnapshot( project.getVersion() ) ) if ( isSnapshot( project.getVersion() ) )
{ {
throw new MojoExecutionException( "This project is a snapshot (" + project.getVersion() throw new MojoExecutionException( "This project is a snapshot (" + project.getVersion() +
+ "). It appears that the release version has not been committed." ); "). It appears that the release version has not been committed." );
} }
Model model = project.getOriginalModel(); Model model = project.getOriginalModel();
@ -345,7 +345,8 @@ public class PrepareReleaseMojo
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new MojoExecutionException( "Cannot write development version of pom to: " + project.getFile(), e ); throw new MojoExecutionException( "Cannot write development version of pom to: " + project.getFile(),
e );
} }
finally finally
{ {
@ -378,8 +379,8 @@ public class PrepareReleaseMojo
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new MojoExecutionException( "Cannot read existing release progress file from directory: " throw new MojoExecutionException(
+ basedir + ". Cannot resume." ); "Cannot read existing release progress file from directory: " + basedir + ". Cannot resume." );
} }
} }
else else
@ -390,9 +391,8 @@ public class PrepareReleaseMojo
} }
catch ( IOException e ) catch ( IOException e )
{ {
getLog().warn( getLog().warn( "Cannot read existing release progress file from directory: " + basedir +
"Cannot read existing release progress file from directory: " + basedir ". Creating new instance." );
+ ". Creating new instance." );
} }
releaseProgress.setResumeAtCheckpoint( resume ); releaseProgress.setResumeAtCheckpoint( resume );
@ -487,8 +487,7 @@ public class PrepareReleaseMojo
} }
throw new MojoExecutionException( throw new MojoExecutionException(
"Cannot prepare the release because you have local modifications : \n" "Cannot prepare the release because you have local modifications : \n" + message.toString() );
+ message.toString() );
} }
try try
@ -596,8 +595,8 @@ public class PrepareReleaseMojo
message.append( "\n" ); message.append( "\n" );
} }
throw new MojoExecutionException( "Can't release project due to non released dependencies :\n" throw new MojoExecutionException(
+ message.toString() ); "Can't release project due to non released dependencies :\n" + message.toString() );
} }
try try
@ -925,8 +924,8 @@ public class PrepareReleaseMojo
{ {
try try
{ {
artifactMetadataSource artifactMetadataSource.retrieve( artifact, localRepository,
.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() ); project.getPluginArtifactRepositories() );
} }
catch ( ArtifactMetadataRetrievalException e ) catch ( ArtifactMetadataRetrievalException e )
{ {

View File

@ -40,7 +40,6 @@ import org.apache.maven.model.Profile;
import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.profiles.activation.ProfileActivationCalculator; import org.apache.maven.profiles.activation.ProfileActivationCalculator;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler; import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.apache.maven.project.injection.ModelDefaultsInjector; import org.apache.maven.project.injection.ModelDefaultsInjector;
@ -64,7 +63,6 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
@ -386,7 +384,7 @@ public class DefaultMavenProjectBuilder
} }
private MavenProject build( String pomLocation, Model model, ArtifactRepository localRepository, private MavenProject build( String pomLocation, Model model, ArtifactRepository localRepository,
List remoteArtifactRepositories, List externalProfiles, File projectDir ) List parentSearchRepositories, List externalProfiles, File projectDir )
throws ProjectBuildingException throws ProjectBuildingException
{ {
Model superModel = getSuperModel(); Model superModel = getSuperModel();
@ -395,10 +393,6 @@ public class DefaultMavenProjectBuilder
LinkedList lineage = new LinkedList(); LinkedList lineage = new LinkedList();
Set aggregatedRemoteWagonRepositories = new HashSet(); Set aggregatedRemoteWagonRepositories = new HashSet();
if ( remoteArtifactRepositories != null && !remoteArtifactRepositories.isEmpty() )
{
aggregatedRemoteWagonRepositories.addAll( remoteArtifactRepositories );
}
aggregatedRemoteWagonRepositories.addAll( ProjectUtils.buildArtifactRepositories( superModel.getRepositories(), aggregatedRemoteWagonRepositories.addAll( ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
artifactRepositoryFactory, artifactRepositoryFactory,
@ -422,10 +416,8 @@ public class DefaultMavenProjectBuilder
Model originalModel = ModelUtils.cloneModel( model ); Model originalModel = ModelUtils.cloneModel( model );
List repositories = new ArrayList( aggregatedRemoteWagonRepositories ); MavenProject project = assembleLineage( model, lineage, localRepository, externalProfiles, projectDir,
parentSearchRepositories, aggregatedRemoteWagonRepositories );
MavenProject project = assembleLineage( model, lineage, repositories, localRepository, externalProfiles,
projectDir );
project.setOriginalModel( originalModel ); project.setOriginalModel( originalModel );
@ -445,7 +437,8 @@ public class DefaultMavenProjectBuilder
try try
{ {
project = processProjectLogic( pomLocation, project, repositories, externalProfiles ); project = processProjectLogic( pomLocation, project, new ArrayList( aggregatedRemoteWagonRepositories ),
externalProfiles );
} }
catch ( ModelInterpolationException e ) catch ( ModelInterpolationException e )
{ {
@ -562,8 +555,9 @@ public class DefaultMavenProjectBuilder
/** /**
* @noinspection CollectionDeclaredAsConcreteClass * @noinspection CollectionDeclaredAsConcreteClass
*/ */
private MavenProject assembleLineage( Model model, LinkedList lineage, List aggregatedRemoteWagonRepositories, private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
ArtifactRepository localRepository, List externalProfiles, File projectDir ) List externalProfiles, File projectDir, List parentSearchRepositories,
Set aggregatedRemoteWagonRepositories )
throws ProjectBuildingException throws ProjectBuildingException
{ {
if ( !model.getRepositories().isEmpty() ) if ( !model.getRepositories().isEmpty() )
@ -672,11 +666,15 @@ public class DefaultMavenProjectBuilder
parentModel.getArtifactId(), parentModel.getArtifactId(),
parentModel.getVersion() ); parentModel.getVersion() );
model = findModelFromRepository( parentArtifact, aggregatedRemoteWagonRepositories, localRepository ); // we must add the repository this POM was found in too, by chance it may be located where the parent is
// we can't query the parent to ask where it is :)
List remoteRepositories = new ArrayList( aggregatedRemoteWagonRepositories );
remoteRepositories.addAll( parentSearchRepositories );
model = findModelFromRepository( parentArtifact, remoteRepositories, localRepository );
} }
MavenProject parent = assembleLineage( model, lineage, aggregatedRemoteWagonRepositories, localRepository, MavenProject parent = assembleLineage( model, lineage, localRepository, externalProfiles, parentProjectDir,
externalProfiles, parentProjectDir ); parentSearchRepositories, aggregatedRemoteWagonRepositories );
project.setParent( parent ); project.setParent( parent );
@ -855,8 +853,9 @@ public class DefaultMavenProjectBuilder
Artifact artifact; Artifact artifact;
try try
{ {
artifact = artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), VersionRange artifact = artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(),
.createFromVersionSpec( version ) ); VersionRange
.createFromVersionSpec( version ) );
} }
catch ( InvalidVersionSpecificationException e ) catch ( InvalidVersionSpecificationException e )
{ {

View File

@ -40,8 +40,8 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a> * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>