This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to annotated tag maven-filtering-1.0-alpha-1
in repository https://gitbox.apache.org/repos/asf/maven-filtering.git

commit 6d9b56ec1ea12201c9e2053e073f0410b14e57eb
Author: Oliver Lamy <[email protected]>
AuthorDate: Sun Feb 24 09:06:43 2008 +0000

    change the Properties loading order now System Properties wins
    
    
    
    git-svn-id: 
https://svn.apache.org/repos/asf/maven/sandbox/trunk/shared/maven-filtering@630604
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../shared/filtering/DefaultMavenFileFilter.java   | 31 +++++++++++++++-------
 src/site/apt/index.apt                             | 22 ++++++++-------
 .../DefaultMavenResourcesFilteringTest.java        |  3 +--
 3 files changed, 34 insertions(+), 22 deletions(-)

diff --git 
a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java 
b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
index a089ab9..848a257 100755
--- 
a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
+++ 
b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
@@ -80,27 +80,38 @@ public class DefaultMavenFileFilter
                                           final boolean 
escapedBackslashesInFilePath )
         throws MavenFilteringException
     {
-
-        final Properties filterProperties = new Properties();
-
-        // System properties
-        filterProperties.putAll( System.getProperties() );
-
-        // Project properties
-        filterProperties.putAll( mavenProject.getProperties() == null ? 
Collections.EMPTY_MAP : mavenProject
-            .getProperties() );
+        
+        // here we build some properties which will be used to read some 
properties files
+        // to interpolate the expression ${ }  in this properties file
 
         // Take a copy of filterProperties to ensure that evaluated 
filterTokens are not propagated
         // to subsequent filter files. NB this replicates current behaviour 
and seems to make sense.
+        
         final Properties baseProps = new Properties();
-        baseProps.putAll( filterProperties );
 
+        // Project properties
+        baseProps.putAll( mavenProject.getProperties() == null ? 
Collections.EMPTY_MAP : mavenProject
+            .getProperties() );        
+        // System properties wins
+        baseProps.putAll( System.getProperties() );         
+        
+        // now we build properties to use for resources interpolation
+        
+        final Properties filterProperties = new Properties();
+        
         loadProperties( filterProperties, filters, baseProps );
 
         loadProperties( filterProperties, mavenProject.getFilters(), baseProps 
);
 
         loadProperties( filterProperties, 
mavenProject.getBuild().getFilters(), baseProps );
 
+        // Project properties
+        filterProperties.putAll( mavenProject.getProperties() == null ? 
Collections.EMPTY_MAP : mavenProject
+            .getProperties() );        
+        // System properties wins
+        filterProperties.putAll( System.getProperties() );        
+        
+        
         List defaultFilterWrappers = new ArrayList( 3 );
 
         // support ${token}
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index 6d79423..cf8e617 100755
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -42,27 +42,29 @@ Maven Filtering Component
   This component has a method which returns the default 
FileUtils.FilterWrapper.
   This are :
   
-    * interpolation with token ${ } and values from SystemProps, 
project.properties, filters, project.filters and project.build.filters
+    * interpolation with token $\{ \} and values from filters, 
project.filters, project.build.filters, pom.properties and SystemProps
     
-    * interpolation with token @ @ and values from SystemProps, 
project.properties, filters, project.filters and project.build.filters
+    * interpolation with token @ @ and values from filters, project.filters, 
project.build.filters, pom.properties and SystemProps
     
-    * interpolation with token ${ } and values from mavenProject interpolation
+    * interpolation with token $\{ \} and values from mavenProject 
interpolation
     
     []
     
     The values (Properties object) used for interpolation are loaded with the 
following order :
+   
+    * List of properties file ( the method has a parameter which accept a List 
of String -> path properties files )
+   
+    * pom.filters
     
-    * System Properties
+    * pom.build.filters
     
     * pom.properties
     
-    * List of properties ( the method has a parameter which accept a List of 
String -> path properties files )
-    
-    * pom.filters
-    
-    * pom.build.filters
+    * System Properties
     
     []
     
     <<NOTE>> : As it's a Properties object, last defined key/value pair wins . 
-    The value for key java.version can be overriding with a property in the 
maven project (yes crazy but possible).
+    
+    <<NOTE>> : When building the global Properties object and reading the 
properties files defined the different filters, 
+    interpolation with the token $\{ \} is supported for this filters with a 
limited properties values coming from pom.properties and System Properties 
(last wins too)
diff --git 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
index 8668ee6..059eff8 100755
--- 
a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
+++ 
b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
@@ -29,7 +29,6 @@ import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.model.Resource;
-import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
@@ -106,7 +105,7 @@ public class DefaultMavenResourcesFilteringTest
         
         assertEquals( "@@", result.getProperty( "emptyexpression" ) );
         assertEquals( "${}", result.getProperty( "emptyexpression2" ) );
-        assertEquals( "zloug", result.getProperty( "javaVersion" ) );
+        assertEquals( System.getProperty( "java.version" ), 
result.getProperty( "javaVersion" ) );
         
         assertEquals( baseDir.toString(), result.get( "base" ) );
         

Reply via email to