Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D58A10D27 for ; Sat, 27 Dec 2014 12:56:04 +0000 (UTC) Received: (qmail 23620 invoked by uid 500); 27 Dec 2014 12:56:04 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 23524 invoked by uid 500); 27 Dec 2014 12:56:04 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 23508 invoked by uid 99); 27 Dec 2014 12:56:04 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Dec 2014 12:56:04 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id CEC6CAC0DDD; Sat, 27 Dec 2014 12:55:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1648051 - in /maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear: AbstractEarMojo.java GenerateApplicationXmlMojo.java Date: Sat, 27 Dec 2014 12:55:58 -0000 To: commits@maven.apache.org From: khmarbaise@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141227125600.CEC6CAC0DDD@hades.apache.org> Author: khmarbaise Date: Sat Dec 27 12:55:58 2014 New Revision: 1648051 URL: http://svn.apache.org/r1648051 Log: [MEAR-188] Project property cannot be resolved inside element Introduced interpolation within the envEntries elements its no possible having properties etc. within those elements. Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java?rev=1648051&r1=1648050&r2=1648051&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java (original) +++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java Sat Dec 27 12:55:58 2014 @@ -31,8 +31,10 @@ import org.apache.maven.plugin.MojoExecu import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.ear.util.ArtifactTypeMappingService; import org.apache.maven.plugin.ear.util.JavaEEVersion; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.filtering.MavenResourcesFiltering; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; @@ -159,6 +161,9 @@ public abstract class AbstractEarMojo @Parameter( defaultValue = "${project.build.directory}", required = true ) private File tempFolder; + @Component + private MavenResourcesFiltering mavenResourcesFiltering; + private List earModules; private List allModules; Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java?rev=1648051&r1=1648050&r2=1648051&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java (original) +++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java Sat Dec 27 12:55:58 2014 @@ -19,6 +19,12 @@ package org.apache.maven.plugin.ear; * under the License. */ +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.ear.util.JavaEEVersion; @@ -28,14 +34,13 @@ import org.apache.maven.plugins.annotati import org.apache.maven.plugins.annotations.ResolutionScope; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.StringSearchInterpolator; +import org.codehaus.plexus.interpolation.ValueSource; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * Generates the EAR deployment descriptor file(s). * @@ -44,7 +49,7 @@ import java.util.List; */ // CHECKSTYLE_OFF: LineLength @Mojo( name = "generate-application-xml", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true, requiresDependencyResolution = ResolutionScope.TEST ) -//CHECKSTYLE_ON: LineLength +// CHECKSTYLE_ON: LineLength public class GenerateApplicationXmlMojo extends AbstractEarMojo { @@ -304,6 +309,28 @@ public class GenerateApplicationXmlMojo } /** + * This help method was needed otherwise the interpolate method of interpolator will make an empty string of a + * {@code null} element which results in supplemental elements for env-entry. + * + * @param interpolator The interpolator + * @param element The element + * @return The interpolated elements. + * @throws InterpolationException in case of an error. + */ + private String interpolate( Interpolator interpolator, String element ) + throws InterpolationException + { + if ( element == null ) + { + return element; + } + else + { + return interpolator.interpolate( element ); + } + } + + /** * Builds the env-entries based on the configuration. * * @return a list of EnvEntry object(s) @@ -319,14 +346,23 @@ public class GenerateApplicationXmlMojo } try { + StringSearchInterpolator ssi = new StringSearchInterpolator(); + ValueSource vs = new MapBasedValueSource( project.getProperties() ); + ssi.addValueSource( vs ); + final PlexusConfiguration[] allEnvEntries = envEntries.getChildren( EnvEntry.ENV_ENTRY ); for ( PlexusConfiguration envEntry : allEnvEntries ) { - final String childDescription = envEntry.getChild( EnvEntry.DESCRIPTION ).getValue(); - final String childEnvEntryName = envEntry.getChild( EnvEntry.ENV_ENTRY_NAME ).getValue(); - final String childEnvEntryType = envEntry.getChild( EnvEntry.ENV_ENTRY_TYPE ).getValue(); - final String childEnvEntryValue = envEntry.getChild( EnvEntry.ENV_ENTRY_VALUE ).getValue(); + // CHECKSTYLE_OFF: LineLength + final String childDescription = interpolate( ssi, envEntry.getChild( EnvEntry.DESCRIPTION ).getValue() ); + final String childEnvEntryName = + interpolate( ssi, envEntry.getChild( EnvEntry.ENV_ENTRY_NAME ).getValue() ); + final String childEnvEntryType = + interpolate( ssi, envEntry.getChild( EnvEntry.ENV_ENTRY_TYPE ).getValue() ); + final String childEnvEntryValue = + interpolate( ssi, envEntry.getChild( EnvEntry.ENV_ENTRY_VALUE ).getValue() ); + // CHECKSTYLE_ON: LineLength try { @@ -344,6 +380,10 @@ public class GenerateApplicationXmlMojo { throw new EarPluginException( "Invalid env-entry configuration", e ); } + catch ( InterpolationException e ) + { + throw new EarPluginException( "Interpolation exception:", e ); + } }