From 2c3931c3bbb350abe2ef8e32f972694d1348794d Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Wed, 6 Mar 2013 01:03:03 +0000 Subject: [PATCH 1/2] [MNG-5445] extract StringSearchModelInterpolator issue into local IT plugin rather than rely on external versions-maven-plugin --- .../src/test/resources/mng-5445/pom.xml | 27 ++------ .../pom.xml | 65 +++++++++++++++++++ .../plugin/coreit/PathInterpolationMojo.java | 57 ++++++++++++++++ .../src/site/site.xml | 33 ++++++++++ core-it-support/core-it-plugins/pom.xml | 1 + 5 files changed, 163 insertions(+), 20 deletions(-) create mode 100644 core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/pom.xml create mode 100644 core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/main/java/org/apache/maven/plugin/coreit/PathInterpolationMojo.java create mode 100644 core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/site/site.xml diff --git a/core-it-suite/src/test/resources/mng-5445/pom.xml b/core-it-suite/src/test/resources/mng-5445/pom.xml index f05e533ec..5ba7630cd 100644 --- a/core-it-suite/src/test/resources/mng-5445/pom.xml +++ b/core-it-suite/src/test/resources/mng-5445/pom.xml @@ -6,43 +6,30 @@ mng5445-it 0.0.1-SNAPSHOT - Test legacy StringSearchModelInterpolator + Test StringSearchModelInterpolator with path-based properties http://maven.apache.org UTF-8 + ${project.build.sourceDirectory}/foo - - 2.2.1 - - src - org.apache.maven.plugins - maven-surefire-plugin - 0.1-stub-SNAPSHOT - - ${project.build.sourceDirectory} - ${project.build.outputDirectory} - - - - org.codehaus.mojo - versions-maven-plugin - 2.0 + org.apache.maven.its.plugins + maven-it-plugin-model-interpolation + 2.1-SNAPSHOT - test-display-plugin-updates - validate - display-plugin-updates + path-interpolation + diff --git a/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/pom.xml b/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/pom.xml new file mode 100644 index 000000000..1ec7577f5 --- /dev/null +++ b/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + + maven-it-plugins + org.apache.maven.its.plugins + 2.1-SNAPSHOT + + + maven-it-plugin-model-interpolation + maven-plugin + + Maven IT Plugin :: Model Interpolation + 2013 + + + + org.apache.maven + maven-plugin-api + 2.0 + + + org.apache.maven + maven-project + 2.1.0 + + + + org.apache.maven.its + maven-it-helper + ${project.version} + + + org.apache.maven.shared + maven-verifier + + + junit + junit + + + + + diff --git a/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/main/java/org/apache/maven/plugin/coreit/PathInterpolationMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/main/java/org/apache/maven/plugin/coreit/PathInterpolationMojo.java new file mode 100644 index 000000000..dc86b3f8f --- /dev/null +++ b/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/main/java/org/apache/maven/plugin/coreit/PathInterpolationMojo.java @@ -0,0 +1,57 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.DefaultProjectBuilderConfiguration; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.interpolation.ModelInterpolationException; +import org.apache.maven.project.interpolation.ModelInterpolator; + +/** + * @goal path-interpolation + * @phase validate + */ +public class PathInterpolationMojo + extends AbstractMojo +{ + /** @component */ + private ModelInterpolator modelInterpolator; + + /** @parameter expression="${project}" */ + private MavenProject project; + + public void execute() + throws MojoExecutionException + { + try + { + modelInterpolator.interpolate( project.getOriginalModel(), + project.getBasedir(), + new DefaultProjectBuilderConfiguration().setExecutionProperties( project.getProperties() ), + true ); + } + catch ( ModelInterpolationException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } +} diff --git a/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/site/site.xml b/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/site/site.xml new file mode 100644 index 000000000..18f84c576 --- /dev/null +++ b/core-it-support/core-it-plugins/maven-it-plugin-model-interpolation/src/site/site.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/core-it-support/core-it-plugins/pom.xml b/core-it-support/core-it-plugins/pom.xml index 76ae364f7..54ce6a8cc 100644 --- a/core-it-support/core-it-plugins/pom.xml +++ b/core-it-support/core-it-plugins/pom.xml @@ -51,6 +51,7 @@ under the License. maven-it-plugin-fork maven-it-plugin-invalid-descriptor maven-it-plugin-log-file + maven-it-plugin-model-interpolation maven-it-plugin-no-default-comp maven-it-plugin-no-project maven-it-plugin-online From d1087e04bbc00042aaa368e29bf72a6a9ff41743 Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Wed, 6 Mar 2013 01:32:29 +0000 Subject: [PATCH 2/2] [MNG-5445] restrict new test to 3.1.x stream (assumes the fix isn't going to be backported to 3.0.x, note that the test itself requires a minimum of 2.1.0 for the additional path-related ModelInterpolator methods) --- ...enITmng5445LegacyStringSearchModelInterpolatorTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5445LegacyStringSearchModelInterpolatorTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5445LegacyStringSearchModelInterpolatorTest.java index b55d97d0f..e00714baf 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5445LegacyStringSearchModelInterpolatorTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5445LegacyStringSearchModelInterpolatorTest.java @@ -19,10 +19,9 @@ * under the License. */ -import org.apache.maven.it.util.ResourceExtractor; - import java.io.File; -import java.util.Properties; + +import org.apache.maven.it.util.ResourceExtractor; /** * This is a test set for MNG-5445. @@ -33,7 +32,7 @@ public class MavenITmng5445LegacyStringSearchModelInterpolatorTest public MavenITmng5445LegacyStringSearchModelInterpolatorTest() { - super( ALL_MAVEN_VERSIONS ); + super( "[3.1,)" ); } /**