o adjusting the request to hold the upfront repositories that can be taken out of profiles

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@582071 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2007-10-05 04:03:10 +00:00
parent 5d2c433ba9
commit 112e69aa0e
3 changed files with 113 additions and 37 deletions

View File

@ -108,6 +108,8 @@ public class DefaultMavenExecutionRequest
private ProfileManager profileManager;
private List remoteRepositories;
/**
* Suppress SNAPSHOT updates.
* @issue MNG-2681
@ -567,4 +569,21 @@ public class DefaultMavenExecutionRequest
return this;
}
public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository )
{
if ( remoteRepositories == null )
{
remoteRepositories = new ArrayList();
}
remoteRepositories.add( repository );
return this;
}
public List getRemoteRepositories()
{
return remoteRepositories;
}
}

View File

@ -195,4 +195,7 @@ public interface MavenExecutionRequest
File getGlobalSettingsFile();
MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile );
MavenExecutionRequest addRemoteRepository( ArtifactRepository repository );
List getRemoteRepositories();
}

View File

@ -30,6 +30,7 @@ import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.embedder.MavenEmbedderException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
import org.apache.maven.monitor.event.DefaultEventMonitor;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.profiles.DefaultProfileManager;
@ -61,7 +62,7 @@ import java.util.List;
/**
* Things that we deal with in this populator to ensure that we have a valid {@MavenExecutionRequest}
*
* <p/>
* - POM
* - Settings
* - Local Repository
@ -110,14 +111,85 @@ public class DefaultMavenExecutionRequestPopulator
profileManager( request, configuration );
processSettings( request, configuration );
return request;
}
private void processSettings( MavenExecutionRequest request,
Configuration configuration )
{
ProfileManager profileManager = request.getProfileManager();
Settings settings = request.getSettings();
List settingsProfiles = settings.getProfiles();
if ( settingsProfiles != null && !settingsProfiles.isEmpty() )
{
List settingsActiveProfileIds = settings.getActiveProfiles();
profileManager.explicitlyActivate( settingsActiveProfileIds );
for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); )
{
org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile) it.next();
Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
profileManager.addProfile( profile );
// We need to convert profile repositories to artifact repositories
for ( Iterator j = profile.getRepositories().iterator(); j.hasNext(); )
{
Repository r = (Repository) j.next();
ArtifactRepositoryPolicy releases = new ArtifactRepositoryPolicy();
if ( r.getReleases() != null )
{
releases.setChecksumPolicy( r.getReleases().getChecksumPolicy() );
releases.setUpdatePolicy( r.getReleases().getUpdatePolicy() );
}
else
{
releases.setChecksumPolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY );
releases.setUpdatePolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
}
ArtifactRepositoryPolicy snapshots = new ArtifactRepositoryPolicy();
if ( r.getSnapshots() != null )
{
snapshots.setChecksumPolicy( r.getSnapshots().getChecksumPolicy() );
snapshots.setUpdatePolicy( r.getSnapshots().getUpdatePolicy() );
}
else
{
snapshots.setChecksumPolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY );
snapshots.setUpdatePolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
}
ArtifactRepository ar = artifactRepositoryFactory.createArtifactRepository( r.getId(), r.getUrl(),
defaultArtifactRepositoryLayout, snapshots, releases );
request.addRemoteRepository( ar );
}
}
}
}
// ------------------------------------------------------------------------
// POM
// ------------------------------------------------------------------------
private void pom( MavenExecutionRequest request, Configuration configuration )
private void pom( MavenExecutionRequest request,
Configuration configuration )
{
// ------------------------------------------------------------------------
// POM
@ -149,7 +221,8 @@ public class DefaultMavenExecutionRequestPopulator
// Settings
// ------------------------------------------------------------------------
private void settings( MavenExecutionRequest request, Configuration configuration )
private void settings( MavenExecutionRequest request,
Configuration configuration )
{
// ------------------------------------------------------------------------
// Settings
@ -188,7 +261,8 @@ public class DefaultMavenExecutionRequestPopulator
// Local Repository
// ------------------------------------------------------------------------
private void localRepository( MavenExecutionRequest request, Configuration configuration )
private void localRepository( MavenExecutionRequest request,
Configuration configuration )
throws MavenEmbedderException
{
// ------------------------------------------------------------------------
@ -206,7 +280,8 @@ public class DefaultMavenExecutionRequestPopulator
}
public ArtifactRepository createLocalRepository( Settings settings, Configuration configuration )
public ArtifactRepository createLocalRepository( Settings settings,
Configuration configuration )
throws MavenEmbedderException
{
String localRepositoryPath = null;
@ -314,7 +389,8 @@ public class DefaultMavenExecutionRequestPopulator
// Snapshot Policy
// ------------------------------------------------------------------------
private void snapshotPolicy( MavenExecutionRequest request, Configuration configuration )
private void snapshotPolicy( MavenExecutionRequest request,
Configuration configuration )
{
// ------------------------------------------------------------------------
// Snapshot Repository Update Policies
@ -347,7 +423,8 @@ public class DefaultMavenExecutionRequestPopulator
// Checksum Policy
// ------------------------------------------------------------------------
private void checksumPolicy( MavenExecutionRequest request, Configuration configuration )
private void checksumPolicy( MavenExecutionRequest request,
Configuration configuration )
{
// ------------------------------------------------------------------------
// Repository Checksum Policies
@ -362,7 +439,8 @@ public class DefaultMavenExecutionRequestPopulator
// Artifact Transfer Mechanism
// ------------------------------------------------------------------------
private void artifactTransferMechanism( MavenExecutionRequest request, Configuration configuration )
private void artifactTransferMechanism( MavenExecutionRequest request,
Configuration configuration )
throws MavenEmbedderException
{
// ------------------------------------------------------------------------
@ -477,7 +555,8 @@ public class DefaultMavenExecutionRequestPopulator
// Eventing
// ------------------------------------------------------------------------
private void eventing( MavenExecutionRequest request, Configuration configuration )
private void eventing( MavenExecutionRequest request,
Configuration configuration )
{
// ------------------------------------------------------------------------
// Event Monitor/Logging
@ -499,7 +578,8 @@ public class DefaultMavenExecutionRequestPopulator
// Profile Manager
// ------------------------------------------------------------------------
private void profileManager( MavenExecutionRequest request, Configuration configuration )
private void profileManager( MavenExecutionRequest request,
Configuration configuration )
{
// ------------------------------------------------------------------------
// Profile Manager
@ -509,10 +589,6 @@ public class DefaultMavenExecutionRequestPopulator
ProfileManager globalProfileManager = new DefaultProfileManager( container );
loadSettingsProfiles(
globalProfileManager,
request.getSettings() );
globalProfileManager.explicitlyActivate( request.getActiveProfiles() );
globalProfileManager.explicitlyDeactivate( request.getInactiveProfiles() );
@ -529,26 +605,4 @@ public class DefaultMavenExecutionRequestPopulator
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
public void loadSettingsProfiles( ProfileManager profileManager,
Settings settings )
{
List settingsProfiles = settings.getProfiles();
if ( settingsProfiles != null && !settingsProfiles.isEmpty() )
{
List settingsActiveProfileIds = settings.getActiveProfiles();
profileManager.explicitlyActivate( settingsActiveProfileIds );
for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); )
{
org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile) it.next();
Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
profileManager.addProfile( profile );
}
}
}
}