You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2009/05/15 17:49:27 UTC
svn commit: r775200 -
/maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
Author: jvanzyl
Date: Fri May 15 15:49:27 2009
New Revision: 775200
URL: http://svn.apache.org/viewvc?rev=775200&view=rev
Log:
o removing the profile manager and profile activation context from the embedder code, it can all be handled in the core having the active/inactive profile ids on hand along with all the profiles that are available from any external sources like the settings.xml
Modified:
maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
Modified: maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java?rev=775200&r1=775199&r2=775200&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java (original)
+++ maven/components/branches/MNG-2766/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java Fri May 15 15:49:27 2009
@@ -28,12 +28,6 @@
import org.apache.maven.embedder.Configuration;
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.profiles.DefaultProfileManager;
-import org.apache.maven.profiles.ProfileActivationContext;
-import org.apache.maven.profiles.ProfileActivationException;
-import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Mirror;
@@ -81,8 +75,6 @@
toolchains( request, configuration );
- profileManager( request, configuration );
-
processSettings( request, configuration );
return request;
@@ -144,72 +136,34 @@
}
}
-
+ // Process plugin groups
+ // Get profile models
+ // Get active profiles
private void processSettings( MavenExecutionRequest request, Configuration configuration )
throws MavenEmbedderException
{
- ProfileManager profileManager = request.getProfileManager();
-
Settings settings = request.getSettings();
request.setPluginGroups( settings.getPluginGroups() );
List<org.apache.maven.settings.Profile> settingsProfiles = settings.getProfiles();
- List<String> settingsActiveProfileIds = settings.getActiveProfiles();
-
- if ( settingsActiveProfileIds != null )
- {
- for ( String profileId : settingsActiveProfileIds )
- {
- profileManager.getProfileActivationContext().setActive( profileId );
- }
- }
-
+ // We just need to keep track of what profiles are being activated by the settings. We don't need to process
+ // them here. This should be taken care of by the project builder.
+ //
+ request.addActiveProfiles( settings.getActiveProfiles() );
+
+ // We only need to take the profiles and make sure they are available when the calculation of the active profiles
+ // is determined.
+ //
if ( ( settingsProfiles != null ) && !settingsProfiles.isEmpty() )
{
for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
{
- Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
-
- profileManager.addProfile( profile );
- }
-
- // We need to convert profile repositories to artifact repositories
- try
- {
- for ( Profile profile : profileManager.getActiveProfiles() )
- {
- for ( Repository r : profile.getRepositories() )
- {
- try
- {
- request.addRemoteRepository( repositorySystem.buildArtifactRepository( r ) );
- }
- catch ( InvalidRepositoryException e )
- {
- throw new MavenEmbedderException( "Cannot create remote repository " + r.getId(), e );
- }
- }
- for ( Repository r : profile.getPluginRepositories() )
- {
- try
- {
- request.addRemoteRepository( repositorySystem.buildArtifactRepository( r ) );
- }
- catch ( InvalidRepositoryException e )
- {
- throw new MavenEmbedderException( "Cannot create remote repository " + r.getId(), e );
- }
- }
- }
- }
- catch ( ProfileActivationException e )
- {
- throw new MavenEmbedderException( "Cannot determine active profiles", e );
+ request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) );
}
}
-
+
injectDefaultRepositories( request );
processRepositoriesInSettings( request, configuration );
@@ -396,31 +350,6 @@
}
}
- // ------------------------------------------------------------------------
- // Profile Manager
- // ------------------------------------------------------------------------
-
- private void profileManager( MavenExecutionRequest request, Configuration configuration )
- {
- // ------------------------------------------------------------------------
- // Profile Manager
- // ------------------------------------------------------------------------
-
- ProfileActivationContext activationContext = request.getProfileActivationContext();
- if ( activationContext == null )
- {
- activationContext = new ProfileActivationContext( request.getProperties(), false );
- }
-
- activationContext.setExplicitlyActiveProfileIds( request.getActiveProfiles() );
- activationContext.setExplicitlyInactiveProfileIds( request.getInactiveProfiles() );
-
- ProfileManager globalProfileManager = new DefaultProfileManager( activationContext );
-
- request.setProfileManager( globalProfileManager );
- request.setProfileActivationContext( activationContext );
- }
-
private void toolchains( MavenExecutionRequest request, Configuration configuration )
{
toolchainsBuilder.setUserToolchainsFile( request.getUserToolchainsFile() );