Made buildTopDownMergedConfiguration really recursive - in most cases it didn't.

Fixed a merge problem where only direct children of <configuration> in the POM
appeared in the merged configuration.

(like maven-antrun-plugin, the 'tasks' configuration tag didn't have any
value, but has children. After the merge, the children were gone,
and it was marked as having no value, and hence the field was not updated.)


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@232281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kenney Westerhof 2005-08-12 12:44:22 +00:00
parent 0b4aa2dc41
commit 1311273aa6

View File

@ -186,9 +186,9 @@ public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Setti
}
// TODO: this might result in an artifact "RELEASE" being resolved continuously
// FIXME: need to find out how a plugin gets marked as 'installed'
// and no ChildContainer exists. The check for that below fixes
// the 'Can't find plexus container for plugin: xxx' error.
// FIXME: need to find out how a plugin gets marked as 'installed'
// and no ChildContainer exists. The check for that below fixes
// the 'Can't find plexus container for plugin: xxx' error.
if ( !pluginCollector.isPluginInstalled( plugin ) || container.getChildContainer( plugin.getKey() ) == null )
{
try
@ -768,7 +768,8 @@ private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration c
}
}
if ( fieldValue == null )
// only mark as invalid if there are no child nodes
if ( fieldValue == null && (value == null || value.getChildCount() == 0 ) )
{
parameter.setExpression( expression );
invalidParameters.add( parameter );
@ -839,10 +840,10 @@ private PlexusConfiguration mergeMojoConfiguration( XmlPlexusConfiguration fromP
for ( Iterator it = mojoDescriptor.getParameters().iterator(); it.hasNext(); )
{
Parameter parameter = (Parameter) it.next();
String paramName = parameter.getName();
String alias = parameter.getAlias();
PlexusConfiguration pomConfig = fromPom.getChild( paramName );
PlexusConfiguration aliased = null;
@ -866,11 +867,11 @@ private PlexusConfiguration mergeMojoConfiguration( XmlPlexusConfiguration fromP
}
boolean addedPomConfig = false;
if ( pomConfig != null )
{
pomConfig = buildTopDownMergedConfiguration( pomConfig, mojoConfig );
if ( StringUtils.isNotEmpty( pomConfig.getValue( null ) ) || pomConfig.getChildCount() > 0 )
{
result.addChild( pomConfig );
@ -920,13 +921,28 @@ private XmlPlexusConfiguration buildTopDownMergedConfiguration( PlexusConfigurat
for ( int i = 0; i < attributeNames.length; i++ )
{
String attributeValue = recessive.getAttribute( attributeNames[i], null );
// TODO: recessive seems to be dominant here?
result.setAttribute( attributeNames[i], attributeValue );
}
mergeConfiguration( result, recessive );
}
PlexusConfiguration[] children = dominant.getChildren();
for ( int i = 0; i < children.length; i++ )
{
PlexusConfiguration childDom = children[i];
PlexusConfiguration childRec = recessive == null ? null : recessive.getChild( childDom.getName(), false );
if ( childRec != null )
{
result.addChild( buildTopDownMergedConfiguration( childDom, childRec ) );
}
else
{ // FIXME: copy, or use reference?
result.addChild( copyConfiguration( childDom ) );
}
}
return result;
}