mirror of https://github.com/apache/maven.git
PR: MNG-753
correct ordering of repositories in POM (also fixed problem of not correctly overriding "central" - properly this time!) took note of a simpler way to ensure this is correct in future git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@240204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c945c27bff
commit
d466205274
|
@ -144,7 +144,8 @@ public class DefaultMavenProjectBuilder
|
|||
/**
|
||||
* @todo move to metadatasource itself?
|
||||
*/
|
||||
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
|
||||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException, ArtifactResolutionException
|
||||
{
|
||||
MavenProject project = buildFromSourceFile( projectDescriptor, localRepository, profileManager );
|
||||
|
@ -258,13 +259,15 @@ public class DefaultMavenProjectBuilder
|
|||
return buildFromSourceFile( projectDescriptor, localRepository, profileManager );
|
||||
}
|
||||
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository,
|
||||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
return buildFromSourceFile( projectDescriptor, localRepository, profileManager );
|
||||
}
|
||||
|
||||
private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactRepository localRepository,
|
||||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model model = readModel( projectDescriptor );
|
||||
|
@ -273,7 +276,8 @@ public class DefaultMavenProjectBuilder
|
|||
modelCache.put( createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ), model );
|
||||
|
||||
MavenProject project = build( projectDescriptor.getAbsolutePath(), model, localRepository,
|
||||
Collections.EMPTY_LIST, projectDescriptor.getAbsoluteFile().getParentFile(), profileManager );
|
||||
Collections.EMPTY_LIST, projectDescriptor.getAbsoluteFile().getParentFile(),
|
||||
profileManager );
|
||||
|
||||
if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null )
|
||||
{
|
||||
|
@ -308,8 +312,8 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||
|
||||
return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories,
|
||||
null, null );
|
||||
return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories, null,
|
||||
null );
|
||||
}
|
||||
|
||||
private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
|
@ -443,12 +447,11 @@ public class DefaultMavenProjectBuilder
|
|||
//noinspection CollectionDeclaredAsConcreteClass
|
||||
LinkedList lineage = new LinkedList();
|
||||
|
||||
// TODO: the aRWR can get out of sync with project.model.repositories. We should do all the processing of
|
||||
// profiles, etc on the models then recreate the aggregated sets at the end from the project repositories (they
|
||||
// must still be created along the way so that parent poms can be discovered, however)
|
||||
Set aggregatedRemoteWagonRepositories = new HashSet();
|
||||
|
||||
aggregatedRemoteWagonRepositories.addAll( ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
|
||||
artifactRepositoryFactory,
|
||||
container ) );
|
||||
|
||||
List activeExternalProfiles;
|
||||
try
|
||||
{
|
||||
|
@ -503,9 +506,22 @@ public class DefaultMavenProjectBuilder
|
|||
previous = current;
|
||||
}
|
||||
|
||||
// only add the super repository if it wasn't overridden by a profile or project
|
||||
List repositories = new ArrayList( aggregatedRemoteWagonRepositories );
|
||||
List superRepositories = ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
|
||||
artifactRepositoryFactory, container );
|
||||
for ( Iterator i = superRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||
if ( !repositories.contains( repository ) )
|
||||
{
|
||||
repositories.add( repository );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
project = processProjectLogic( pomLocation, project, new ArrayList( aggregatedRemoteWagonRepositories ), profileManager );
|
||||
project = processProjectLogic( pomLocation, project, repositories, profileManager );
|
||||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
|
@ -524,7 +540,8 @@ public class DefaultMavenProjectBuilder
|
|||
* the resolved source roots, etc for the parent - that occurs for the parent when it is constructed independently
|
||||
* and projects are not cached or reused
|
||||
*/
|
||||
private MavenProject processProjectLogic( String pomLocation, MavenProject project, List remoteRepositories, ProfileManager profileMgr )
|
||||
private MavenProject processProjectLogic( String pomLocation, MavenProject project, List remoteRepositories,
|
||||
ProfileManager profileMgr )
|
||||
throws ProjectBuildingException, ModelInterpolationException
|
||||
{
|
||||
Model model = project.getModel();
|
||||
|
@ -584,9 +601,11 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
if ( projectArtifact.isSnapshot() )
|
||||
{
|
||||
project.setSnapshotDeploymentVersion( transformationManager.getSnapshotDeploymentVersion( projectArtifact ) );
|
||||
project.setSnapshotDeploymentVersion(
|
||||
transformationManager.getSnapshotDeploymentVersion( projectArtifact ) );
|
||||
|
||||
project.setSnapshotDeploymentBuildNumber( transformationManager.getSnapshotDeploymentBuildNumber( projectArtifact ) );
|
||||
project.setSnapshotDeploymentBuildNumber(
|
||||
transformationManager.getSnapshotDeploymentBuildNumber( projectArtifact ) );
|
||||
}
|
||||
|
||||
project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(),
|
||||
|
@ -779,8 +798,8 @@ public class DefaultMavenProjectBuilder
|
|||
model = findModelFromRepository( parentArtifact, remoteRepositories, localRepository );
|
||||
}
|
||||
|
||||
MavenProject parent = assembleLineage( model, lineage, localRepository, parentProjectDir, parentSearchRepositories,
|
||||
aggregatedRemoteWagonRepositories );
|
||||
MavenProject parent = assembleLineage( model, lineage, localRepository, parentProjectDir,
|
||||
parentSearchRepositories, aggregatedRemoteWagonRepositories );
|
||||
|
||||
project.setParent( parent );
|
||||
|
||||
|
@ -844,11 +863,13 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ProfileActivationException( "Cannot read profiles.xml resource from directory: " + projectDir, e );
|
||||
throw new ProfileActivationException( "Cannot read profiles.xml resource from directory: " + projectDir,
|
||||
e );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new ProfileActivationException( "Cannot parse profiles.xml resource from directory: " + projectDir, e );
|
||||
throw new ProfileActivationException(
|
||||
"Cannot parse profiles.xml resource from directory: " + projectDir, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -882,7 +903,8 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
}
|
||||
|
||||
private Model readModel( Reader reader ) throws IOException, XmlPullParserException, InvalidModelException
|
||||
private Model readModel( Reader reader )
|
||||
throws IOException, XmlPullParserException, InvalidModelException
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
|
|
Loading…
Reference in New Issue