You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2008/02/19 23:20:27 UTC

svn commit: r629249 - in /maven/plugins/trunk/maven-invoker-plugin/src: main/java/org/apache/maven/plugin/invoker/ site/apt/ test/java/org/apache/maven/plugin/invoker/

Author: olamy
Date: Tue Feb 19 14:20:24 2008
New Revision: 629249

URL: http://svn.apache.org/viewvc?rev=629249&view=rev
Log:
[MINVOKER-23] Use project.getProperties() when performing IT pom interpolations
Submitted by John Allen

Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/CompositeMap.java
    maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt
    maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/ExtendedMavenProjectStub.java
    maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InterpolationTest.java

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/CompositeMap.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/CompositeMap.java?rev=629249&r1=629248&r2=629249&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/CompositeMap.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/CompositeMap.java Tue Feb 19 14:20:24 2008
@@ -34,18 +34,18 @@
 class CompositeMap
     implements Map
 {
-    
+
     private MavenProject mavenProject;
-    
+
     private Properties properties;
-    
+
     protected CompositeMap(MavenProject mavenProject, Properties properties)
     {
         this.mavenProject = mavenProject;
         this.properties = properties == null ? new Properties() : properties;
     }
 
-    /** 
+    /**
      * @see java.util.Map#clear()
      */
     public void clear()
@@ -54,7 +54,7 @@
 
     }
 
-    /** 
+    /**
      * @see java.util.Map#containsKey(java.lang.Object)
      */
     public boolean containsKey( Object key )
@@ -70,12 +70,13 @@
         }
         catch ( Exception e )
         {
-            // uhm do we have to throw a RuntimeException here ? 
+            // uhm do we have to throw a RuntimeException here ?
         }
-        return properties.containsKey( key );
+
+        return ( mavenProject.getProperties().containsKey( key ) || properties.containsKey( key ) );
     }
 
-    /** 
+    /**
      * @see java.util.Map#containsValue(java.lang.Object)
      */
     public boolean containsValue( Object value )
@@ -83,7 +84,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#entrySet()
      */
     public Set entrySet()
@@ -91,7 +92,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#get(java.lang.Object)
      */
     public Object get( Object key )
@@ -110,20 +111,24 @@
         }
         catch ( Exception e )
         {
-            // uhm do we have to throw a RuntimeException here ? 
+            // uhm do we have to throw a RuntimeException here ?
         }
-        return properties.get( key );
+
+        Object value = properties.get( key );
+
+        return ( value != null ? value : this.mavenProject.getProperties().get( key ) );
+
     }
 
-    /** 
+    /**
      * @see java.util.Map#isEmpty()
      */
     public boolean isEmpty()
     {
-        return this.mavenProject == null && this.properties.isEmpty();
+        return this.mavenProject == null && this.mavenProject.getProperties().isEmpty() && this.properties.isEmpty();
     }
 
-    /** 
+    /**
      * @see java.util.Map#keySet()
      */
     public Set keySet()
@@ -131,7 +136,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#put(java.lang.Object, java.lang.Object)
      */
     public Object put( Object key, Object value )
@@ -139,7 +144,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#putAll(java.util.Map)
      */
     public void putAll( Map t )
@@ -147,7 +152,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#remove(java.lang.Object)
      */
     public Object remove( Object key )
@@ -155,7 +160,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#size()
      */
     public int size()
@@ -163,7 +168,7 @@
         throw new UnsupportedOperationException();
     }
 
-    /** 
+    /**
      * @see java.util.Map#values()
      */
     public Collection values()
@@ -171,6 +176,6 @@
         throw new UnsupportedOperationException();
     }
 
-    
-    
+
+
 }

Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt?rev=629249&r1=629248&r2=629249&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt Tue Feb 19 14:20:24 2008
@@ -22,7 +22,9 @@
     
   * values from the project pom (you must use @pom.groupId@ notation in your pom file)
   
-  * In the plugin configuration you can add some properties in a interpolationsProperties element    
+  * In the plugin configuration you can add some properties in a interpolationsProperties element
+  
+  * properties from pom.properties      
 
 * Running only some tests
 

Modified: maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/ExtendedMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/ExtendedMavenProjectStub.java?rev=629249&r1=629248&r2=629249&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/ExtendedMavenProjectStub.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/ExtendedMavenProjectStub.java Tue Feb 19 14:20:24 2008
@@ -21,6 +21,8 @@
 import org.apache.maven.model.Scm;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 
+import java.util.Properties;
+
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
  * @since 22 nov. 07
@@ -30,6 +32,7 @@
     extends MavenProjectStub
 {
     private Scm scm;
+    private Properties properties;
 
     public Scm getScm()
     {
@@ -39,5 +42,15 @@
     public void setScm( Scm scm )
     {
         this.scm = scm;
+    }
+
+    public Properties getProperties()
+    {
+        return properties;
+    }
+
+    public void setProperties( Properties properties )
+    {
+        this.properties= properties;
     }
 }

Modified: maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InterpolationTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InterpolationTest.java?rev=629249&r1=629248&r2=629249&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InterpolationTest.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InterpolationTest.java Tue Feb 19 14:20:24 2008
@@ -37,19 +37,22 @@
 public class InterpolationTest
     extends AbstractMojoTestCase
 {
-    
+
     protected MavenProjectStub buildMavenProjectStub()
     {
         ExtendedMavenProjectStub project = new ExtendedMavenProjectStub();
         project.setVersion( "1.0-SNAPSHOT" );
         project.setArtifactId( "foo" );
         project.setGroupId( "bar" );
+        Properties properties = new Properties();
+        properties.put( "fooOnProject", "barOnProject" );
+        project.setProperties( properties );
         Scm scm = new Scm();
         scm.setConnection( "http://blabla" );
         project.setScm( scm );
         return project;
     }
-    
+
     public void testCompositeMap()
         throws Exception
     {
@@ -62,8 +65,9 @@
         assertEquals( "bar", compositeMap.get( "foo" ) );
         assertEquals( "bar", compositeMap.get( "pom.groupId" ) );
         assertEquals( "http://blabla", compositeMap.get( "pom.scm.connection" ) );
+        assertEquals( "barOnProject", compositeMap.get( "fooOnProject" ) );
     }
-    
+
     public void testInterpolationGoalsFile()
         throws Exception
     {
@@ -81,7 +85,7 @@
         assertEquals( "clean", goals.get( 0 ) );
         assertEquals( "bar:foo:1.0-SNAPSHOT:mygoal", goals.get( 1 ) );
     }
-    
+
     public void testPomInterpolation()
         throws Exception
     {
@@ -125,7 +129,7 @@
             }
         }
     }
-    
+
     public void testProfilesFromFile()
         throws Exception
     {
@@ -137,7 +141,7 @@
         assertEquals( 2, profiles.size() );
         assertTrue( profiles.contains( "foo" ) );
     }
-    
+
     public void testEmptyProfilesFromFile()
         throws Exception
     {
@@ -151,8 +155,8 @@
         assertFalse( profiles.contains( "zloug" ) );
         assertEquals( 0, profiles.size() );
 
-    }    
-    
+    }
+
     public void testProfilesWithNoFile()
         throws Exception
     {
@@ -166,5 +170,5 @@
         assertTrue( profiles.contains( "zloug" ) );
         assertEquals( 1, profiles.size() );
 
-    }     
+    }
 }