From fc77014cfeccbb2e74b67616a7b5049ee29d8813 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Wed, 8 Mar 2006 17:04:47 +0000 Subject: [PATCH] (Merged from 384264.) [MNG-2124] Fixed interpolator to call the ReflectionValueExtractor method that prevents trimming the first expression token, since this is done in the interpolator itself. I'm still investigating whether this is going to break realignment of File instances to basedir during plugin parameter injection, but I've had to adjust it0088, since it is not handling project.build.directory as a File, but as a String. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@384270 13f79535-47bb-0310-9956-ffa450edef68 --- maven-core-it/README.txt | 4 +- maven-core-it/integration-tests.txt | 1 + .../maven/it0088/PomInterpolationTest.java | 7 +-- maven-core-it/it0100/goals.txt | 1 + maven-core-it/it0100/parent/child/pom.xml | 46 +++++++++++++++++++ .../child/src/test/verifier/verifications.xml | 8 ++++ maven-core-it/it0100/parent/pom.xml | 32 +++++++++++++ maven-core-it/it0100/pom.xml | 14 ++++++ .../RegexBasedModelInterpolator.java | 5 +- 9 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 maven-core-it/it0100/goals.txt create mode 100644 maven-core-it/it0100/parent/child/pom.xml create mode 100644 maven-core-it/it0100/parent/child/src/test/verifier/verifications.xml create mode 100644 maven-core-it/it0100/parent/pom.xml create mode 100644 maven-core-it/it0100/pom.xml diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index 3595c4bfdb..c29cd07039 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -266,7 +266,9 @@ it0097: Test that the implied relative path for the parent POM works, even two it0098: Test that quoted system properties are processed correctly. [MNG-1415] it0099: Test that parent-POMs cached during a build are available as parents - to other POMs in the multimodule build. [MNG-2124] + to other POMs in the multimodule build. [MNG-2130] + +it0100: Test that ${parent.artifactId} resolves correctly. [MNG-2124] ------------------------------------------------------------------------------- diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 6b4216948d..2aff06281d 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,3 +1,4 @@ +it0100 it0099 it0098 it0097 diff --git a/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java b/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java index 652d8bc7ef..c65fc295ae 100644 --- a/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java +++ b/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java @@ -44,8 +44,9 @@ public class PomInterpolationTest testProperties.load( new FileInputStream( testPropertiesFile ) ); - File projectBuildDirectory = new File( basedir, "target" ); - - assertEquals( testProperties.getProperty( "project.build.directory" ), projectBuildDirectory.getAbsolutePath() ); + // [jdcasey] NOTE: This property is not a java.io.File, so it will NOT be adjusted + // to the basedir! We need to simply check that it's value is "target", rather than + // new java.io.File( basedir, "target" ).getAbsolutePath(); + assertEquals( testProperties.getProperty( "project.build.directory" ), "target" ); } } diff --git a/maven-core-it/it0100/goals.txt b/maven-core-it/it0100/goals.txt new file mode 100644 index 0000000000..0b5987362f --- /dev/null +++ b/maven-core-it/it0100/goals.txt @@ -0,0 +1 @@ +verify diff --git a/maven-core-it/it0100/parent/child/pom.xml b/maven-core-it/it0100/parent/child/pom.xml new file mode 100644 index 0000000000..a9b952b37b --- /dev/null +++ b/maven-core-it/it0100/parent/child/pom.xml @@ -0,0 +1,46 @@ + + + + parent + org.apache.maven.it0100 + 1.0 + + + 4.0.0 + child + child + + pom + + + + + maven-help-plugin + + + + target/effective-pom.txt + + initialize + + effective-pom + + + + + + maven-verifier-plugin + + + verify + + verify + + + + + + + + diff --git a/maven-core-it/it0100/parent/child/src/test/verifier/verifications.xml b/maven-core-it/it0100/parent/child/src/test/verifier/verifications.xml new file mode 100644 index 0000000000..43cb3f4e53 --- /dev/null +++ b/maven-core-it/it0100/parent/child/src/test/verifier/verifications.xml @@ -0,0 +1,8 @@ + + + + target/effective-pom.txt + Parent: parent, project: child + + + diff --git a/maven-core-it/it0100/parent/pom.xml b/maven-core-it/it0100/parent/pom.xml new file mode 100644 index 0000000000..403d6ec785 --- /dev/null +++ b/maven-core-it/it0100/parent/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + org.apache.maven.it0100 + parent + pom + 1.0 + parent + + + + + maven-antrun-plugin + + + validate + + + Parent: ${pom.parent.artifactId}, project: ${pom.artifactId} + Parent: ${parent.artifactId}, project: ${pom.artifactId} + + + + run + + + + + + + + diff --git a/maven-core-it/it0100/pom.xml b/maven-core-it/it0100/pom.xml new file mode 100644 index 0000000000..c0aa814058 --- /dev/null +++ b/maven-core-it/it0100/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + org.apache.maven.it0100 + root + pom + 1.0 + root + + + parent/child + + + diff --git a/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java b/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java index 9e45d4e3f2..63c8d154ec 100644 --- a/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java +++ b/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java @@ -136,7 +136,10 @@ public class RegexBasedModelInterpolator { try { - value = ReflectionValueExtractor.evaluate( realExpr, model ); + // NOTE: We've already trimmed off any leading expression parts like 'project.' + // or 'pom.', and now we have to ensure that the ReflectionValueExtractor + // doesn't try to do it again. + value = ReflectionValueExtractor.evaluate( realExpr, model, false ); } catch ( Exception e ) {