mirror of https://github.com/apache/maven.git
o the first phase of merging plugin configuration as defined in the POM
with defaults and user defined values. After a chat with emmanuel we decided that we would allow for plugin wide configuration and mojo/goal specific configuration with the more specific mojo/goal configuration winning in the event a parameter is defined in both places. Currently only plugin wide parameters are being considered: I still need to update the model for mojo/goal specific parameters and then update the parameter merging code. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163181 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b6ba62ae98
commit
552b22c77a
|
@ -26,7 +26,9 @@
|
|||
import org.apache.maven.plugin.PluginConfigurationException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.util.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -121,6 +123,20 @@ private Map createParameters( MojoDescriptor goal, MavenGoalExecutionContext con
|
|||
|
||||
Object value = OgnlProjectValueExtractor.evaluate( expression, context );
|
||||
|
||||
map.put( key, value );
|
||||
}
|
||||
|
||||
map = mergeProjectDefinedPluginConfiguration( context.getProject(), goal.getId(), map );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < parameters.size(); i++ )
|
||||
{
|
||||
Parameter parameter = (Parameter) parameters.get( i );
|
||||
|
||||
String key = parameter.getName();
|
||||
|
||||
Object value = map.get( key );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// We will perform a basic check here for parameters values that are
|
||||
// required. Required parameters can't be null so we throw an
|
||||
|
@ -133,8 +149,31 @@ private Map createParameters( MojoDescriptor goal, MavenGoalExecutionContext con
|
|||
{
|
||||
throw new PluginConfigurationException( createPluginParameterRequiredMessage( goal, parameter ) );
|
||||
}
|
||||
}
|
||||
|
||||
map.put( key, value );
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map mergeProjectDefinedPluginConfiguration( MavenProject project, String goalId, Map map )
|
||||
{
|
||||
// ----------------------------------------------------------------------
|
||||
// I would like to be able to lookup the Plugin object using a key but
|
||||
// we have a limitation in modello that will be remedied shortly. So
|
||||
// for now I have to iterate through and see what we have.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if ( project.getPlugins() != null )
|
||||
{
|
||||
String pluginId = goalId.substring( 0, goalId.indexOf( ":" ) );
|
||||
|
||||
for ( Iterator iterator = project.getPlugins().iterator(); iterator.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin) iterator.next();
|
||||
|
||||
if ( pluginId.equals( plugin.getId() ) )
|
||||
{
|
||||
return CollectionUtils.mergeMaps( plugin.getConfiguration(), map );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue