You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2005/12/09 06:57:15 UTC

svn commit: r355387 - in /maven/components/trunk/maven-project/src: main/java/org/apache/maven/profiles/activation/ main/resources/META-INF/plexus/ test/java/org/apache/maven/profiles/

Author: jdcasey
Date: Thu Dec  8 21:57:05 2005
New Revision: 355387

URL: http://svn.apache.org/viewcvs?rev=355387&view=rev
Log:
PR: MNG-1509
Submitted By: Bernd Bohmann
Reviewed By: John Casey

Applied patches. These patches added the OS activator to the component descriptor, fixed the activation implementation for it, and finally added a unit test for OS activation.

Modified:
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java
    maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java?rev=355387&r1=355386&r2=355387&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.java Thu Dec  8 21:57:05 2005
@@ -35,17 +35,28 @@
     {
         Activation activation = profile.getActivation();
         ActivationOS os = activation.getOs();
-        
-        boolean hasNonNull = ensureAtLeastOneNonNull( os );
-        
-        boolean isFamily = determineFamilyMatch( os.getFamily() );
-        boolean isName = determineNameMatch( os.getName() );
-        boolean isArch = determineArchMatch( os.getArch() );
-        boolean isVersion = determineVersionMatch( os.getVersion() );
-        
-        return hasNonNull && isFamily && isName && isArch && isVersion;
+
+        boolean result = ensureAtLeastOneNonNull( os );
+
+        if ( result && os.getFamily() != null )
+        {
+            result = determineFamilyMatch( os.getFamily() );
+        }
+        if ( result && os.getName() != null )
+        {
+            result = determineNameMatch( os.getName() );
+        }
+        if ( result && os.getArch() != null )
+        {
+            result = determineArchMatch( os.getArch() );
+        }
+        if ( result && os.getVersion() != null )
+        {
+            result = determineVersionMatch( os.getVersion() );
+        }
+        return result;
     }
-    
+
     private boolean ensureAtLeastOneNonNull( ActivationOS os )
     {
         return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null;
@@ -107,9 +118,9 @@
             reverse = true;
             test = test.substring( 1 );
         }
-        
+
         boolean result = Os.isName( test );
-        
+
         if ( reverse )
         {
             return !result;

Modified: maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml?rev=355387&r1=355386&r2=355387&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml Thu Dec  8 21:57:05 2005
@@ -122,6 +122,16 @@
      -->
     <component>
       <role>org.apache.maven.profiles.activation.ProfileActivator</role>
+      <role-hint>os</role-hint>
+      <implementation>org.apache.maven.profiles.activation.OperatingSystemProfileActivator</implementation>
+    </component>
+    <!--
+     |
+     |
+     |
+     -->
+    <component>
+      <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>file</role-hint>
       <implementation>org.apache.maven.profiles.activation.FileProfileActivator</implementation>
     </component>

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java?rev=355387&r1=355386&r2=355387&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java Thu Dec  8 21:57:05 2005
@@ -3,6 +3,7 @@
 import org.apache.maven.model.Activation;
 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.codehaus.plexus.PlexusTestCase;
 
@@ -154,6 +155,31 @@
         
         assertNotNull( active );
         assertEquals( 0, active.size() );
+    }
+
+   public void testOsActivationProfile() throws ProfileActivationException
+    {
+        Profile osActivated = new Profile();
+        osActivated.setId("os-profile");
+
+        Activation osActivation = new Activation();
+
+        ActivationOS activationOS = new ActivationOS();
+
+        activationOS.setName("!dddd");
+
+        osActivation.setOs(activationOS);
+
+        osActivated.setActivation(osActivation);
+
+        ProfileManager profileManager = new DefaultProfileManager(getContainer());
+
+        profileManager.addProfile(osActivated);
+
+        List active = profileManager.getActiveProfiles();
+
+        assertNotNull( active );
+        assertEquals( 1, active.size() );
     }
 
 }