o debugging configuration merging

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@771096 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-03 18:08:54 +00:00
parent 3fad6dd633
commit d0778cc82d
2 changed files with 74 additions and 22 deletions

View File

@ -15,6 +15,7 @@ package org.apache.maven.lifecycle;
* the License.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -38,11 +39,14 @@ import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginLoaderException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
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.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@ -177,8 +181,9 @@ public class DefaultLifecycleExecutor
for ( MojoExecution mojoExecution : lifecyclePlan )
{
try
{
{
logger.info( executionDescription( mojoExecution ) );
System.out.println( "!!!");
System.out.println( mojoExecution.getConfiguration() );
pluginManager.executeMojo( session, mojoExecution );
}
@ -194,7 +199,7 @@ public class DefaultLifecycleExecutor
}
}
}
private String executionDescription( MojoExecution me )
{
PluginDescriptor pd = me.getMojoDescriptor().getPluginDescriptor();
@ -330,10 +335,10 @@ public class DefaultLifecycleExecutor
//
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
//
MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, project, session.getLocalRepository() );
MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, project, session.getLocalRepository() );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
String g = mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId();
String a = mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId();
@ -569,6 +574,7 @@ public class DefaultLifecycleExecutor
public Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, MavenProject project, ArtifactRepository localRepository )
throws LifecycleExecutionException
{
//return new Xpp3Dom( "configuration" );
return convert( getMojoDescriptor( groupId+":"+artifactId+":"+version+":"+goal, project, localRepository ) );
}
@ -577,10 +583,9 @@ public class DefaultLifecycleExecutor
return convert( mojoDescriptor );
}
public Xpp3Dom convert( MojoDescriptor mojoDescriptor )
{
Map<String,Parameter> parameters = mojoDescriptor.getParameterMap();
{
Xpp3Dom dom = new Xpp3Dom( "configuration" );
PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
@ -588,15 +593,71 @@ public class DefaultLifecycleExecutor
PlexusConfiguration[] ces = c.getChildren();
for( PlexusConfiguration ce : ces )
{
Xpp3Dom e = new Xpp3Dom( ce.getName() );
e.setValue( ce.getValue( ce.getAttribute( "default-value", null ) ) );
dom.addChild( e );
{
if ( ce.getValue( null ) != null )
{
Xpp3Dom e = new Xpp3Dom( ce.getName() );
e.setValue( ce.getValue( null ) );
dom.addChild( e );
}
}
return dom;
}
// assign all values
// validate everything is fine
private Xpp3Dom processConfiguration( MavenSession session, MojoExecution mojoExecution )
{
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution );
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
Map<String,Parameter> parameters = mojoDescriptor.getParameterMap();
Xpp3Dom configuration = mojoExecution.getConfiguration();
for( Xpp3Dom c : configuration.getChildren() )
{
String configurationName = c.getName();
Parameter parameter = parameters.get( configurationName );
// Read-only
if ( !parameter.isEditable() )
{
}
try
{
Object value = expressionEvaluator.evaluate( c.getValue() );
if ( value == null )
{
String e = c.getAttribute( "default-value" );
if ( e != null )
{
System.out.println( ">> " + e );
value = expressionEvaluator.evaluate( e );
}
}
if ( value instanceof String || value instanceof File )
c.setValue( value.toString() );
}
catch ( ExpressionEvaluationException e )
{
// do nothing
}
}
return mojoExecution.getConfiguration();
}
// These are checks that should be available in real time to IDEs
/*

View File

@ -193,9 +193,6 @@ public class DefaultMavenProjectBuilder
Set<Plugin> pl = lifecycle.populateDefaultConfigurationForPlugins(new HashSet<Plugin>(pln),
project, configuration.getLocalRepository());
/*
*/
for (Plugin buildPlugin : pl) {
Xpp3Dom dom = (Xpp3Dom) buildPlugin.getConfiguration();
@ -219,15 +216,9 @@ public class DefaultMavenProjectBuilder
}
}
}
}
project.getModel().getBuild().setPlugins(new ArrayList<Plugin>(pl));
/*
if(model.getArtifactId() != null &&
model.getArtifactId().equals("maven-model"))
{
System.out.println(new DomainModel(project.getModel()).asString());
}
*/
}
catch (IOException e)
{