From 1c2b979977d09e05a3a9bd2a0b2644773e3157af Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Mon, 26 Jan 2009 03:29:07 +0000 Subject: [PATCH] MNG-3887: order of plugin executions, MNG-3864: plugin configs are collapsed, MNG-4000: Plugin executions without id are lost git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@737633 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/project/builder/PomTransformer.java | 24 ++++++++++--------- .../project/builder/PomConstructionTest.java | 22 +++++++++-------- .../wo-plugin-mngt/sub/pom.xml | 2 +- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java b/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java index eb4492897b..c15a304d59 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java @@ -333,19 +333,20 @@ public class PomTransformer continue; } - boolean hasAtLeastOneWithoutId = true; + boolean hasAtLeastOneWithoutId = false; for ( ModelContainer executionContainer : executionContainers ) { - if ( hasAtLeastOneWithoutId ) - { - hasAtLeastOneWithoutId = hasExecutionId( executionContainer ); - } + - if ( !hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) && executionContainers.indexOf( executionContainer ) > 0 ) + if ( hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) && executionContainers.indexOf( executionContainer ) > 0 ) { removeProperties.addAll( executionContainer.getProperties() ); } + if ( !hasAtLeastOneWithoutId ) + { + hasAtLeastOneWithoutId = !hasExecutionId( executionContainer ); + } } } @@ -362,16 +363,17 @@ public class PomTransformer new AlwaysJoinModelContainerFactory())); for(ModelContainer es : executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri )) { ExecutionRule rule = new ExecutionRule(); - //List x = rule.execute(es.getProperties()); - List x = (!joinedContainer) ? rule.execute(es.getProperties()) : - ModelTransformerContext.sort(rule.execute(es.getProperties()), - ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); + List x = rule.execute(es.getProperties()); + // List x = (!joinedContainer) ? rule.execute(es.getProperties()) : + // ModelTransformerContext.sort(rule.execute(es.getProperties()), + // ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); dataSource.replace(es, es.createNewInstance(x)); } } - props = dataSource.getModelProperties(); + props = joinedContainer ? ModelTransformerContext.sort(dataSource.getModelProperties(), ProjectUri.baseUri) + : dataSource.getModelProperties(); for(ModelEventListener listener : eventListeners) { diff --git a/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java index 2e70bf120a..0a08f21f92 100644 --- a/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/builder/PomConstructionTest.java @@ -111,7 +111,9 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "execution-configuration" ); - assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions[1]/configuration" ) ).size() ); + assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); + assertEquals( "src/main/mdo/nexus.xml", ( pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/model" ) )); + assertEquals( "src/main/mdo/security.xml", ( pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/model" ) )); } public void testSingleConfigurationInheritance() @@ -128,8 +130,8 @@ public class PomConstructionTest { PomTestWrapper pom = buildPom( "config-with-plugin-mng" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "src/main/mdo/security.xml", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/model" ) ); - assertEquals( "1.0.8", pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/version" ) ); + assertEquals( "src/main/mdo/security.xml", pom.getValue( "build/plugins[1]/executions[2]/configuration[1]/model" ) ); + assertEquals( "1.0.8", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/version" ) ); } /** MNG-3965 */ @@ -145,7 +147,7 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "foo/sub" ); - System.out.println(pom.getDomainModel().asString()); + //System.out.println(pom.getDomainModel().asString()); } /** MNG-3985 */ @@ -211,7 +213,7 @@ public class PomConstructionTest assertEquals( "e", pom.getValue( "build/plugins[1]/executions[5]/id" ) ); } - /* FIXME: cf. MNG-3887 + /* FIXME: cf. MNG-3887 */ public void testOrderOfPluginExecutionsWithPluginManagement() throws Exception { @@ -248,7 +250,7 @@ public class PomConstructionTest assertEquals( "Tom&Jerry", pom.getValue( "properties/xmlTest" ) ); } - /* FIXME: cf. MNG-3925 + /* FIXME: cf. MNG-3925 public void testOrderOfMergedPluginExecutionsWithoutPluginManagement() throws Exception { @@ -315,7 +317,7 @@ public class PomConstructionTest { PomTestWrapper pom = buildPom( "plugin-exec-merging/wo-plugin-mngt/sub" ); assertEquals( 2, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); - assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default']/phase" ) ); + assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default-execution-id']/phase" ) ); assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) ); } @@ -514,7 +516,7 @@ public class PomConstructionTest assertEquals( "four", pom.getValue( "build/plugins[1]/configuration/stringParams/stringParam[4]" ) ); } - /* FIXME: cf. MNG-3827 + /* FIXME: cf. MNG-3827*/ public void testOrderOfPluginConfigurationElementsWithPluginManagement() throws Exception { @@ -539,7 +541,7 @@ public class PomConstructionTest assertEquals( "key2", pom.getValue( prefix + "propertiesParam/property[2]/name" ) ); } - /* FIXME: cf. MNG-3864 + /* FIXME: cf. MNG-3864*/ public void testOrderOfPluginExecutionConfigurationElementsWithPluginManagement() throws Exception { @@ -598,7 +600,7 @@ public class PomConstructionTest } //*/ - /* FIXME: cf. MNG-4000 + /* FIXME: cf. MNG-4000 */ public void testMultiplePluginExecutionsWithAndWithoutIdsWithoutPluginManagement() throws Exception { diff --git a/maven-project/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mngt/sub/pom.xml b/maven-project/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mngt/sub/pom.xml index 827b907535..a3f4ff6101 100644 --- a/maven-project/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mngt/sub/pom.xml +++ b/maven-project/src/test/resources-project-builder/plugin-exec-merging/wo-plugin-mngt/sub/pom.xml @@ -45,7 +45,7 @@ under the License. - default + default-execution-id child-default