mirror of https://github.com/apache/maven.git
Fix for IT 2695. Two plugins with different executions that had same id were merging. Created a different container for execution ids, so that they can be queried per plugin, rather than globally.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@711743 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
824e2eefe7
commit
3d85fa7874
|
@ -36,8 +36,7 @@ public class IdModelContainerFactory
|
||||||
|
|
||||||
private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
|
private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
|
||||||
ProjectUri.PluginRepositories.PluginRepository.xUri, ProjectUri.Repositories.Repository.xUri,
|
ProjectUri.PluginRepositories.PluginRepository.xUri, ProjectUri.Repositories.Repository.xUri,
|
||||||
ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri, ProjectUri.Profiles.Profile.xUri,
|
ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri, ProjectUri.Profiles.Profile.xUri) );
|
||||||
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ) );
|
|
||||||
|
|
||||||
public Collection<String> getUris()
|
public Collection<String> getUris()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package org.apache.maven.project.builder;
|
||||||
|
|
||||||
|
import org.apache.maven.shared.model.ModelContainerFactory;
|
||||||
|
import org.apache.maven.shared.model.ModelContainer;
|
||||||
|
import org.apache.maven.shared.model.ModelProperty;
|
||||||
|
import org.apache.maven.shared.model.ModelContainerAction;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class PluginExecutionIdModelContainerFactory implements ModelContainerFactory {
|
||||||
|
|
||||||
|
private static final Collection<String> uris = Collections.unmodifiableList(Arrays.asList(
|
||||||
|
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri));
|
||||||
|
|
||||||
|
public Collection<String> getUris() {
|
||||||
|
return uris;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelContainer create(List<ModelProperty> modelProperties) {
|
||||||
|
if ( modelProperties == null || modelProperties.size() == 0 )
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException( "modelProperties: null or empty" );
|
||||||
|
}
|
||||||
|
return new PluginExecutionIdModelContainer( modelProperties );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PluginExecutionIdModelContainer
|
||||||
|
implements ModelContainer
|
||||||
|
{
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private List<ModelProperty> properties;
|
||||||
|
|
||||||
|
private PluginExecutionIdModelContainer( List<ModelProperty> properties )
|
||||||
|
{
|
||||||
|
this.properties = new ArrayList<ModelProperty>( properties );
|
||||||
|
this.properties = Collections.unmodifiableList( this.properties );
|
||||||
|
|
||||||
|
for ( ModelProperty mp : properties )
|
||||||
|
{
|
||||||
|
if ( mp.getUri().endsWith( "/id" ) )
|
||||||
|
{
|
||||||
|
this.id = mp.getResolvedValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelContainerAction containerAction( ModelContainer modelContainer )
|
||||||
|
{
|
||||||
|
if ( modelContainer == null )
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException( "modelContainer: null" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !( modelContainer instanceof PluginExecutionIdModelContainer ) )
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException( "modelContainer: wrong type" );
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginExecutionIdModelContainer c = (PluginExecutionIdModelContainer) modelContainer;
|
||||||
|
if ( c.id == null || id == null )
|
||||||
|
{
|
||||||
|
return ModelContainerAction.NOP;
|
||||||
|
}
|
||||||
|
return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
|
||||||
|
{
|
||||||
|
return new PluginExecutionIdModelContainer( modelProperties );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ModelProperty> getProperties()
|
||||||
|
{
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "ID = " + id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,14 +46,12 @@ public final class PomClassicTransformer
|
||||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
|
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
|
||||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
|
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
|
||||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
|
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
|
||||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
|
|
||||||
|
|
||||||
ProjectUri.Build.Plugins.xUri,
|
ProjectUri.Build.Plugins.xUri,
|
||||||
ProjectUri.Build.Plugins.Plugin.configuration,
|
ProjectUri.Build.Plugins.Plugin.configuration,
|
||||||
ProjectUri.Reporting.Plugins.xUri,
|
ProjectUri.Reporting.Plugins.xUri,
|
||||||
ProjectUri.Reporting.Plugins.Plugin.configuration,
|
ProjectUri.Reporting.Plugins.Plugin.configuration,
|
||||||
ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
|
ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
|
||||||
ProjectUri.Build.Plugins.Plugin.Executions.xUri,
|
|
||||||
ProjectUri.Build.Resources.xUri,
|
ProjectUri.Build.Resources.xUri,
|
||||||
ProjectUri.Build.Resources.Resource.includes,
|
ProjectUri.Build.Resources.Resource.includes,
|
||||||
ProjectUri.Build.Resources.Resource.excludes,
|
ProjectUri.Build.Resources.Resource.excludes,
|
||||||
|
@ -202,7 +200,7 @@ public final class PomClassicTransformer
|
||||||
{
|
{
|
||||||
ModelDataSource executionSource = new DefaultModelDataSource();
|
ModelDataSource executionSource = new DefaultModelDataSource();
|
||||||
executionSource.init( pluginContainer.getProperties(),
|
executionSource.init( pluginContainer.getProperties(),
|
||||||
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) );
|
||||||
List<ModelContainer> executionContainers =
|
List<ModelContainer> executionContainers =
|
||||||
executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
||||||
if ( executionContainers.size() < 2 )
|
if ( executionContainers.size() < 2 )
|
||||||
|
@ -318,7 +316,7 @@ public final class PomClassicTransformer
|
||||||
{
|
{
|
||||||
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
|
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
|
||||||
ModelDataSource source = new DefaultModelDataSource();
|
ModelDataSource source = new DefaultModelDataSource();
|
||||||
source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) );
|
||||||
List<ModelContainer> containers =
|
List<ModelContainer> containers =
|
||||||
source.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
source.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
||||||
for ( ModelContainer container : containers )
|
for ( ModelContainer container : containers )
|
||||||
|
|
Loading…
Reference in New Issue