diff --git a/src/it/mrm/parent-deps-1.1.pom b/src/it/mrm/parent-deps-1.1.pom new file mode 100644 index 000000000000..8142f76ab439 --- /dev/null +++ b/src/it/mrm/parent-deps-1.1.pom @@ -0,0 +1,17 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + parent-deps + 1.1 + pom + + + + + org.codehaus.mojo.flatten.its + dep + 1.1 + provided + + + \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-depmgnt-provided-transitive/pom.xml b/src/it/projects/flatten-dependency-all-depmgnt-provided-transitive/pom.xml new file mode 100644 index 000000000000..309ce9d39079 --- /dev/null +++ b/src/it/projects/flatten-dependency-all-depmgnt-provided-transitive/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + flatten-dependency-all-depmgnt-provided-transitive + 0.0.1-SNAPSHOT + + + + + org.codehaus.mojo.flatten.its + dep + 1.1 + provided + + + + + + + org.codehaus.mojo.flatten.its + parent-deps + 1 + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + all + + + + + \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-depmgnt-provided-transitive/verify.groovy b/src/it/projects/flatten-dependency-all-depmgnt-provided-transitive/verify.groovy new file mode 100644 index 000000000000..13dab1ffd73b --- /dev/null +++ b/src/it/projects/flatten-dependency-all-depmgnt-provided-transitive/verify.groovy @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File originalPom = new File( basedir, 'pom.xml' ) +assert originalPom.exists() + +def originalProject = new XmlSlurper().parse( originalPom ) +assert 1 == originalProject.dependencies.size() + +File flattendPom = new File( basedir, '.flattened-pom.xml' ) +assert flattendPom.exists() + +def flattendProject = new XmlSlurper().parse( flattendPom ) +assert 1 == flattendProject.dependencies.size() +assert 1 == flattendProject.dependencies.dependency.size() + + diff --git a/src/it/projects/flatten-dependency-all-provided-children/pom.xml b/src/it/projects/flatten-dependency-all-provided-children/pom.xml new file mode 100644 index 000000000000..152ad6e991be --- /dev/null +++ b/src/it/projects/flatten-dependency-all-provided-children/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + flatten-dependency-all-depmgnt-provided-transitive + 0.0.1-SNAPSHOT + + + + org.codehaus.mojo.flatten.its + parent-deps + 1 + provided + + + + + verify + + + org.codehaus.mojo + flatten-maven-plugin + + all + + + + + \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-provided-children/verify.groovy b/src/it/projects/flatten-dependency-all-provided-children/verify.groovy new file mode 100644 index 000000000000..3d175eba7d24 --- /dev/null +++ b/src/it/projects/flatten-dependency-all-provided-children/verify.groovy @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File originalPom = new File( basedir, 'pom.xml' ) +assert originalPom.exists() + +def originalProject = new XmlSlurper().parse( originalPom ) +assert 1 == originalProject.dependencies.size() + +File flattendPom = new File( basedir, '.flattened-pom.xml' ) +assert flattendPom.exists() + +def flattendProject = new XmlSlurper().parse( flattendPom ) +assert 1 == flattendProject.dependencies.size() +assert 1 == flattendProject.dependencies.dependency.size() \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-provided-direct/pom.xml b/src/it/projects/flatten-dependency-all-provided-direct/pom.xml new file mode 100644 index 000000000000..246d39766fde --- /dev/null +++ b/src/it/projects/flatten-dependency-all-provided-direct/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + flatten-dependency-all-provided-direct + 0.0.1-SNAPSHOT + + + + org.codehaus.mojo.flatten.its + dep + 1.1 + provided + + + + + verify + + + org.codehaus.mojo + flatten-maven-plugin + + all + + + + + \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-provided-direct/verify.groovy b/src/it/projects/flatten-dependency-all-provided-direct/verify.groovy new file mode 100644 index 000000000000..c659846277cf --- /dev/null +++ b/src/it/projects/flatten-dependency-all-provided-direct/verify.groovy @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File originalPom = new File( basedir, 'pom.xml' ) +assert originalPom.exists() + +def originalProject = new XmlSlurper().parse( originalPom ) +assert 1 == originalProject.dependencies.size() + +File flattendPom = new File( basedir, '.flattened-pom.xml' ) +assert flattendPom.exists() + +def flattenedProject = new XmlSlurper().parse( flattendPom ) +assert 1 == flattenedProject.dependencies.size() +assert 1 == flattenedProject.dependencies.dependency.size() + +String scope = flattenedProject.dependencies.dependency.scope +assert "provided" == scope \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-provided-transitive/pom.xml b/src/it/projects/flatten-dependency-all-provided-transitive/pom.xml new file mode 100644 index 000000000000..05fb4f2d576c --- /dev/null +++ b/src/it/projects/flatten-dependency-all-provided-transitive/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + flatten-dependency-all-provided-transitive + 0.0.1-SNAPSHOT + + + + org.codehaus.mojo.flatten.its + parent-deps + 1.1 + + + + + verify + + + org.codehaus.mojo + flatten-maven-plugin + + all + + + + + \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-provided-transitive/verify.groovy b/src/it/projects/flatten-dependency-all-provided-transitive/verify.groovy new file mode 100644 index 000000000000..4cd635c5a6b9 --- /dev/null +++ b/src/it/projects/flatten-dependency-all-provided-transitive/verify.groovy @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File originalPom = new File( basedir, 'pom.xml' ) +assert originalPom.exists() + +def originalProject = new XmlSlurper().parse( originalPom ) +assert 1 == originalProject.dependencies.size() + +File flattendPom = new File( basedir, '.flattened-pom.xml' ) +assert flattendPom.exists() + +def flattenedProject = new XmlSlurper().parse( flattendPom ) +assert 1 == flattenedProject.dependencies.size() +assert 1 == flattenedProject.dependencies.dependency.size() \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java index ac9b97b1e81e..eaadbd73bc40 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java @@ -1067,10 +1067,20 @@ private void createFlattenedDependenciesAll( List projectDependencie { return true; } - if (node.getState() != DependencyNode.INCLUDED) { + if ("provided".equals(node.getArtifact().getScope())) + { + DependencyNode parent = node.getParent(); + if(!parent.getArtifact().getGroupId().equals(projectArtifact.getGroupId()) || !parent.getArtifact().getArtifactId().equals(projectArtifact.getArtifactId())) + { + return false; + } + } + if (node.getState() != DependencyNode.INCLUDED) + { return false; } - if (node.getArtifact().isOptional()) { + if (node.getArtifact().isOptional()) + { return false; } dependencyNodeLinkedList.add(node);