{
DefaultModelBuildingResult result = new DefaultModelBuildingResult();
DefaultModelProblemCollector problems = new DefaultModelProblemCollector( result );
DefaultProfileActivationContext profileActivationContext = getProfileActivationContext( request );
problems.setSource( "(external profiles)" );
List<Profile> activeExternalProfiles =
profileSelector.getActiveProfiles( request.getProfiles(), profileActivationContext, problems );
result.setActiveExternalProfiles( activeExternalProfiles );
if ( !activeExternalProfiles.isEmpty() )
{
Properties profileProps = new Properties();
for ( Profile profile : activeExternalProfiles )
{
profileProps.putAll( profile.getProperties() );
}
profileProps.putAll( profileActivationContext.getUserProperties() );
profileActivationContext.setUserProperties( profileProps );
}
Model inputModel = readModel( request.getModelSource(), request.getPomFile(), request, problems );
problems.setRootModel( inputModel );
ModelData resultData = new ModelData( request.getModelSource(), inputModel );
ModelData superData = new ModelData( null, getSuperModel() );
Collection<String> parentIds = new LinkedHashSet<String>();
parentIds.add( ModelProblemUtils.toId( inputModel ) );
List<ModelData> lineage = new ArrayList<ModelData>();
for ( ModelData currentData = resultData; currentData != null; )
{
lineage.add( currentData );
Model tmpModel = currentData.getModel();
Model rawModel = tmpModel.clone();
currentData.setRawModel( rawModel );
problems.setSource( tmpModel );
modelNormalizer.mergeDuplicates( tmpModel, request, problems );
profileActivationContext.setProjectProperties( tmpModel.getProperties() );
List<Profile> activePomProfiles =
profileSelector.getActiveProfiles( rawModel.getProfiles(), profileActivationContext, problems );
currentData.setActiveProfiles( activePomProfiles );