From c8151318c29deb416526c3358cb3ecdb462301e0 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 24 May 2009 17:39:34 +0000 Subject: [PATCH] o Fixed processing of parameter aliases git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@778197 13f79535-47bb-0310-9956-ffa450edef68 --- .../lifecycle/DefaultLifecycleExecutor.java | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 407dd42991..d7c5229b47 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -54,6 +54,7 @@ import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; @@ -471,16 +472,49 @@ public class DefaultLifecycleExecutor */ private Xpp3Dom extractMojoConfiguration( Xpp3Dom executionConfiguration, MojoDescriptor mojoDescriptor ) { - Xpp3Dom mojoConfiguration = new Xpp3Dom( executionConfiguration ); + Xpp3Dom mojoConfiguration = new Xpp3Dom( executionConfiguration.getName() ); Collection mojoParameters = mojoDescriptor.getParameterMap().keySet(); - for ( int i = mojoConfiguration.getChildCount() - 1; i >= 0; i-- ) + Map aliases = new HashMap(); + if ( mojoDescriptor.getParameters() != null ) { - String mojoParameter = mojoConfiguration.getChild( i ).getName(); - if ( !mojoParameters.contains( mojoParameter ) ) + for ( Parameter parameter : mojoDescriptor.getParameters() ) { - mojoConfiguration.removeChild( i ); + String alias = parameter.getAlias(); + if ( StringUtils.isNotEmpty( alias ) ) + { + aliases.put( alias, parameter.getName() ); + } + } + } + + for ( int i = 0; i < executionConfiguration.getChildCount(); i++ ) + { + Xpp3Dom executionDom = executionConfiguration.getChild( i ); + String paramName = executionDom.getName(); + + if ( mojoParameters.contains( paramName ) ) + { + Xpp3Dom mojoDom = new Xpp3Dom( executionDom ); + mojoConfiguration.addChild( mojoDom ); + } + else if ( aliases.containsKey( paramName ) ) + { + Xpp3Dom mojoDom = new Xpp3Dom( aliases.get( paramName ) ); + mojoDom.setValue( executionDom.getValue() ); + + for ( String attributeName : executionDom.getAttributeNames() ) + { + mojoDom.setAttribute( attributeName, executionDom.getAttribute( attributeName ) ); + } + + for ( Xpp3Dom child : executionDom.getChildren() ) + { + mojoDom.addChild( new Xpp3Dom( child ) ); + } + + mojoConfiguration.addChild( mojoDom ); } }