mirror of https://github.com/apache/maven.git
o Moved expansion of plugin configuration into component
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@773692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
129bcf0e1d
commit
3f08e048a9
|
@ -44,6 +44,7 @@ import org.apache.maven.model.Profile;
|
|||
import org.apache.maven.model.interpolator.Interpolator;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.model.lifecycle.LifecycleBindingsInjector;
|
||||
import org.apache.maven.model.plugin.PluginConfigurationExpander;
|
||||
import org.apache.maven.profiles.DefaultProfileManager;
|
||||
import org.apache.maven.profiles.ProfileActivationException;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
|
@ -87,6 +88,9 @@ public class DefaultMavenProjectBuilder
|
|||
@Requirement
|
||||
private LifecycleBindingsInjector lifecycleBindingsInjector;
|
||||
|
||||
@Requirement
|
||||
private PluginConfigurationExpander pluginConfigurationExpander;
|
||||
|
||||
@Requirement
|
||||
private ResolutionErrorHandler resolutionErrorHandler;
|
||||
|
||||
|
@ -169,33 +173,10 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
if ( configuration.isProcessPlugins() )
|
||||
{
|
||||
Collection<Plugin> pluginsFromProject = project.getModel().getBuild().getPlugins();
|
||||
pluginConfigurationExpander.expandPluginConfiguration( project.getModel() );
|
||||
|
||||
// Merge the various sources for mojo configuration:
|
||||
// 1. default values from mojo descriptor
|
||||
// 2. POM values from per-plugin configuration
|
||||
// 3. POM values from per-execution configuration
|
||||
// These configuration sources are given in increasing order of dominance.
|
||||
|
||||
// push plugin configuration down to executions
|
||||
for ( Plugin buildPlugin : pluginsFromProject )
|
||||
{
|
||||
Xpp3Dom dom = (Xpp3Dom) buildPlugin.getConfiguration();
|
||||
|
||||
if ( dom != null )
|
||||
{
|
||||
for ( PluginExecution e : buildPlugin.getExecutions() )
|
||||
{
|
||||
Xpp3Dom dom1 = Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) e.getConfiguration(), new Xpp3Dom( dom ) );
|
||||
e.setConfiguration( dom1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// merge in default values from mojo descriptor
|
||||
lifecycle.populateDefaultConfigurationForPlugins( pluginsFromProject, project, configuration.getLocalRepository() );
|
||||
|
||||
project.getModel().getBuild().setPlugins( new ArrayList<Plugin>( pluginsFromProject ) );
|
||||
lifecycle.populateDefaultConfigurationForPlugins( project.getModel().getBuild().getPlugins(), project,
|
||||
configuration.getLocalRepository() );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package org.apache.maven.model.plugin;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/**
|
||||
* Handles expansion of general plugin configuration into individual executions and report sets.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
@Component( role = PluginConfigurationExpander.class )
|
||||
public class DefaultPluginConfigurationExpander
|
||||
implements PluginConfigurationExpander
|
||||
{
|
||||
|
||||
public void expandPluginConfiguration( Model model )
|
||||
{
|
||||
Build build = model.getBuild();
|
||||
Reporting reporting = model.getReporting();
|
||||
|
||||
if ( build != null )
|
||||
{
|
||||
for ( Plugin buildPlugin : build.getPlugins() )
|
||||
{
|
||||
Xpp3Dom parentDom = (Xpp3Dom) buildPlugin.getConfiguration();
|
||||
|
||||
if ( parentDom != null )
|
||||
{
|
||||
for ( PluginExecution execution : buildPlugin.getExecutions() )
|
||||
{
|
||||
Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration();
|
||||
childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) );
|
||||
execution.setConfiguration( childDom );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( reporting != null )
|
||||
{
|
||||
for ( ReportPlugin reportPlugin : reporting.getPlugins() )
|
||||
{
|
||||
Xpp3Dom parentDom = (Xpp3Dom) reportPlugin.getConfiguration();
|
||||
|
||||
if ( parentDom != null )
|
||||
{
|
||||
for ( ReportSet execution : reportPlugin.getReportSets() )
|
||||
{
|
||||
Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration();
|
||||
childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) );
|
||||
execution.setConfiguration( childDom );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.apache.maven.model.plugin;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
/**
|
||||
* Handles expansion of general plugin configuration into individual executions and report sets.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public interface PluginConfigurationExpander
|
||||
{
|
||||
|
||||
/**
|
||||
* Merges values from general plugin configuration into the individual plugin executions and reports sets of the
|
||||
* given model.
|
||||
*
|
||||
* @param model The model whose plugin configuration should be expanded, must not be <code>null</code>.
|
||||
*/
|
||||
void expandPluginConfiguration( Model model );
|
||||
|
||||
}
|
Loading…
Reference in New Issue