Fixed various ordering of element problems during plugin management joins.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@737812 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-01-26 20:22:20 +00:00
parent 1c2b979977
commit 702ed0b0dd
3 changed files with 41 additions and 14 deletions

View File

@ -177,7 +177,7 @@ public class PomTransformer
}
}
boolean joinedContainer = false;
List<ModelProperty> joinedContainers = new ArrayList<ModelProperty>();
for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ) )
{
for ( ModelContainer managementContainer : source.queryFor( ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri ) )
@ -230,7 +230,6 @@ public class PomTransformer
if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) )
{
joinedContainer = true;
ModelDataSource pluginDatasource = new DefaultModelDataSource( pluginContainer.getProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES );
ModelDataSource managementDatasource = new DefaultModelDataSource( managementContainer.getProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES );
@ -241,7 +240,7 @@ public class PomTransformer
managementPropertiesWithoutExecutions.removeAll(a.getProperties());
}
//THIS JOIN REVERSES ORDER
source.join( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) );
source.joinWithOriginalOrder( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) );
List<ModelContainer> pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
List<ModelContainer> joinedExecutionContainers = new ArrayList<ModelContainer>();
@ -266,13 +265,19 @@ public class PomTransformer
for(ModelContainer b : pluginExecutionContainers)
{
if(b.containerAction(c).equals(ModelContainerAction.JOIN)) //----
if(b.containerAction(c).equals(ModelContainerAction.JOIN))
{
//MNG-3995 - property lost here
source.join(b, c);
joinedContainers.addAll(source.join(b, c).getProperties());
// ExecutionRule rule = new ExecutionRule();
// List<ModelProperty> x = rule.execute(d.getProperties());
// List<ModelProperty> x = (!joinedContainer) ? rule.execute(es.getProperties()) :
// ModelTransformerContext.sort(rule.execute(es.getProperties()),
// ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
// source.replace(d, d.createNewInstance(x));
//REVERSE ORDER HERE
joinedExecutionContainers.add(a);//-----
// Collections.reverse(joinedExecutionContainers);
joinedExecutionContainers.add(a);
}
}
}
@ -363,17 +368,17 @@ public class PomTransformer
new AlwaysJoinModelContainerFactory()));
for(ModelContainer es : executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri )) {
ExecutionRule rule = new ExecutionRule();
List<ModelProperty> x = rule.execute(es.getProperties());
// List<ModelProperty> x = (!joinedContainer) ? rule.execute(es.getProperties()) :
// ModelTransformerContext.sort(rule.execute(es.getProperties()),
// ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
// List<ModelProperty> x = rule.execute(es.getProperties());
List<ModelProperty> x = !aContainsAnyOfB(es.getProperties(), joinedContainers) ? rule.execute(es.getProperties()) :
ModelTransformerContext.sort(rule.execute(es.getProperties()),
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
dataSource.replace(es, es.createNewInstance(x));
}
}
props = joinedContainer ? ModelTransformerContext.sort(dataSource.getModelProperties(), ProjectUri.baseUri)
: dataSource.getModelProperties();
props =// false ? ModelTransformerContext.sort(dataSource.getModelProperties(), ProjectUri.baseUri)
dataSource.getModelProperties();
for(ModelEventListener listener : eventListeners)
{
@ -411,6 +416,20 @@ public class PomTransformer
return factory.createDomainModel( p );
}
private static boolean aContainsAnyOfB(List<ModelProperty> a, List<ModelProperty> b) {
for(ModelProperty mpA : a )
{
for(ModelProperty mpB : b)
{
if(mpA.equals(mpB))
{
return true;
}
}
}
return false;
}
private static List<ModelProperty> transformDependencyManagement( List<ModelProperty> modelProperties )
{
List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();

View File

@ -81,6 +81,14 @@ public class PomConstructionTest
assertModelEquals( tester, "child-descriptor", "build/plugins[1]/executions[1]/goals[1]" );
}
public void testPluginOrder()
throws Exception
{
PomTestWrapper pom = buildPom( "plugin-order" );
assertEquals( "plexus-component-metadata", pom.getValue( "build/plugins[1]/artifactId" ) );
assertEquals( "maven-surefire-plugin", pom.getValue( "build/plugins[2]/artifactId" ) );
}
public void testErroneousJoiningOfDifferentPluginsWithEqualDependencies()
throws Exception
{

View File

@ -55,7 +55,7 @@ under the License.
<plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
<plexusUtilsVersion>1.5.6</plexusUtilsVersion>
<wagonVersion>1.0-beta-4</wagonVersion>
<modelBuilderVersion>1.2</modelBuilderVersion>
<modelBuilderVersion>1.3</modelBuilderVersion>
<mercuryVersion>1.0.0-alpha-2</mercuryVersion>
<woodstoxVersion>3.2.6</woodstoxVersion>
<modelloVersion>1.0-alpha-22</modelloVersion>