Author: bentmann
Date: Mon May 18 20:10:06 2009
New Revision: 776073

URL: http://svn.apache.org/viewvc?rev=776073&view=rev
Log:
o Fixed interpolation of system properties

Added:
    
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/
   (with props)
    
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml
   (with props)
Modified:
    
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java
    
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
    
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
    
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java
    
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java

Modified: 
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java?rev=776073&r1=776072&r2=776073&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/profiles/matchers/JdkMatcherTest.java
 Mon May 18 20:10:06 2009
@@ -19,7 +19,7 @@
                
                JdkMatcher m = new JdkMatcher();
                Properties props = new Properties();
-               props.setProperty("${java.version}", "1.5.0_16");
+               props.setProperty("java.version", "1.5.0_16");
                
                assertTrue(m.isMatch(p, props ));
        }

Modified: 
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=776073&r1=776072&r2=776073&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
 Mon May 18 20:10:06 2009
@@ -1332,7 +1332,7 @@
        throws Exception
        {
        Properties props = new Properties();
-           props.put("${java.version}", "1.5.0_15");
+           props.put("java.version", "1.5.0_15");
                
            PomTestWrapper pom = buildPom( "jdk-activation",  props ); 
            assertEquals(3, pom.getMavenProject().getActiveProfiles().size());  
@@ -1428,6 +1428,15 @@
            PomTestWrapper pom = buildPom( 
"dependency-management-with-interpolation/sub" );
        }   
 
+    public void testInterpolationWithSystemProperty()
+        throws Exception
+    {
+        Properties sysProps = new Properties();
+        sysProps.setProperty( "system.property", "PASSED" );
+        PomTestWrapper pom = buildPom( "sytem-property-interpolation", 
sysProps );
+        assertEquals( "PASSED", pom.getValue( "name" ) );
+    }    
+
     private void assertPathSuffixEquals( String expected, Object actual )
     {
         String a = actual.toString();

Propchange: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/
------------------------------------------------------------------------------
    bugtraq:label = Enter issue ID:

Propchange: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/
------------------------------------------------------------------------------
    bugtraq:message = Issue id: %BUGID%

Propchange: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/
------------------------------------------------------------------------------
    bugtraq:number = false

Propchange: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml?rev=776073&view=auto
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml
 (added)
+++ 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml
 Mon May 18 20:10:06 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>gid</groupId>
+  <artifactId>aid</artifactId>
+  <version>1.0</version>
+
+  <name>${system.property}</name>
+</project>

Propchange: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/sytem-property-interpolation/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java?rev=776073&r1=776072&r2=776073&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/interpolator/DefaultInterpolator.java
 Mon May 18 20:10:06 2009
@@ -55,7 +55,8 @@
         List<InterpolatorProperty>  interpolatorProperties = new 
ArrayList<InterpolatorProperty>();
         for ( Entry<Object, Object> e : properties.entrySet() )
         {
-                interpolatorProperties.add( new InterpolatorProperty( (String) 
e.getKey(), (String) e.getValue(), 
PomInterpolatorTag.EXECUTION_PROPERTIES.toString() ) );
+            interpolatorProperties.add( new InterpolatorProperty( "${" + 
e.getKey() + "}", (String) e.getValue(),
+                                                                  
PomInterpolatorTag.EXECUTION_PROPERTIES.toString() ) );
         }
 
         if ( !containsProjectVersion( interpolatorProperties ) )

Modified: 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java?rev=776073&r1=776072&r2=776073&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/JdkMatcher.java
 Mon May 18 20:10:06 2009
@@ -12,7 +12,7 @@
        implements ProfileMatcher 
        {
        
-    private static final String JDK_VERSION = "${java.version}";
+    private static final String JDK_VERSION = "java.version";
 
        public boolean isMatch(Profile profile,
                        Properties properties) {

Modified: 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java?rev=776073&r1=776072&r2=776073&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/profiles/matchers/PropertyMatcher.java
 Mon May 18 20:10:06 2009
@@ -51,7 +51,7 @@
 
         for ( Entry<Object, Object> ip : properties.entrySet() )
         {
-               if(ip.getKey().equals("${" + name + "}"))
+               if(ip.getKey().equals( name ))
                {
                        return ((String) ip.getValue()).equals(value);
                }         


Reply via email to