You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2020/06/02 06:30:09 UTC

[maven] 03/04: fix replacing artifact

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

olamy pushed a commit to branch no_duplicate_artifacts_in_attached_artifacts
in repository https://gitbox.apache.org/repos/asf/maven.git

commit b058a033e95b187dcaa36d2fc99951b41d0bfdf0
Author: olivier lamy <ol...@apache.org>
AuthorDate: Tue Jun 2 13:40:11 2020 +1000

    fix replacing artifact
    
    Signed-off-by: olivier lamy <ol...@apache.org>
---
 .../src/main/java/org/apache/maven/project/MavenProject.java     | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index a03b529..31a7ff3 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -927,7 +927,7 @@ public class MavenProject
      *
      * @param artifact the artifact to add or replace.
      * @deprecated Please use {@link MavenProjectHelper}
-     * @throws DuplicateArtifactAttachmentException not used anymore but leave it for backward compatibility
+     * @throws DuplicateArtifactAttachmentException will never happen but leave it for backward compatibility
      */
     public void addAttachedArtifact( Artifact artifact )
         throws DuplicateArtifactAttachmentException
@@ -936,10 +936,13 @@ public class MavenProject
         int index = attachedArtifacts.indexOf( artifact );
         if ( index > 0 )
         {
-            LOGGER.warn( "artifact {} already attached, remove previous instance and add again" );
+            LOGGER.warn( "artifact {} already attached, replace previous instance", artifact );
             attachedArtifacts.set( index, artifact );
         }
-        attachedArtifacts.add( artifact );
+        else
+        {
+            attachedArtifacts.add( artifact );
+        }
     }
 
     public List<Artifact> getAttachedArtifacts()