You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2007/10/24 22:51:39 UTC

svn commit: r588013 - in /maven/plugins/trunk/maven-war-plugin: pom.xml src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java src/main/java/org/apache/maven/plugin/war/util/CompositeMap.java

Author: snicoll
Date: Wed Oct 24 13:51:38 2007
New Revision: 588013

URL: http://svn.apache.org/viewvc?rev=588013&view=rev
Log:
MWAR-89: improved filtering capabilities
Submitted by: Jochen Wiedmann
Reviewed by: Stephane Nicoll

Modified:
    maven/plugins/trunk/maven-war-plugin/pom.xml
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/CompositeMap.java

Modified: maven/plugins/trunk/maven-war-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/pom.xml?rev=588013&r1=588012&r2=588013&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-war-plugin/pom.xml Wed Oct 24 13:51:38 2007
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <artifactId>maven-plugins</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
@@ -111,20 +112,10 @@
                   <goal>run</goal>
                 </goals>
               </execution>
-           </executions>
+            </executions>
           </plugin>
         </plugins>
       </build>
     </profile>
-  </profiles>  
-  <!-- TODO: remove when plexus-utils is released -->
-  <!--repositories>
-    <repository>
-      <id>codehaus.snapshots</id>
-      <url>http://snapshots.repository.codehaus.org/</url>
-      <releases>
-        <enabled>false</enabled>
-      </releases>
-    </repository>
-  </repositories-->
+  </profiles>
 </project>

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?rev=588013&r1=588012&r2=588013&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java Wed Oct 24 13:51:38 2007
@@ -529,9 +529,6 @@
         {
             Map filterProperties = new Properties();
 
-            // System properties
-            filterProperties.putAll( System.getProperties() );
-
             // Project properties
             filterProperties.putAll( project.getProperties() );
 
@@ -552,7 +549,8 @@
             }
 
             // can't putAll, as ReflectionProperties doesn't enumerate - so we make a composite map with the project variables as dominant
-            return new CompositeMap( new ReflectionProperties( project ), filterProperties );
+            return new CompositeMap(
+                new Map[]{filterProperties, new ReflectionProperties( project ), System.getProperties()} );
         }
 
         public WebappStructure getWebappStructure()

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/CompositeMap.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/CompositeMap.java?rev=588013&r1=588012&r2=588013&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/CompositeMap.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/CompositeMap.java Wed Oct 24 13:51:38 2007
@@ -20,7 +20,6 @@
  */
 
 import java.util.AbstractMap;
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 
@@ -31,27 +30,29 @@
 public class CompositeMap
     extends AbstractMap
 {
-    private Map recessive;
+    private final Map[] maps;
 
-    private Map dominant;
-
-    public CompositeMap( Map dominant, Map recessive )
+    /**
+     * Creates a new instance, which is composed from all the given maps.
+     *
+     * @param maps the map
+     */
+    public CompositeMap( Map[] maps )
     {
-        this.dominant = Collections.unmodifiableMap( dominant );
-
-        this.recessive = Collections.unmodifiableMap( recessive );
+        this.maps = maps;
     }
 
     public synchronized Object get( Object key )
     {
-        Object value = dominant.get( key );
-
-        if ( value == null )
+        for ( int i = 0; i < maps.length; i++ )
         {
-            value = recessive.get( key );
+            Object value = maps[i].get( key );
+            if ( value != null )
+            {
+                return value;
+            }
         }
-
-        return value;
+        return null;
     }
 
     public Set entrySet()