mirror of https://github.com/apache/maven.git
o Fixed interpolation of system properties
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@776073 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8c30410341
commit
59224daa9e
|
@ -19,7 +19,7 @@ public class JdkMatcherTest extends TestCase
|
|||
|
||||
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 ));
|
||||
}
|
||||
|
|
|
@ -1332,7 +1332,7 @@ public class PomConstructionTest
|
|||
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 @@ public class PomConstructionTest
|
|||
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();
|
||||
|
|
|
@ -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>
|
|
@ -55,7 +55,8 @@ public class DefaultInterpolator
|
|||
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 ) )
|
||||
|
|
|
@ -12,7 +12,7 @@ public class JdkMatcher
|
|||
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) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PropertyMatcher implements ProfileMatcher
|
|||
|
||||
for ( Entry<Object, Object> ip : properties.entrySet() )
|
||||
{
|
||||
if(ip.getKey().equals("${" + name + "}"))
|
||||
if(ip.getKey().equals( name ))
|
||||
{
|
||||
return ((String) ip.getValue()).equals(value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue