You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by br...@apache.org on 2005/03/22 12:29:55 UTC
cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/util Xpp3DomUtils.java
brett 2005/03/22 03:29:55
Modified: maven-core/src/main/java/org/apache/maven/plugin
DefaultPluginManager.java
maven-core/src/main/java/org/apache/maven/project/inheritance
DefaultModelInheritanceAssembler.java
maven-core/src/main/java/org/apache/maven/project/injection
DefaultModelDefaultsInjector.java
Added: maven-core/src/main/java/org/apache/maven/util
Xpp3DomUtils.java
Log:
clean up plugin configuration handling
Revision Changes Path
1.66 +7 -47 maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Index: DefaultPluginManager.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- DefaultPluginManager.java 22 Mar 2005 10:46:55 -0000 1.65
+++ DefaultPluginManager.java 22 Mar 2005 11:29:55 -0000 1.66
@@ -37,6 +37,7 @@
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.settings.MavenSettingsBuilder;
+import org.apache.maven.util.Xpp3DomUtils;
import org.codehaus.plexus.ArtifactEnabledContainer;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@@ -651,9 +652,8 @@
Goal goal = (Goal) j.next();
if ( goal.getId().equals( goalName ) )
{
- Xpp3Dom goalConfiguration = copyXpp3Dom( (Xpp3Dom) goal.getConfiguration() );
- mergeXpp3Dom( goalConfiguration, dom );
- dom = goalConfiguration;
+ Xpp3Dom goalConfiguration = (Xpp3Dom) goal.getConfiguration();
+ dom = Xpp3DomUtils.mergeXpp3Dom( Xpp3DomUtils.copyXpp3Dom( goalConfiguration ), dom );
break;
}
}
@@ -675,54 +675,14 @@
return configuration;
}
- private static void mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
- {
- // TODO: how to merge lists rather than override?
- // TODO: share this as some sort of assembler, implement a walk interface?
- Xpp3Dom[] children = recessive.getChildren();
- for ( int i = 0; i < children.length; i++ )
- {
- Xpp3Dom child = children[i];
- Xpp3Dom childDom = dominant.getChild( child.getName() );
- if ( childDom != null )
- {
- mergeXpp3Dom( childDom, child );
- }
- else
- {
- dominant.addChild( copyXpp3Dom( child ) );
- }
- }
- }
-
- private static Xpp3Dom copyXpp3Dom( Xpp3Dom src )
- {
- // TODO: into Xpp3Dom as a copy constructor
- Xpp3Dom dom = new Xpp3Dom( src.getName() );
- dom.setValue( src.getValue() );
-
- String[] attributeNames = src.getAttributeNames();
- for ( int i = 0; i < attributeNames.length; i++ )
- {
- String attributeName = attributeNames[i];
- dom.setAttribute( attributeName, src.getAttribute( attributeName ) );
- }
-
- Xpp3Dom[] children = src.getChildren();
- for ( int i = 0; i < children.length; i++ )
- {
- dom.addChild( copyXpp3Dom( children[i] ) );
- }
-
- return dom;
- }
-
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter )
{
StringBuffer message = new StringBuffer();
- message.append( "The '" + parameter.getName() ).append( "' parameter is required for the execution of the " ).append(
- mojo.getId() ).append( " mojo and cannot be null." );
+ message.append( "The '" + parameter.getName() );
+ message.append( "' parameter is required for the execution of the " );
+ message.append( mojo.getId() );
+ message.append( " mojo and cannot be null." );
return message.toString();
}
1.25 +5 -5 maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
Index: DefaultModelInheritanceAssembler.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- DefaultModelInheritanceAssembler.java 22 Mar 2005 10:46:55 -0000 1.24
+++ DefaultModelInheritanceAssembler.java 22 Mar 2005 11:29:55 -0000 1.25
@@ -26,7 +26,9 @@
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Repository;
import org.apache.maven.model.Scm;
+import org.apache.maven.util.Xpp3DomUtils;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.Iterator;
import java.util.List;
@@ -264,11 +266,9 @@
}
else
{
- // TODO: configuration not currently merged
- if ( childGoal.getConfiguration() == null )
- {
- childGoal.setConfiguration( parentGoal.getConfiguration() );
- }
+ Xpp3Dom childDom = (Xpp3Dom) childGoal.getConfiguration();
+ Xpp3Dom parentDom = (Xpp3Dom) parentGoal.getConfiguration();
+ childGoal.setConfiguration( Xpp3DomUtils.mergeXpp3Dom( childDom, parentDom ) );
}
}
}
1.8 +9 -10 maven-components/maven-core/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java
Index: DefaultModelDefaultsInjector.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultModelDefaultsInjector.java 22 Mar 2005 10:46:55 -0000 1.7
+++ DefaultModelDefaultsInjector.java 22 Mar 2005 11:29:55 -0000 1.8
@@ -22,6 +22,8 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
+import org.apache.maven.util.Xpp3DomUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList;
import java.util.Iterator;
@@ -118,22 +120,19 @@
}
else
{
- // TODO: merge
- if ( localGoal.getConfiguration() == null )
- {
- localGoal.setConfiguration( defaultGoal.getConfiguration() );
- }
+ Xpp3Dom goalConfiguration = (Xpp3Dom) localGoal.getConfiguration();
+ Xpp3Dom defaultGoalConfiguration = (Xpp3Dom) defaultGoal.getConfiguration();
+ localGoal.setConfiguration(
+ Xpp3DomUtils.mergeXpp3Dom( goalConfiguration, defaultGoalConfiguration ) );
}
}
}
plugin.setGoals( new ArrayList( goalMap.values() ) );
- // TODO: merge
- if ( plugin.getConfiguration() == null )
- {
- plugin.setConfiguration( def.getConfiguration() );
- }
+ Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration();
+ Xpp3Dom defaultPluginConfiguration = (Xpp3Dom) def.getConfiguration();
+ plugin.setConfiguration( Xpp3DomUtils.mergeXpp3Dom( pluginConfiguration, defaultPluginConfiguration ) );
}
private void injectDependencyDefaults( List dependencies, DependencyManagement dependencyManagement )
1.1 maven-components/maven-core/src/main/java/org/apache/maven/util/Xpp3DomUtils.java
Index: Xpp3DomUtils.java
===================================================================
package org.apache.maven.util;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed 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.
*/
/**
* TODO: describe
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: Xpp3DomUtils.java,v 1.1 2005/03/22 11:29:55 brett Exp $
*/
public class Xpp3DomUtils
{
private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
{
// TODO: how to mergeXpp3Dom lists rather than override?
// TODO: share this as some sort of assembler, implement a walk interface?
Xpp3Dom[] children = recessive.getChildren();
for ( int i = 0; i < children.length; i++ )
{
Xpp3Dom child = children[i];
Xpp3Dom childDom = dominant.getChild( child.getName() );
if ( childDom != null )
{
mergeIntoXpp3Dom( childDom, child );
}
else
{
dominant.addChild( copyXpp3Dom( child ) );
}
}
}
public static Xpp3Dom copyXpp3Dom( Xpp3Dom src )
{
// TODO: into Xpp3Dom as a copy constructor
Xpp3Dom dom = new Xpp3Dom( src.getName() );
dom.setValue( src.getValue() );
String[] attributeNames = src.getAttributeNames();
for ( int i = 0; i < attributeNames.length; i++ )
{
String attributeName = attributeNames[i];
dom.setAttribute( attributeName, src.getAttribute( attributeName ) );
}
Xpp3Dom[] children = src.getChildren();
for ( int i = 0; i < children.length; i++ )
{
dom.addChild( copyXpp3Dom( children[i] ) );
}
return dom;
}
public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
{
if ( dominant != null )
{
mergeIntoXpp3Dom( dominant, recessive );
return dominant;
}
return recessive;
}
}