mirror of https://github.com/apache/maven.git
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:
parent
786091aa6c
commit
b072910ab3
|
@ -1,5 +1,21 @@
|
|||
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 java.util.List;
|
||||
|
@ -7,9 +23,11 @@ import java.util.Set;
|
|||
|
||||
public class ResolutionGroup
|
||||
{
|
||||
|
||||
|
||||
private final Set artifacts;
|
||||
|
||||
private final List resolutionRepositories;
|
||||
|
||||
private final Artifact pomArtifact;
|
||||
|
||||
public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories )
|
||||
|
@ -18,17 +36,17 @@ public class ResolutionGroup
|
|||
this.artifacts = artifacts;
|
||||
this.resolutionRepositories = resolutionRepositories;
|
||||
}
|
||||
|
||||
|
||||
public Artifact getPomArtifact()
|
||||
{
|
||||
return pomArtifact;
|
||||
}
|
||||
|
||||
|
||||
public Set getArtifacts()
|
||||
{
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
|
||||
public List getResolutionRepositories()
|
||||
{
|
||||
return resolutionRepositories;
|
||||
|
|
|
@ -232,8 +232,8 @@ public class PrepareReleaseMojo
|
|||
{
|
||||
if ( isSnapshot( project.getVersion() ) )
|
||||
{
|
||||
throw new MojoExecutionException( "This project is a snapshot (" + project.getVersion()
|
||||
+ "). It appears that the release version has not been committed." );
|
||||
throw new MojoExecutionException( "This project is a snapshot (" + project.getVersion() +
|
||||
"). It appears that the release version has not been committed." );
|
||||
}
|
||||
|
||||
Model model = project.getOriginalModel();
|
||||
|
@ -345,7 +345,8 @@ public class PrepareReleaseMojo
|
|||
}
|
||||
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
|
||||
{
|
||||
|
@ -373,13 +374,13 @@ public class PrepareReleaseMojo
|
|||
try
|
||||
{
|
||||
releaseProgress = ReleaseProgressTracker.load( basedir );
|
||||
|
||||
|
||||
releaseProgress.verifyResumeCapable();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Cannot read existing release progress file from directory: "
|
||||
+ basedir + ". Cannot resume." );
|
||||
throw new MojoExecutionException(
|
||||
"Cannot read existing release progress file from directory: " + basedir + ". Cannot resume." );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -390,9 +391,8 @@ public class PrepareReleaseMojo
|
|||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
getLog().warn(
|
||||
"Cannot read existing release progress file from directory: " + basedir
|
||||
+ ". Creating new instance." );
|
||||
getLog().warn( "Cannot read existing release progress file from directory: " + basedir +
|
||||
". Creating new instance." );
|
||||
}
|
||||
|
||||
releaseProgress.setResumeAtCheckpoint( resume );
|
||||
|
@ -487,8 +487,7 @@ public class PrepareReleaseMojo
|
|||
}
|
||||
|
||||
throw new MojoExecutionException(
|
||||
"Cannot prepare the release because you have local modifications : \n"
|
||||
+ message.toString() );
|
||||
"Cannot prepare the release because you have local modifications : \n" + message.toString() );
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -596,8 +595,8 @@ public class PrepareReleaseMojo
|
|||
message.append( "\n" );
|
||||
}
|
||||
|
||||
throw new MojoExecutionException( "Can't release project due to non released dependencies :\n"
|
||||
+ message.toString() );
|
||||
throw new MojoExecutionException(
|
||||
"Can't release project due to non released dependencies :\n" + message.toString() );
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -925,8 +924,8 @@ public class PrepareReleaseMojo
|
|||
{
|
||||
try
|
||||
{
|
||||
artifactMetadataSource
|
||||
.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() );
|
||||
artifactMetadataSource.retrieve( artifact, localRepository,
|
||||
project.getPluginArtifactRepositories() );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.apache.maven.model.Profile;
|
|||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.Repository;
|
||||
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.project.inheritance.ModelInheritanceAssembler;
|
||||
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.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
@ -386,7 +384,7 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
|
||||
private MavenProject build( String pomLocation, Model model, ArtifactRepository localRepository,
|
||||
List remoteArtifactRepositories, List externalProfiles, File projectDir )
|
||||
List parentSearchRepositories, List externalProfiles, File projectDir )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model superModel = getSuperModel();
|
||||
|
@ -395,10 +393,6 @@ public class DefaultMavenProjectBuilder
|
|||
LinkedList lineage = new LinkedList();
|
||||
|
||||
Set aggregatedRemoteWagonRepositories = new HashSet();
|
||||
if ( remoteArtifactRepositories != null && !remoteArtifactRepositories.isEmpty() )
|
||||
{
|
||||
aggregatedRemoteWagonRepositories.addAll( remoteArtifactRepositories );
|
||||
}
|
||||
|
||||
aggregatedRemoteWagonRepositories.addAll( ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
|
||||
artifactRepositoryFactory,
|
||||
|
@ -422,10 +416,8 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
Model originalModel = ModelUtils.cloneModel( model );
|
||||
|
||||
List repositories = new ArrayList( aggregatedRemoteWagonRepositories );
|
||||
|
||||
MavenProject project = assembleLineage( model, lineage, repositories, localRepository, externalProfiles,
|
||||
projectDir );
|
||||
MavenProject project = assembleLineage( model, lineage, localRepository, externalProfiles, projectDir,
|
||||
parentSearchRepositories, aggregatedRemoteWagonRepositories );
|
||||
|
||||
project.setOriginalModel( originalModel );
|
||||
|
||||
|
@ -445,7 +437,8 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
try
|
||||
{
|
||||
project = processProjectLogic( pomLocation, project, repositories, externalProfiles );
|
||||
project = processProjectLogic( pomLocation, project, new ArrayList( aggregatedRemoteWagonRepositories ),
|
||||
externalProfiles );
|
||||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
|
@ -562,8 +555,9 @@ public class DefaultMavenProjectBuilder
|
|||
/**
|
||||
* @noinspection CollectionDeclaredAsConcreteClass
|
||||
*/
|
||||
private MavenProject assembleLineage( Model model, LinkedList lineage, List aggregatedRemoteWagonRepositories,
|
||||
ArtifactRepository localRepository, List externalProfiles, File projectDir )
|
||||
private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
|
||||
List externalProfiles, File projectDir, List parentSearchRepositories,
|
||||
Set aggregatedRemoteWagonRepositories )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( !model.getRepositories().isEmpty() )
|
||||
|
@ -672,11 +666,15 @@ public class DefaultMavenProjectBuilder
|
|||
parentModel.getArtifactId(),
|
||||
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,
|
||||
externalProfiles, parentProjectDir );
|
||||
MavenProject parent = assembleLineage( model, lineage, localRepository, externalProfiles, parentProjectDir,
|
||||
parentSearchRepositories, aggregatedRemoteWagonRepositories );
|
||||
|
||||
project.setParent( parent );
|
||||
|
||||
|
@ -855,8 +853,9 @@ public class DefaultMavenProjectBuilder
|
|||
Artifact artifact;
|
||||
try
|
||||
{
|
||||
artifact = artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), VersionRange
|
||||
.createFromVersionSpec( version ) );
|
||||
artifact = artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(),
|
||||
VersionRange
|
||||
.createFromVersionSpec( version ) );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
|
|
|
@ -40,8 +40,8 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||
|
|
Loading…
Reference in New Issue