Fix for problems with modello plugin. Builder was not properly inheriting the goals.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@721608 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2008-11-29 01:41:35 +00:00
parent 8d32719c39
commit 4d84546f7b
3 changed files with 76 additions and 4 deletions

View File

@ -10,7 +10,8 @@ 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));
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.xUri));
public Collection<String> getUris() {
return uris;

View File

@ -44,6 +44,7 @@ public class PomTransformer
public static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
ProjectUri.Build.PluginManagement.Plugins.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
//ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
@ -149,6 +150,7 @@ public class PomTransformer
transformPluginManagement( managementContainer.getProperties() ) );
//Remove duplicate executions tags
boolean hasExecutionsTag = false;
for ( ModelProperty mp : dependencyContainer.getProperties() )
{
@ -176,9 +178,71 @@ public class PomTransformer
managementContainer = new ArtifactModelContainerFactory().create( pList );
ModelContainerAction action = dependencyContainer.containerAction( managementContainer );
// System.out.println(action);
if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) )
{
source.join( dependencyContainer, managementContainer );
{ //System.out.println("A:");
ModelDataSource dependencyDatasource = new DefaultModelDataSource();
dependencyDatasource.init( dependencyContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
new IdModelContainerFactory() ) );
ModelDataSource managementDatasource = new DefaultModelDataSource();
managementDatasource.init( managementContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
new IdModelContainerFactory() ) );
List<ModelContainer> managementExecutionContainers = managementDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
List<ModelProperty> managementPropertiesWithoutExecutions = new ArrayList<ModelProperty>(managementContainer.getProperties());
for(ModelContainer a : managementExecutionContainers)
{
managementPropertiesWithoutExecutions.removeAll(a.getProperties());
}
source.join( dependencyContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) );
List<ModelContainer> dependencyExecutionContainers = dependencyDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
List<ModelContainer> joinedExecutionContainers = new ArrayList<ModelContainer>();
//System.out.println(managementExecutionContainers.size());
for(ModelContainer a : managementExecutionContainers)
{
for(ModelContainer b : dependencyExecutionContainers)
{
if(b.containerAction(a).equals(ModelContainerAction.JOIN))
{
source.join(b, a);
joinedExecutionContainers.add(a);
}
}
}
ModelProperty executionsProperty = null;
for(ModelProperty a : dependencyContainer.getProperties())
{
if(a.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.xUri)) {
executionsProperty = a;
break;
}
}
if(executionsProperty == null)
{
for(ModelProperty a : managementPropertiesWithoutExecutions)
{
if(a.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.xUri)) {
executionsProperty = a;
break;
}
}
}
if(executionsProperty != null)
{
managementExecutionContainers.removeAll(joinedExecutionContainers);
Collections.reverse(managementExecutionContainers);
for(ModelContainer a : managementExecutionContainers)
{
source.insertModelPropertiesAfter(executionsProperty,
ModelTransformerContext.sort(a.getProperties(), ProjectUri.Build.Plugins.Plugin.Executions.xUri));
}
}
}
}
}

View File

@ -40,6 +40,8 @@ import java.io.InputStream;
import java.io.Writer;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
/**
* Provides a wrapper for the maven model.
@ -283,8 +285,13 @@ public final class PomClassicDomainModel
{
if(modelProperties == null)
{
Set<String> s = new HashSet<String>();
//TODO: Should add all collections from ProjectUri
s.addAll(PomTransformer.URIS);
s.add(ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri);
s.add(ProjectUri.Build.Plugins.Plugin.Executions.xUri);
modelProperties = ModelMarshaller.marshallXmlToModelProperties(
getInputStream(), ProjectUri.baseUri, PomTransformer.URIS );
getInputStream(), ProjectUri.baseUri, s );
}
return new ArrayList<ModelProperty>(modelProperties);
}