From 0d9973155d32d8e6b521c970fa304b058ee4c3be Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Tue, 9 Aug 2022 15:43:51 -0400 Subject: [PATCH] Test case that fails #185 --- .../pom.xml | 35 +++++++++++++++ .../verify.groovy | 45 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/it/projects/flatten-dependency-all-both-test-and-transitive/pom.xml create mode 100644 src/it/projects/flatten-dependency-all-both-test-and-transitive/verify.groovy diff --git a/src/it/projects/flatten-dependency-all-both-test-and-transitive/pom.xml b/src/it/projects/flatten-dependency-all-both-test-and-transitive/pom.xml new file mode 100644 index 00000000..8ca9f3a6 --- /dev/null +++ b/src/it/projects/flatten-dependency-all-both-test-and-transitive/pom.xml @@ -0,0 +1,35 @@ + + 4.0.0 + org.codehaus.mojo.flatten.its + flatten-dependency-all-both-test-and-transitive + 0.0.1-SNAPSHOT + + + verify + + + org.codehaus.mojo + flatten-maven-plugin + + oss + all + + + + + + + + org.codehaus.mojo.flatten.its + core + + 3.2.1 + + + org.codehaus.mojo.flatten.its + dep + 3.2.1 + test + + + \ No newline at end of file diff --git a/src/it/projects/flatten-dependency-all-both-test-and-transitive/verify.groovy b/src/it/projects/flatten-dependency-all-both-test-and-transitive/verify.groovy new file mode 100644 index 00000000..7a4d735c --- /dev/null +++ b/src/it/projects/flatten-dependency-all-both-test-and-transitive/verify.groovy @@ -0,0 +1,45 @@ +/* + * 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 2 == originalProject.dependencies.dependency.size() +assert "dep" == originalProject.dependencies.dependency[1].artifactId.text() +assert "3.2.1" == originalProject.dependencies.dependency[1].version.text() +assert "test" == originalProject.dependencies.dependency[1].scope.text() + +File flattenedPom = new File( basedir, '.flattened-pom.xml' ) +assert flattenedPom.exists() + +def flattenedProject = new XmlSlurper().parse( flattenedPom ) + +// core and dep should be there. It's because while the test-scope dep (the +// direct dependency), core declares dep as compile-scope (default) dependency. +assert 2 == flattenedProject.dependencies.dependency.size() + +assert "core" == originalProject.dependencies.dependency[0].artifactId.text() +assert "3.2.1" == originalProject.dependencies.dependency[0].version.text() +assert "compile" == originalProject.dependencies.dependency[0].scope.text() + +// The flattened pom.xml should declare the dep under core as compile scope. +// It's ok to ignore the one in the test-scope dependency. +assert "dep" == originalProject.dependencies.dependency[1].artifactId.text() +assert "3.2.1" == originalProject.dependencies.dependency[1].version.text() +assert "compile" == originalProject.dependencies.dependency[1].scope.text()