if ( projectDescriptor != null )
{
projectDir = projectDescriptor.getAbsoluteFile().getParentFile();
}
Model superModel = getSuperModel();
ProfileManager externalProfileManager = config.getGlobalProfileManager();
ProfileManager superProjectProfileManager;
if ( externalProfileManager != null )
{
superProjectProfileManager = new DefaultProfileManager(
container,
externalProfileManager.getRequestProperties() );
}
else
{
superProjectProfileManager = new DefaultProfileManager( container );
}
List activeProfiles;
superProjectProfileManager.addProfiles( superModel.getProfiles() );
activeProfiles = injectActiveProfiles( superProjectProfileManager, superModel );
MavenProject superProject = new MavenProject( superModel );
superProject.setActiveProfiles( activeProfiles );
//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)
// Use a TreeSet to ensure ordering is retained
Set aggregatedRemoteWagonRepositories = new LinkedHashSet();
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
List activeExternalProfiles;
try
{
if ( externalProfileManager != null )
{
activeExternalProfiles = externalProfileManager.getActiveProfiles();
}
else
{
activeExternalProfiles = Collections.EMPTY_LIST;
}
}
catch ( ProfileActivationException e )
{
throw new ProjectBuildingException( projectId, "Failed to calculate active external profiles.", e );
}
for ( Iterator i = activeExternalProfiles.iterator(); i.hasNext(); )
{
Profile externalProfile = (Profile) i.next();
for ( Iterator repoIterator = externalProfile.getRepositories().iterator(); repoIterator.hasNext(); )
{
Repository mavenRepo = (Repository) repoIterator.next();
ArtifactRepository artifactRepo = null;
try
{
artifactRepo =
ProjectUtils.buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
}
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( projectId, e.getMessage(), e );
}
aggregatedRemoteWagonRepositories.add( artifactRepo );
}
}
MavenProject project = null;
try
{
project = assembleLineage( model, lineage, config, projectDescriptor, parentSearchRepositories,
aggregatedRemoteWagonRepositories, strict );
}
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( projectId, e.getMessage(), e );
}
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
MavenProject previousProject = superProject;
Model previous = superProject.getModel();
for ( Iterator i = lineage.iterator(); i.hasNext(); )
{
MavenProject currentProject = (MavenProject) i.next();
Model current = currentProject.getModel();
String pathAdjustment = null;
try
{