PR: MNG-753

use an ordered set so that insertion order is preserved

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@289259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-15 15:29:02 +00:00
parent e9f55ae5f4
commit b0c3a2fedc
1 changed files with 20 additions and 16 deletions

View File

@ -82,6 +82,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -322,21 +323,20 @@ public class DefaultMavenProjectBuilder
throws ProjectBuildingException throws ProjectBuildingException
{ {
Artifact projectArtifact; Artifact projectArtifact;
if ( "pom".equals( artifact.getType() ) ) if ( "pom".equals( artifact.getType() ) )
{ {
projectArtifact = artifact; projectArtifact = artifact;
} }
else else
{ {
getLogger().warn( getLogger().warn( "Attempting to build MavenProject instance for Artifact of type: " + artifact.getType() +
"Attempting to build MavenProject instance for Artifact of type: " + artifact.getType() "; constructing POM artifact instead." );
+ "; constructing POM artifact instead." );
projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope() ); artifact.getVersion(), artifact.getScope() );
} }
MavenProject project = getCachedProject( projectArtifact.getGroupId(), projectArtifact.getArtifactId(), MavenProject project = getCachedProject( projectArtifact.getGroupId(), projectArtifact.getArtifactId(),
projectArtifact.getVersion() ); projectArtifact.getVersion() );
Model model; Model model;
@ -376,7 +376,8 @@ public class DefaultMavenProjectBuilder
try try
{ {
projectArtifact.setResolved( false ); projectArtifact.setResolved( false );
artifactResolver.resolveAlways( projectArtifact, remoteArtifactRepositories, localRepository ); artifactResolver.resolveAlways( projectArtifact, remoteArtifactRepositories,
localRepository );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
@ -472,7 +473,8 @@ public class DefaultMavenProjectBuilder
// TODO: the aRWR can get out of sync with project.model.repositories. We should do all the processing of // 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 // 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) // must still be created along the way so that parent poms can be discovered, however)
Set aggregatedRemoteWagonRepositories = new HashSet(); // Use a TreeSet to ensure ordering is retained
Set aggregatedRemoteWagonRepositories = new LinkedHashSet();
List activeExternalProfiles; List activeExternalProfiles;
try try
@ -693,7 +695,7 @@ public class DefaultMavenProjectBuilder
} }
ProfileManager profileManager = new DefaultProfileManager( container ); ProfileManager profileManager = new DefaultProfileManager( container );
if ( externalProfileManager != null ) if ( externalProfileManager != null )
{ {
profileManager.explicitlyActivate( externalProfileManager.getExplicitlyActivatedIds() ); profileManager.explicitlyActivate( externalProfileManager.getExplicitlyActivatedIds() );
@ -778,11 +780,15 @@ public class DefaultMavenProjectBuilder
String candidateParentGroupId = candidateParent.getGroupId(); String candidateParentGroupId = candidateParent.getGroupId();
if ( candidateParentGroupId == null && candidateParent.getParent() != null ) if ( candidateParentGroupId == null && candidateParent.getParent() != null )
{
candidateParentGroupId = candidateParent.getParent().getGroupId(); candidateParentGroupId = candidateParent.getParent().getGroupId();
}
String candidateParentVersion = candidateParent.getVersion(); String candidateParentVersion = candidateParent.getVersion();
if ( candidateParentVersion == null && candidateParent.getParent() != null ) if ( candidateParentVersion == null && candidateParent.getParent() != null )
{
candidateParentVersion = candidateParent.getParent().getVersion(); candidateParentVersion = candidateParent.getParent().getVersion();
}
if ( parentModel.getGroupId().equals( candidateParentGroupId ) && if ( parentModel.getGroupId().equals( candidateParentGroupId ) &&
parentModel.getArtifactId().equals( candidateParent.getArtifactId() ) && parentModel.getArtifactId().equals( candidateParent.getArtifactId() ) &&
@ -797,9 +803,7 @@ public class DefaultMavenProjectBuilder
{ {
getLogger().debug( "Invalid parent-POM referenced by relative path '" + getLogger().debug( "Invalid parent-POM referenced by relative path '" +
parentModel.getRelativePath() + "' in parent specification in " + project.getId() + ":" + parentModel.getRelativePath() + "' in parent specification in " + project.getId() + ":" +
"\n Specified: " + parentModel.getId() + "\n Specified: " + parentModel.getId() + "\n Found: " + candidateParent.getId() );
"\n Found: " + candidateParent.getId()
);
} }
} }
} }
@ -890,18 +894,18 @@ public class DefaultMavenProjectBuilder
if ( root != null ) if ( root != null )
{ {
List active = root.getActiveProfiles(); List active = root.getActiveProfiles();
if( active != null && !active.isEmpty() ) if ( active != null && !active.isEmpty() )
{ {
profileManager.explicitlyActivate( root.getActiveProfiles() ); profileManager.explicitlyActivate( root.getActiveProfiles() );
} }
for ( Iterator it = root.getProfiles().iterator(); it.hasNext(); ) for ( Iterator it = root.getProfiles().iterator(); it.hasNext(); )
{ {
org.apache.maven.profiles.Profile rawProfile = (org.apache.maven.profiles.Profile) it.next(); org.apache.maven.profiles.Profile rawProfile = (org.apache.maven.profiles.Profile) it.next();
Profile converted = ProfilesConversionUtils.convertFromProfileXmlProfile( rawProfile ); Profile converted = ProfilesConversionUtils.convertFromProfileXmlProfile( rawProfile );
profileManager.addProfile( converted ); profileManager.addProfile( converted );
} }
} }