From ee9a453c6d6906cc77dc24ed7587bd3db4cd70ef Mon Sep 17 00:00:00 2001 From: Kortanul Date: Tue, 29 May 2018 09:15:29 -0400 Subject: [PATCH] Fix handling of bundle and test-jar packaging Changes the skip filter for reactor dependencies to only compare based on Maven coordinates rather than the full ID of each artifact. Previously, the group ID, artifact ID, version, packaging, type, and classifier had to match, but unfortunately Maven doesn't have packaging information when resolving upstream reactor dependencies. This caused problems for `bundle` and `test-jar` packaging (which both end up being "jar" packaging under the hood). The new approach just uses coordinates of group ID, artifact ID, and version; this should work fine since it's unlikely that one would want a dependency outside the reactor that exactly matches the coordinates of a project inside the reactor during the same build. Signed-off-by: Kortanul --- pom.xml | 2 +- .../invoker.properties | 0 src/it/reactorProcessBundle/pom.xml | 30 +++++++ .../project-bundle/pom.xml | 47 ++++++++++ .../java/org/simplify4u/plugins/Main.java | 7 ++ .../project-verifier/pom.xml | 59 +++++++++++++ src/it/reactorProcessJar/invoker.properties | 16 ++++ src/it/reactorProcessJar/pom.xml | 30 +++++++ .../project-jar}/pom.xml | 12 +-- .../java/org/simplify4u/plugins/Main.java | 7 ++ .../project-verifier}/pom.xml | 20 +++-- src/it/reactorProcessPom/invoker.properties | 16 ++++ src/it/reactorProcessPom/pom.xml | 30 +++++++ .../project-pom}/pom.xml | 2 +- .../java/org/simplify4u/plugins/Main.java | 7 ++ .../project-verifier/pom.xml | 60 +++++++++++++ .../reactorProcessTestJar/invoker.properties | 16 ++++ src/it/reactorProcessTestJar/pom.xml | 30 +++++++ .../project-test-jar/pom.xml | 54 ++++++++++++ .../java/org/simplify4u/plugins/Main.java | 7 ++ .../java/org/simplify4u/plugins/MainTest.java | 7 ++ .../project-verifier/pom.xml | 60 +++++++++++++ src/it/reactorSkip/pom.xml | 28 ++---- src/it/reactorSkip/project-bundle/pom.xml | 47 ++++++++++ .../java/org/simplify4u/plugins/Main.java | 7 ++ .../project-jar}/pom.xml | 12 +-- .../java/org/simplify4u/plugins/Main.java | 7 ++ .../{projectA => project-pom}/pom.xml | 2 +- src/it/reactorSkip/project-test-jar/pom.xml | 54 ++++++++++++ .../java/org/simplify4u/plugins/Main.java | 7 ++ .../java/org/simplify4u/plugins/MainTest.java | 7 ++ src/it/reactorSkip/project-verifier/pom.xml | 85 +++++++++++++++++++ .../skipfilters/ReactorDependencySkipper.java | 62 ++++++++++++-- 33 files changed, 778 insertions(+), 59 deletions(-) rename src/it/{reactorProcess => reactorProcessBundle}/invoker.properties (100%) create mode 100644 src/it/reactorProcessBundle/pom.xml create mode 100644 src/it/reactorProcessBundle/project-bundle/pom.xml create mode 100644 src/it/reactorProcessBundle/project-bundle/src/main/java/org/simplify4u/plugins/Main.java create mode 100644 src/it/reactorProcessBundle/project-verifier/pom.xml create mode 100644 src/it/reactorProcessJar/invoker.properties create mode 100644 src/it/reactorProcessJar/pom.xml rename src/it/{reactorSkip/projectB => reactorProcessJar/project-jar}/pom.xml (78%) create mode 100644 src/it/reactorProcessJar/project-jar/src/main/java/org/simplify4u/plugins/Main.java rename src/it/{reactorProcess => reactorProcessJar/project-verifier}/pom.xml (81%) create mode 100644 src/it/reactorProcessPom/invoker.properties create mode 100644 src/it/reactorProcessPom/pom.xml rename src/it/{reactorProcess/projectA => reactorProcessPom/project-pom}/pom.xml (96%) create mode 100644 src/it/reactorProcessPom/project-pom/src/main/java/org/simplify4u/plugins/Main.java create mode 100644 src/it/reactorProcessPom/project-verifier/pom.xml create mode 100644 src/it/reactorProcessTestJar/invoker.properties create mode 100644 src/it/reactorProcessTestJar/pom.xml create mode 100644 src/it/reactorProcessTestJar/project-test-jar/pom.xml create mode 100644 src/it/reactorProcessTestJar/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java create mode 100644 src/it/reactorProcessTestJar/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java create mode 100644 src/it/reactorProcessTestJar/project-verifier/pom.xml create mode 100644 src/it/reactorSkip/project-bundle/pom.xml create mode 100644 src/it/reactorSkip/project-bundle/src/main/java/org/simplify4u/plugins/Main.java rename src/it/{reactorProcess/projectB => reactorSkip/project-jar}/pom.xml (78%) create mode 100644 src/it/reactorSkip/project-jar/src/main/java/org/simplify4u/plugins/Main.java rename src/it/reactorSkip/{projectA => project-pom}/pom.xml (96%) create mode 100644 src/it/reactorSkip/project-test-jar/pom.xml create mode 100644 src/it/reactorSkip/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java create mode 100644 src/it/reactorSkip/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java create mode 100644 src/it/reactorSkip/project-verifier/pom.xml diff --git a/pom.xml b/pom.xml index 0e76c48d..0a361aa4 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.simplify4u.plugins pgpverify-maven-plugin - 1.3.0-wren1 + 1.3.0-wren2 maven-plugin Verify PGP signatures plugin diff --git a/src/it/reactorProcess/invoker.properties b/src/it/reactorProcessBundle/invoker.properties similarity index 100% rename from src/it/reactorProcess/invoker.properties rename to src/it/reactorProcessBundle/invoker.properties diff --git a/src/it/reactorProcessBundle/pom.xml b/src/it/reactorProcessBundle/pom.xml new file mode 100644 index 00000000..daa2d5f1 --- /dev/null +++ b/src/it/reactorProcessBundle/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + test + test-parent + 0.0.1 + pom + + + project-bundle + project-verifier + + diff --git a/src/it/reactorProcessBundle/project-bundle/pom.xml b/src/it/reactorProcessBundle/project-bundle/pom.xml new file mode 100644 index 00000000..b061cce9 --- /dev/null +++ b/src/it/reactorProcessBundle/project-bundle/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-bundle + 0.0.1 + bundle + + + + + org.apache.felix + maven-bundle-plugin + 3.5.0 + true + + + com.demo.hello.* + + + + + + diff --git a/src/it/reactorProcessBundle/project-bundle/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorProcessBundle/project-bundle/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorProcessBundle/project-bundle/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorProcessBundle/project-verifier/pom.xml b/src/it/reactorProcessBundle/project-verifier/pom.xml new file mode 100644 index 00000000..4f464338 --- /dev/null +++ b/src/it/reactorProcessBundle/project-verifier/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-verifier + 0.0.1 + + + + + org.simplify4u.plugins + pgpverify-maven-plugin + @project.version@ + + true + true + + + + + check + + + + + + + + + + test + project-bundle + 0.0.1 + + + diff --git a/src/it/reactorProcessJar/invoker.properties b/src/it/reactorProcessJar/invoker.properties new file mode 100644 index 00000000..0807a9df --- /dev/null +++ b/src/it/reactorProcessJar/invoker.properties @@ -0,0 +1,16 @@ +# +# Copyright 2018 Wren Security +# +# Licensed 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. +# +invoker.buildResult = failure diff --git a/src/it/reactorProcessJar/pom.xml b/src/it/reactorProcessJar/pom.xml new file mode 100644 index 00000000..5aceb78e --- /dev/null +++ b/src/it/reactorProcessJar/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + test + test-parent + 0.0.1 + pom + + + project-jar + project-verifier + + diff --git a/src/it/reactorSkip/projectB/pom.xml b/src/it/reactorProcessJar/project-jar/pom.xml similarity index 78% rename from src/it/reactorSkip/projectB/pom.xml rename to src/it/reactorProcessJar/project-jar/pom.xml index 77e5f7ca..2bbfcb22 100644 --- a/src/it/reactorSkip/projectB/pom.xml +++ b/src/it/reactorProcessJar/project-jar/pom.xml @@ -25,16 +25,6 @@ test - projectB + project-jar 0.0.1 - pom - - - - test - projectA - 0.0.1 - pom - - diff --git a/src/it/reactorProcessJar/project-jar/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorProcessJar/project-jar/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorProcessJar/project-jar/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorProcess/pom.xml b/src/it/reactorProcessJar/project-verifier/pom.xml similarity index 81% rename from src/it/reactorProcess/pom.xml rename to src/it/reactorProcessJar/project-verifier/pom.xml index 24f05a65..7e54f9f0 100644 --- a/src/it/reactorProcess/pom.xml +++ b/src/it/reactorProcessJar/project-verifier/pom.xml @@ -18,10 +18,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + test + test-parent + 0.0.1 + + test - test-parent + project-verifier 0.0.1 - pom @@ -44,8 +49,11 @@ - - projectA - projectB - + + + test + project-jar + 0.0.1 + + diff --git a/src/it/reactorProcessPom/invoker.properties b/src/it/reactorProcessPom/invoker.properties new file mode 100644 index 00000000..0807a9df --- /dev/null +++ b/src/it/reactorProcessPom/invoker.properties @@ -0,0 +1,16 @@ +# +# Copyright 2018 Wren Security +# +# Licensed 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. +# +invoker.buildResult = failure diff --git a/src/it/reactorProcessPom/pom.xml b/src/it/reactorProcessPom/pom.xml new file mode 100644 index 00000000..4fdd8fdf --- /dev/null +++ b/src/it/reactorProcessPom/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + test + test-parent + 0.0.1 + pom + + + project-pom + project-verifier + + diff --git a/src/it/reactorProcess/projectA/pom.xml b/src/it/reactorProcessPom/project-pom/pom.xml similarity index 96% rename from src/it/reactorProcess/projectA/pom.xml rename to src/it/reactorProcessPom/project-pom/pom.xml index e86d97c6..f03a98c8 100644 --- a/src/it/reactorProcess/projectA/pom.xml +++ b/src/it/reactorProcessPom/project-pom/pom.xml @@ -25,7 +25,7 @@ test - projectA + project-pom 0.0.1 pom diff --git a/src/it/reactorProcessPom/project-pom/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorProcessPom/project-pom/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorProcessPom/project-pom/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorProcessPom/project-verifier/pom.xml b/src/it/reactorProcessPom/project-verifier/pom.xml new file mode 100644 index 00000000..049e2e8f --- /dev/null +++ b/src/it/reactorProcessPom/project-verifier/pom.xml @@ -0,0 +1,60 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-verifier + 0.0.1 + + + + + org.simplify4u.plugins + pgpverify-maven-plugin + @project.version@ + + true + true + + + + + check + + + + + + + + + + test + project-pom + 0.0.1 + pom + + + diff --git a/src/it/reactorProcessTestJar/invoker.properties b/src/it/reactorProcessTestJar/invoker.properties new file mode 100644 index 00000000..0807a9df --- /dev/null +++ b/src/it/reactorProcessTestJar/invoker.properties @@ -0,0 +1,16 @@ +# +# Copyright 2018 Wren Security +# +# Licensed 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. +# +invoker.buildResult = failure diff --git a/src/it/reactorProcessTestJar/pom.xml b/src/it/reactorProcessTestJar/pom.xml new file mode 100644 index 00000000..df0255f9 --- /dev/null +++ b/src/it/reactorProcessTestJar/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + test + test-parent + 0.0.1 + pom + + + project-test-jar + project-verifier + + diff --git a/src/it/reactorProcessTestJar/project-test-jar/pom.xml b/src/it/reactorProcessTestJar/project-test-jar/pom.xml new file mode 100644 index 00000000..c5bf06f8 --- /dev/null +++ b/src/it/reactorProcessTestJar/project-test-jar/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-test-jar + 0.0.1 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + + ** + + + + + + + test-jar + + + + + + + diff --git a/src/it/reactorProcessTestJar/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorProcessTestJar/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorProcessTestJar/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorProcessTestJar/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java b/src/it/reactorProcessTestJar/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java new file mode 100644 index 00000000..161f3b00 --- /dev/null +++ b/src/it/reactorProcessTestJar/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class MainTest { + public static void main(String[] args) { + System.out.println("This is a fake test class."); + } +} diff --git a/src/it/reactorProcessTestJar/project-verifier/pom.xml b/src/it/reactorProcessTestJar/project-verifier/pom.xml new file mode 100644 index 00000000..25ea643e --- /dev/null +++ b/src/it/reactorProcessTestJar/project-verifier/pom.xml @@ -0,0 +1,60 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-verifier + 0.0.1 + + + + + org.simplify4u.plugins + pgpverify-maven-plugin + @project.version@ + + true + true + + + + + check + + + + + + + + + + test + project-test-jar + 0.0.1 + test-jar + + + diff --git a/src/it/reactorSkip/pom.xml b/src/it/reactorSkip/pom.xml index e9be8a42..2f403a9f 100644 --- a/src/it/reactorSkip/pom.xml +++ b/src/it/reactorSkip/pom.xml @@ -23,29 +23,11 @@ 0.0.1 pom - - - - org.simplify4u.plugins - pgpverify-maven-plugin - @project.version@ - - true - false - - - - - check - - - - - - - - projectA - projectB + project-pom + project-jar + project-test-jar + project-bundle + project-verifier diff --git a/src/it/reactorSkip/project-bundle/pom.xml b/src/it/reactorSkip/project-bundle/pom.xml new file mode 100644 index 00000000..b061cce9 --- /dev/null +++ b/src/it/reactorSkip/project-bundle/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-bundle + 0.0.1 + bundle + + + + + org.apache.felix + maven-bundle-plugin + 3.5.0 + true + + + com.demo.hello.* + + + + + + diff --git a/src/it/reactorSkip/project-bundle/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorSkip/project-bundle/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorSkip/project-bundle/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorProcess/projectB/pom.xml b/src/it/reactorSkip/project-jar/pom.xml similarity index 78% rename from src/it/reactorProcess/projectB/pom.xml rename to src/it/reactorSkip/project-jar/pom.xml index 77e5f7ca..2bbfcb22 100644 --- a/src/it/reactorProcess/projectB/pom.xml +++ b/src/it/reactorSkip/project-jar/pom.xml @@ -25,16 +25,6 @@ test - projectB + project-jar 0.0.1 - pom - - - - test - projectA - 0.0.1 - pom - - diff --git a/src/it/reactorSkip/project-jar/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorSkip/project-jar/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorSkip/project-jar/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorSkip/projectA/pom.xml b/src/it/reactorSkip/project-pom/pom.xml similarity index 96% rename from src/it/reactorSkip/projectA/pom.xml rename to src/it/reactorSkip/project-pom/pom.xml index e86d97c6..f03a98c8 100644 --- a/src/it/reactorSkip/projectA/pom.xml +++ b/src/it/reactorSkip/project-pom/pom.xml @@ -25,7 +25,7 @@ test - projectA + project-pom 0.0.1 pom diff --git a/src/it/reactorSkip/project-test-jar/pom.xml b/src/it/reactorSkip/project-test-jar/pom.xml new file mode 100644 index 00000000..c5bf06f8 --- /dev/null +++ b/src/it/reactorSkip/project-test-jar/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-test-jar + 0.0.1 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + + ** + + + + + + + test-jar + + + + + + + diff --git a/src/it/reactorSkip/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java b/src/it/reactorSkip/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java new file mode 100644 index 00000000..a6ec4be8 --- /dev/null +++ b/src/it/reactorSkip/project-test-jar/src/main/java/org/simplify4u/plugins/Main.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class Main { + public static void main(String[] args) { + System.out.println("This is a fake class."); + } +} diff --git a/src/it/reactorSkip/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java b/src/it/reactorSkip/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java new file mode 100644 index 00000000..161f3b00 --- /dev/null +++ b/src/it/reactorSkip/project-test-jar/src/test/java/org/simplify4u/plugins/MainTest.java @@ -0,0 +1,7 @@ +package org.simplify4u.plugins; + +class MainTest { + public static void main(String[] args) { + System.out.println("This is a fake test class."); + } +} diff --git a/src/it/reactorSkip/project-verifier/pom.xml b/src/it/reactorSkip/project-verifier/pom.xml new file mode 100644 index 00000000..0ace7e9c --- /dev/null +++ b/src/it/reactorSkip/project-verifier/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + + test + test-parent + 0.0.1 + + + test + project-verifier + 0.0.1 + + + + + org.simplify4u.plugins + pgpverify-maven-plugin + @project.version@ + + true + false + + + + + check + + + + + + + + + + test + project-pom + 0.0.1 + pom + + + + test + project-jar + 0.0.1 + + + + test + project-test-jar + 0.0.1 + + + + test + project-test-jar + 0.0.1 + test-jar + + + + test + project-bundle + 0.0.1 + + + diff --git a/src/main/java/org/simplify4u/plugins/skipfilters/ReactorDependencySkipper.java b/src/main/java/org/simplify4u/plugins/skipfilters/ReactorDependencySkipper.java index cfb2ddd6..fb7659ad 100644 --- a/src/main/java/org/simplify4u/plugins/skipfilters/ReactorDependencySkipper.java +++ b/src/main/java/org/simplify4u/plugins/skipfilters/ReactorDependencySkipper.java @@ -16,11 +16,12 @@ package org.simplify4u.plugins.skipfilters; -import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; +import java.util.List; + /** * A filter that always skips verification of upstream dependencies that are being built as part of * the current build reactor. @@ -28,7 +29,16 @@ public class ReactorDependencySkipper implements SkipFilter { private final List upstreamProjects; - public ReactorDependencySkipper(final MavenProject currentProject, final MavenSession session) { + /** + * Constructor for {@code ReactorDependencySkipper}. + * + * @param currentProject + * The project currently being built. + * @param session + * The current maven session. + */ + public ReactorDependencySkipper(final MavenProject currentProject, + final MavenSession session) { this.upstreamProjects = session.getProjectDependencyGraph().getUpstreamProjects(currentProject, true); } @@ -46,16 +56,58 @@ public boolean shouldSkipArtifact(Artifact artifact) { * The to check against upstream reactor dependencies. * * @return {@code true} if the specified artifact is in the current Maven reactor build and is - * a direct or transitive dependency of the current project; {@code false} if it is not - * either. + * a direct or transitive dependency of the current project; {@code false} if it is + * not either. */ private boolean isUpstreamReactorDependency(final Artifact artifact) { for (final MavenProject upstreamProject : this.upstreamProjects) { - if (upstreamProject.getId().equals(artifact.getId())) { + if (this.artifactMatchesProject(artifact, upstreamProject)) { return true; } } return false; } + + /** + * Check whether the specified artifact belongs to the specified Maven project. + * + * @param artifact + * The artifact being checked. + * @param project + * The project to which the artifact will be compared. + * + * @return + * {@code true} if the artifact was produced by the specified project; or + * {@code false} if it is not. + */ + private boolean artifactMatchesProject(final Artifact artifact, + final MavenProject project) { + final Artifact projectArtifact = project.getArtifact(); + + return projectArtifact != null + && this.artifactsMatch(projectArtifact, artifact); + } + + /** + * Check whether the specified artifacts are equivalent, or at least + * identify the same group, artifact ID, and version. + * + * @param artifact1 + * The first artifact. + * @param artifact2 + * The second artifact. + * + * @return + * If either the two artifacts are equal or correspond to the same Maven + * coordinates. + */ + @SuppressWarnings("PMD.UselessParentheses") + private boolean artifactsMatch(final Artifact artifact1, + final Artifact artifact2) { + return artifact1.equals(artifact2) + || (artifact1.getGroupId().equals(artifact2.getGroupId()) + && artifact1.getArtifactId().equals(artifact2.getArtifactId()) + && artifact1.getVersion().equals(artifact2.getVersion())); + } }