Author: brett Date: Wed Mar 4 13:14:32 2009 New Revision: 749997 URL: http://svn.apache.org/viewvc?rev=749997&view=rev Log: [MNG-3641] move profile activation check to span all projects at once in a reactor
Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=749997&r1=749996&r2=749997&view=diff ============================================================================== --- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original) +++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Wed Mar 4 13:14:32 2009 @@ -27,9 +27,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Properties; +import java.util.Set; import java.util.TimeZone; import org.apache.maven.artifact.manager.DefaultWagonManager; @@ -48,6 +50,7 @@ import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleExecutor; +import org.apache.maven.model.Profile; import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.MavenEvents; @@ -328,6 +331,12 @@ throw new BuildFailureException( e.getMessage(), e ); } + // -------------------------------------------------------------------------------- + // MNG-3641: print a warning if one of the profiles to be activated explicitly + // was not activated + + validateActivatedProfiles( globalProfileManager, projects ); + if ( rm.hasMultipleProjects() ) { getLogger().info( "Reactor build order: " ); @@ -348,6 +357,35 @@ return rm; } + private void validateActivatedProfiles( ProfileManager globalProfileManager, List projects ) + { + if ( globalProfileManager != null ) + { + // get all activated profile ids + Set activeProfileIds = new HashSet(); + + for ( Iterator i = projects.iterator(); i.hasNext(); ) + { + MavenProject project = (MavenProject) i.next(); + + for ( Iterator j = project.getActiveProfiles().iterator(); j.hasNext(); ) + { + activeProfileIds.add( ( (Profile) j.next() ).getId() ); + } + } + + for ( Iterator i = globalProfileManager.getExplicitlyActivatedIds().iterator(); i.hasNext(); ) + { + String explicitProfileId = (String) i.next(); + + if ( !activeProfileIds.contains( explicitProfileId ) ) + { + getLogger().warn( "\n\tProfile with id: \'" + explicitProfileId + "\' has not been activated.\n" ); + } + } + } + } + private MavenProject getSuperProject( MavenExecutionRequest request ) throws MavenExecutionException { Modified: maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=749997&r1=749996&r2=749997&view=diff ============================================================================== --- maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original) +++ maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Wed Mar 4 13:14:32 2009 @@ -989,32 +989,6 @@ List injectedProfiles = injectActiveProfiles( profileMgr, model ); activeProfiles.addAll( injectedProfiles ); - - // -------------------------------------------------------------------------------- - // MNG-3641: print a warning if one of the profiles to be activated explicitly - // was not activated - - if ( config != null && config.getGlobalProfileManager() != null ) - { - // get all activated profile ids - List activeProfileIds = new ArrayList(); - - for ( Iterator it = activeProfiles.iterator(); it.hasNext(); ) - { - activeProfileIds.add( ( (Profile) it.next() ).getId() ); - } - - for ( Iterator it = config.getGlobalProfileManager().getExplicitlyActivatedIds().iterator(); it.hasNext(); ) - { - String explicitProfileId = (String) it.next(); - - if ( !activeProfileIds.contains( explicitProfileId ) ) - { - getLogger().warn( "Profile with id: \'" + explicitProfileId + "\' has not been activated." ); - } - - } - } // --------------------------------------------------------------------------------