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 48d661175d..22e341173f 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 @@ -390,7 +390,8 @@ public class PomTransformer { int index = props.indexOf(mp) + 1; - if(index <= props.size() && mp.isParentOf(props.get(index)) && !props.get(index).getUri().contains("#property")) + if(index <= props.size() && mp.isParentOf(props.get(index)) && mp.getDepth() != props.get(index).getDepth() + && !props.get(index).getUri().contains("#property")) { p.add(new ModelProperty(mp.getUri(), null)); } 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 f0c9000fcc..7ecfec0eb5 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 @@ -122,6 +122,15 @@ public class PomConstructionTest // System.out.println(pom.getDomainModel().asString()); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); } + + /** MNG-3997 */ + public void testConsecutiveEmptyElements() + throws Exception + { + PomTestWrapper pom = buildPom( "consecutive_empty_elements" ); + pom.getDomainModel().asString(); + } + //*/ public void testOrderOfGoalsFromPluginExecutionWithoutPluginManagement() throws Exception diff --git a/maven-project/src/test/resources-project-builder/consecutive_empty_elements/pom.xml b/maven-project/src/test/resources-project-builder/consecutive_empty_elements/pom.xml new file mode 100644 index 0000000000..16d1968fa3 --- /dev/null +++ b/maven-project/src/test/resources-project-builder/consecutive_empty_elements/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + test + artifact + 1.0 + + + + + + + + +