You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2021/10/18 18:34:01 UTC

[maven] 03/05: Continued.

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-7276
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 45ebd3715cf109a59c6be6b3c83e8a920ab49d37
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Fri Oct 8 14:45:26 2021 +0200

    Continued.
---
 .../main/java/org/apache/maven/ReactorReader.java  | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 1521b1b..e50eabb 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -34,6 +34,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.function.Function;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -325,22 +326,26 @@ class ReactorReader
         }
 
         return RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ).stream()
-                .filter( artifact -> attachedArtifactComparison( requestedArtifact, artifact ) )
+                .filter( isRequestedArtifact( requestedArtifact ) )
                 .findFirst()
                 .orElse( null );
     }
 
-    private boolean attachedArtifactComparison( Artifact requested, Artifact attached )
+    /**
+     * We are taking as much as we can from the DefaultArtifact.equals(). The requested artifact has no file, so we want
+     * to remove that from the comparison.
+     *
+     * @param requestArtifact checked against the given artifact.
+     * @return true if equals, false otherwise.
+     */
+    private Predicate<Artifact> isRequestedArtifact( Artifact requestArtifact )
     {
-        //
-        // We are taking as much as we can from the DefaultArtifact.equals(). The requested artifact has no file so
-        // we want to remove that from the comparison.
-        //
-        return requested.getArtifactId().equals( attached.getArtifactId() )
-            && requested.getGroupId().equals( attached.getGroupId() )
-            && requested.getVersion().equals( attached.getVersion() )
-            && requested.getExtension().equals( attached.getExtension() )
-            && requested.getClassifier().equals( attached.getClassifier() );
+        return s -> s.getArtifactId().equals( requestArtifact.getArtifactId() )
+                && s.getGroupId().equals( requestArtifact.getGroupId() )
+                && s.getVersion().equals( requestArtifact.getVersion() )
+                && s.getExtension().equals( requestArtifact.getExtension() )
+                && s.getClassifier().equals( requestArtifact.getClassifier() );
+
     }
 
     /**