Olivier,
Please for the love of god, would you please be more careful. You're
just ripping through all sorts of plugins making major behavioral
changes in core fundamental plugins? How do you know changing the way
properties are ordered isn't going to affect someone relying on the
command line winning? Are you absolutely sure?
Also, as I've pointed out direct access to System properties in
plugins is categorically bad because it makes embedding (read IDE use)
totally unpredictable.
On 24-Feb-08, at 1:06 AM, [EMAIL PROTECTED] wrote:
Author: olamy
Date: Sun Feb 24 01:06:43 2008
New Revision: 630604
URL: http://svn.apache.org/viewvc?rev=630604&view=rev
Log:
change the Properties loading order now System Properties wins
Modified:
maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/
apache/maven/shared/filtering/DefaultMavenFileFilter.java
maven/sandbox/trunk/shared/maven-filtering/src/site/apt/index.apt
maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/
apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
Modified: maven/sandbox/trunk/shared/maven-filtering/src/main/java/
org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java?rev=630604&r1=630603&r2=630604&view=diff
=
=
=
=
=
=
=
=
======================================================================
--- maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/
apache/maven/shared/filtering/DefaultMavenFileFilter.java (original)
+++ maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/
apache/maven/shared/filtering/DefaultMavenFileFilter.java Sun Feb 24
01:06:43 2008
@@ -80,27 +80,38 @@
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}
Modified: maven/sandbox/trunk/shared/maven-filtering/src/site/apt/
index.apt
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-filtering/src/site/apt/index.apt?rev=630604&r1=630603&r2=630604&view=diff
=
=
=
=
=
=
=
=
======================================================================
--- maven/sandbox/trunk/shared/maven-filtering/src/site/apt/
index.apt (original)
+++ maven/sandbox/trunk/shared/maven-filtering/src/site/apt/
index.apt Sun Feb 24 01:06:43 2008
@@ -42,27 +42,29 @@
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)
Modified: maven/sandbox/trunk/shared/maven-filtering/src/test/java/
org/apache/maven/shared/filtering/
DefaultMavenResourcesFilteringTest.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java?rev=630604&r1=630603&r2=630604&view=diff
=
=
=
=
=
=
=
=
======================================================================
--- maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/
apache/maven/shared/filtering/
DefaultMavenResourcesFilteringTest.java (original)
+++ maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/
apache/maven/shared/filtering/
DefaultMavenResourcesFilteringTest.java Sun Feb 24 01:06:43 2008
@@ -29,7 +29,6 @@
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 @@
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" ) );
Thanks,
Jason
----------------------------------------------------------
Jason van Zyl
Founder, Apache Maven
jason at sonatype dot com
----------------------------------------------------------
Our achievements speak for themselves. What we have to keep track
of are our failures, discouragements and doubts. We tend to forget
the past difficulties, the many false starts, and the painful
groping. We see our past achievements as the end result of a
clean forward thrust, and our present difficulties as
signs of decline and decay.
-- Eric Hoffer, Reflections on the Human Condition
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]