Fixed usage of repositories from active profiles in settings.xml for model-lineage building, which is fundamental to the build.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@583248 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-10-09 18:10:05 +00:00
parent 975862e353
commit 616c6f1c0f
3 changed files with 37 additions and 15 deletions

View File

@ -140,11 +140,15 @@ public class DefaultProfileAdvisor
return profileManager;
}
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File projectDir,
List explicitlyActiveIds, List explicitlyInactiveIds )
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( ProfileManager profileManager,
String modelId )
throws ProjectBuildingException
{
ProfileManager profileManager = buildProfileManager( model, projectDir, explicitlyActiveIds, explicitlyInactiveIds );
if ( profileManager == null )
{
return new LinkedHashSet();
}
List activeExternalProfiles;
{
@ -154,7 +158,7 @@ public class DefaultProfileAdvisor
}
catch ( ProfileActivationException e )
{
throw new ProjectBuildingException( model.getId(),
throw new ProjectBuildingException( modelId,
"Failed to compute active profiles for repository aggregation.", e );
}
@ -175,7 +179,7 @@ public class DefaultProfileAdvisor
}
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( model.getId(), e.getMessage(), e );
throw new ProjectBuildingException( modelId, e.getMessage(), e );
}
remoteRepositories.add( artifactRepo );
@ -186,6 +190,15 @@ public class DefaultProfileAdvisor
}
}
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File projectDir,
List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException
{
ProfileManager profileManager = buildProfileManager( model, projectDir, explicitlyActiveIds, explicitlyInactiveIds );
return getArtifactRepositoriesFromActiveProfiles( profileManager, model.getId() );
}
private void loadExternalProjectProfiles( ProfileManager profileManager, Model model, File projectDir )
throws ProjectBuildingException
{
@ -199,7 +212,7 @@ public class DefaultProfileAdvisor
{
List active = root.getActiveProfiles();
if ( active != null && !active.isEmpty() )
if ( ( active != null ) && !active.isEmpty() )
{
profileManager.explicitlyActivate( root.getActiveProfiles() );
}
@ -231,7 +244,7 @@ public class DefaultProfileAdvisor
public void contextualize( Context context )
throws ContextException
{
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}

View File

@ -28,18 +28,21 @@ import java.util.LinkedHashSet;
import java.util.List;
/**
*
*
* @author jdcasey
*
*/
public interface ProfileAdvisor
{
String ROLE = ProfileAdvisor.class.getName();
LinkedHashSet getArtifactRepositoriesFromActiveProfiles( ProfileManager profileManager, String modelId )
throws ProjectBuildingException;
LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File projectDir, List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException;
List applyActivatedProfiles( Model model, File projectDir, List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException;

View File

@ -231,8 +231,6 @@ public class DefaultModelLineageBuilder
File projectDir = pomFile == null ? null : pomFile.getParentFile();
loadActiveProfileRepositories( repositories, model, externalProfileManager, projectDir );
Set artifactRepositories = null;
if ( repositories != null )
@ -242,6 +240,8 @@ public class DefaultModelLineageBuilder
List lastRemoteRepos = oldArtifactRepositories;
List remoteRepos = mavenTools.buildArtifactRepositories( repositories );
loadActiveProfileRepositories( remoteRepos, model, externalProfileManager, projectDir );
artifactRepositories = new LinkedHashSet( remoteRepos.size() + oldArtifactRepositories.size() );
artifactRepositories.addAll( remoteRepos );
@ -275,9 +275,15 @@ public class DefaultModelLineageBuilder
explicitlyInactive = Collections.EMPTY_LIST;
}
LinkedHashSet profileRepos = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, projectDir,
LinkedHashSet profileRepos = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( profileManager, model.getId() );
getLogger().debug( "Got the following repos from global profile manager:\n\n" + profileRepos );
profileRepos.addAll( profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, projectDir,
explicitlyActive,
explicitlyInactive );
explicitlyInactive ) );
getLogger().debug( "Got the following repos from all profile managers:\n\n" + profileRepos );
if ( !profileRepos.isEmpty() )
{