maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r633762 - in /maven/components/branches/maven-2.0.x/maven-project/src: main/java/org/apache/maven/profiles/DefaultProfileManager.java test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java
Date Wed, 05 Mar 2008 04:16:16 GMT
Author: brett
Date: Tue Mar  4 20:16:15 2008
New Revision: 633762

URL: http://svn.apache.org/viewvc?rev=633762&view=rev
Log:
[MNG-2234] activate profiles that are not present in the settings so that they can be defined
in the POM

Modified:
    maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
    maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java

Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=633762&r1=633761&r2=633762&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
(original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
Tue Mar  4 20:16:15 2008
@@ -332,12 +332,12 @@
 
         List settingsProfiles = settings.getProfiles();
 
-        if ( settingsProfiles != null && !settingsProfiles.isEmpty() )
-        {
-            List settingsActiveProfileIds = settings.getActiveProfiles();
+        List settingsActiveProfileIds = settings.getActiveProfiles();
 
-            explicitlyActivate( settingsActiveProfileIds );
+        explicitlyActivate( settingsActiveProfileIds );
 
+        if ( settingsProfiles != null && !settingsProfiles.isEmpty() )
+        {
             for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); )
             {
                 org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile)
it.next();

Modified: maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java?rev=633762&r1=633761&r2=633762&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java
(original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java
Tue Mar  4 20:16:15 2008
@@ -20,10 +20,11 @@
  */
 
 import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationOS;
 import org.apache.maven.model.ActivationProperty;
 import org.apache.maven.model.Profile;
-import org.apache.maven.model.ActivationOS;
 import org.apache.maven.profiles.activation.ProfileActivationException;
+import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusTestCase;
 
 import java.util.List;
@@ -31,6 +32,35 @@
 public class DefaultProfileManagerTest
     extends PlexusTestCase
 {
+    public void testShouldActivateNonExistantSettingsProfile()
+        throws ProfileActivationException
+    {
+        // MNG-2234 - we should activate profiles that don't exist yet so that they can be
defined by a POM.
+        Settings settings = new Settings();
+        settings.addActiveProfile( "testProfile" );
+
+        ProfileManager profileManager = new DefaultProfileManager( getContainer(), settings
);
+
+        List activeIds = profileManager.getExplicitlyActivatedIds();
+
+        assertNotNull( activeIds );
+        assertEquals( 1, activeIds.size() );
+        assertEquals( "testProfile", activeIds.get( 0 ) );
+
+        List activeProfiles = profileManager.getActiveProfiles();
+        assertTrue( activeProfiles.isEmpty() );
+
+        Profile p = new Profile();
+        p.setId( "testProfile" );
+        profileManager.addProfile( p );
+
+        activeProfiles = profileManager.getActiveProfiles();
+
+        assertNotNull( activeProfiles );
+        assertEquals( 1, activeProfiles.size() );
+        assertEquals( "testProfile", ( (Profile) activeProfiles.get( 0 ) ).getId() );
+    }
+
     public void testShouldActivateDefaultProfile()
         throws ProfileActivationException
     {



Mime
View raw message