hack in a dom so we can use plexus configuration. more to do...

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163635 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-21 07:23:07 +00:00
parent 28e193d14c
commit 3bd980bdb1
1 changed files with 47 additions and 19 deletions

View File

@ -43,10 +43,14 @@ import org.apache.maven.settings.MavenSettingsBuilder;
import org.codehaus.plexus.ArtifactEnabledContainer; import org.codehaus.plexus.ArtifactEnabledContainer;
import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.configurator.BasicComponentConfigurator;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -55,6 +59,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.util.CollectionUtils; import org.codehaus.plexus.util.CollectionUtils;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
@ -493,12 +498,23 @@ public class DefaultPluginManager
List parameters = mojoDescriptor.getParameters(); List parameters = mojoDescriptor.getParameters();
Xpp3Dom dom = new Xpp3Dom( mojoDescriptor.getId() );
for ( Iterator i = parameters.iterator(); i.hasNext(); ) for ( Iterator i = parameters.iterator(); i.hasNext(); )
{ {
Parameter param = (Parameter) i.next(); Parameter param = (Parameter) i.next();
String name = param.getName(); String name = param.getName();
Object value = values.get( name ); Object value = values.get( name );
// TODO:Still not complete robust - need to merge in the processing in createParameters
if ( value instanceof String )
{
Xpp3Dom d = new Xpp3Dom( name );
d.setValue( (String) value );
dom.addChild( d );
}
else
{
Class clazz = plugin.getClass(); Class clazz = plugin.getClass();
try try
{ {
@ -527,6 +543,18 @@ public class DefaultPluginManager
} }
} }
// TODO: should be a component
ComponentConfigurator configurator = new BasicComponentConfigurator();
try
{
configurator.configureComponent( plugin, new XmlPlexusConfiguration( dom ) );
}
catch ( ComponentConfigurationException e )
{
throw new PluginConfigurationException( "Unable to parse the created DOM for plugin configuration", e );
}
}
public Map createParameters( MojoDescriptor goal, MavenSession session ) public Map createParameters( MojoDescriptor goal, MavenSession session )
throws PluginConfigurationException throws PluginConfigurationException
{ {