maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r749717 - in /maven/components/trunk: maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/ maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ maven-project/src/test/java/org/apache/maven/p...
Date Tue, 03 Mar 2009 19:57:01 GMT
Author: sisbell
Date: Tue Mar  3 19:57:01 2009
New Revision: 749717

URL: http://svn.apache.org/viewvc?rev=749717&view=rev
Log:
Profile tests. Fixes for negation activation.

Added:
    maven/components/trunk/maven-project/src/test/resources-project-builder/profile-module/
    maven/components/trunk/maven-project/src/test/resources-project-builder/profile-module/pom.xml
    maven/components/trunk/maven-project/src/test/resources-project-builder/profile-repository-override/
Modified:
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java?rev=749717&r1=749716&r2=749717&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java
Tue Mar  3 19:57:01 2009
@@ -10,20 +10,35 @@
 public class JdkMatcher implements ActiveProfileMatcher {
     //TODO: Ranges
     public boolean isMatch(ModelContainer modelContainer, List<InterpolatorProperty>
properties) {
-        if(modelContainer == null ) {
+        if(modelContainer == null )
+        {
             throw new IllegalArgumentException("modelContainer: null");
         }
 
-        if(properties == null) {
+        if(properties == null)
+        {
             return false;
         }
 
-        for(InterpolatorProperty property : properties) {
-            if(property.getKey().equals("${java.specification.version}")) {
+        for(InterpolatorProperty property : properties)
+        {
+            if(property.getKey().equals("${java.specification.version}"))
+            {
                 String version = property.getValue();
-                for(ModelProperty modelProperty : modelContainer.getProperties()) {
-                    if(modelProperty.getUri().equals(ProjectUri.Profiles.Profile.Activation.jdk))
{
-                        return version.equals(modelProperty.getValue());
+                for(ModelProperty modelProperty : modelContainer.getProperties())
+                {
+
+                    if(modelProperty.getUri().equals(ProjectUri.Profiles.Profile.Activation.jdk))
+                    {
+                        if(modelProperty.getValue().startsWith("!"))
+                        {
+                            return !version.equals(modelProperty.getValue().replaceFirst("!",
""));
+                        }
+                        else
+                        {
+                            return version.equals(modelProperty.getValue());
+                        }
+
                     }
                 }
                 return false;   

Modified: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java?rev=749717&r1=749716&r2=749717&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
Tue Mar  3 19:57:01 2009
@@ -36,6 +36,39 @@
     }
 
     @org.junit.Test
+    public void jdkVersionDoesNotMatchWithNotSymbol()  {
+        List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
+        modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.xUri, null));
+        modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.Activation.xUri
, null));
+        modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.Activation.jdk
, "!1.5"));
+
+        ModelContainer modelContainer = new DefaultModelContainer(modelProperties);
+
+        List<InterpolatorProperty> props = new ArrayList<InterpolatorProperty>();
+        props.add(new InterpolatorProperty("${java.specification.version}" , "1.5"));
+
+        JdkMatcher matcher = new JdkMatcher();
+        assertTrue(!matcher.isMatch(modelContainer, props));
+    }
+
+    @org.junit.Test
+    public void jdkVersionDoesMatchWithNotSymbol()  {
+        List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
+        modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.xUri, null));
+        modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.Activation.xUri
, null));
+        modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.Activation.jdk
, "!1.5"));
+
+        ModelContainer modelContainer = new DefaultModelContainer(modelProperties);
+
+        List<InterpolatorProperty> props = new ArrayList<InterpolatorProperty>();
+        props.add(new InterpolatorProperty("${java.specification.version}" , "1.6"));
+
+        JdkMatcher matcher = new JdkMatcher();
+        assertTrue(matcher.isMatch(modelContainer, props));
+    }
+
+
+    @org.junit.Test
     public void jdkVersionNotMatches()  {
         List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
         modelProperties.add(new ModelProperty(ProjectUri.Profiles.Profile.xUri, null));

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=749717&r1=749716&r2=749717&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
(original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
Tue Mar  3 19:57:01 2009
@@ -79,6 +79,19 @@
     */
 
     /**
+     * Tests that modules is not overriden by profile
+     * 
+     * @throws Exception
+     */
+    public void testProfileModules()
+        throws Exception
+    {
+        PomTestWrapper pom = buildPomFromMavenProject( "profile-module", "a" );
+        assertEquals( "test-prop", pom.getValue( "properties[1]/b" ) );//verifies profile
applied
+        assertEquals( "test-module", pom.getValue( "modules[1]" ) );
+    }
+
+    /**
      * Will throw exception if doesn't find parent(s) in build
      *
      * @throws Exception

Added: maven/components/trunk/maven-project/src/test/resources-project-builder/profile-module/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/resources-project-builder/profile-module/pom.xml?rev=749717&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/test/resources-project-builder/profile-module/pom.xml
(added)
+++ maven/components/trunk/maven-project/src/test/resources-project-builder/profile-module/pom.xml
Tue Mar  3 19:57:01 2009
@@ -0,0 +1,18 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>gid</groupId>
+  <artifactId>aid</artifactId>
+  <version>1.0</version>
+    <packaging>pom</packaging>
+    <modules>
+        <module>test-module</module>
+    </modules>
+    <profiles>
+        <profile>
+            <id>a</id>
+            <properties>
+                <b>test-prop</b>
+            </properties>
+        </profile>
+    </profiles>
+</project>
\ No newline at end of file



Mime
View raw message