Repository: maven
Updated Branches:
  refs/heads/master 020e35816 -> 5f048234f


Revert "[MNG-5868] Adding serval times the same artifact via MavenProjectHelper 
(attachArtifact) does not produce a failure"

This reverts commit 020e35816f184c10c3f87f103336fed4516f7af6.

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/536350f5
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/536350f5
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/536350f5

Branch: refs/heads/master
Commit: 536350f5c5960e6c639305acde79e3fc81a91dd4
Parents: 020e358
Author: Christian Schulte <schu...@apache.org>
Authored: Fri Dec 18 00:12:22 2015 +0100
Committer: Christian Schulte <schu...@apache.org>
Committed: Fri Dec 18 00:12:22 2015 +0100

----------------------------------------------------------------------
 .../project/DefaultMavenProjectHelper.java      |  7 +++
 .../org/apache/maven/project/MavenProject.java  | 66 +++-----------------
 .../maven/project/MavenProjectHelper.java       | 12 +---
 3 files changed, 20 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/536350f5/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
 
b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
index 223e920..2cce9f6 100644
--- 
a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
+++ 
b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
@@ -91,6 +91,13 @@ public class DefaultMavenProjectHelper
         attachArtifact( project, artifact );
     }
 
+    /**
+     * Add an attached artifact or replace the file for an existing artifact.
+     *
+     * @see 
MavenProject#addAttachedArtifact(org.apache.maven.artifact.Artifact)
+     * @param project project reference.
+     * @param artifact artifact to add or replace.
+     */
     public void attachArtifact( MavenProject project, Artifact artifact )
     {
         project.addAttachedArtifact( artifact );

http://git-wip-us.apache.org/repos/asf/maven/blob/536350f5/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
----------------------------------------------------------------------
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 5710250..9c936e1 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
@@ -260,7 +260,7 @@ public class MavenProject
 
     /**
      * Sets project {@code file} without changing project {@code basedir}.
-     *
+     * 
      * @since 3.2.4
      */
     public void setPomFile( File file )
@@ -909,65 +909,19 @@ public class MavenProject
     }
 
     /**
-     * Adds an artifact to the list of attached artifacts.
-     *
-     * @param artifact The artifact to add.
-     *
-     * @throws DuplicateArtifactAttachmentException if the same artifact 
already is attached to this project.
+     * Add or replace an artifact. This method is now deprecated. Use the 
@{MavenProjectHelper} to attach artifacts to a
+     * project. In spite of the 'throws' declaration on this API, this method 
has never thrown an exception since Maven
+     * 3.0.x. Historically, it logged and ignored a second addition of the 
same g/a/v/c/t. Now it replaces the file for
+     * the artifact, so that plugins (e.g. shade) can change the pathname of 
the file for a particular set of
+     * coordinates.
      *
-     * @see #isArtifactAttached(org.apache.maven.artifact.Artifact)
-     * @see #getAttachedArtifacts()
-     *
-     * @deprecated Please use {@link MavenProjectHelper} to attach artifacts 
to a project.
+     * @param artifact the artifact to add or replace.
+     * @throws DuplicateArtifactAttachmentException
      */
-    @Deprecated
     public void addAttachedArtifact( Artifact artifact )
         throws DuplicateArtifactAttachmentException
     {
-        if ( artifact == null )
-        {
-            throw new NullPointerException( "artifact" );
-        }
-
-// MNG-5868: The following is the former Javadoc comment of this method. I 
added method 'isArtifactAttached' to provide
-//           a way for people to test for a possible 
'DuplicateArtifactAttachmentException' and updated this method to
-//           throw that exception. Regarding the former comment: "Now it 
replaces the file for the artifact, so that
-//           plugins (e.g. shade) can change the pathname of the file for a 
particular set of coordinates." is not what
-//           this method did before the update. It just added duplicate 
artifacts to the list of attached artifacts.
-
-// Former Javadoc comment:
-// -----------------------
-// Add or replace an artifact. This method is now deprecated. Use the 
@{MavenProjectHelper} to attach artifacts to a
-// project. In spite of the 'throws' declaration on this API, this method has 
never thrown an exception since Maven
-// 3.0.x. Historically, it logged and ignored a second addition of the same 
g/a/v/c/t. Now it replaces the file for
-// the artifact, so that plugins (e.g. shade) can change the pathname of the 
file for a particular set of
-// coordinates.
-
-        if ( this.isArtifactAttached( artifact ) )
-        {
-            throw new DuplicateArtifactAttachmentException( this, artifact );
-        }
-
-        this.attachedArtifacts.add( artifact );
-    }
-
-    /**
-     * Tests a given artifact to be contained in the list of attached 
artifacts.
-     *
-     * @param artifact The artifact to test.
-     *
-     * @return {@code true}, if the list of attached artifacts contains {@code 
artifact}; {@code false}, else.
-     *
-     * @since 3.4
-     */
-    public boolean isArtifactAttached( final Artifact artifact )
-    {
-        if ( artifact == null )
-        {
-            throw new NullPointerException( "artifact" );
-        }
-
-        return this.getAttachedArtifacts().contains( artifact );
+        getAttachedArtifacts().add( artifact );
     }
 
     public List<Artifact> getAttachedArtifacts()
@@ -976,7 +930,7 @@ public class MavenProject
         {
             attachedArtifacts = new ArrayList<>();
         }
-        return Collections.unmodifiableList( attachedArtifacts );
+        return attachedArtifacts;
     }
 
     public Xpp3Dom getGoalConfiguration( String pluginGroupId, String 
pluginArtifactId, String executionId,

http://git-wip-us.apache.org/repos/asf/maven/blob/536350f5/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java 
b/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java
index 73b3f8f..0b54c00 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProjectHelper.java
@@ -34,20 +34,16 @@ public interface MavenProjectHelper
      * @param project project reference.
      * @param artifactFile artifact file.
      * @param artifactClassifier artifact classifier.
-     * @throws DuplicateArtifactAttachmentException if the same artifact 
already is attached to this project.
      */
-    void attachArtifact( MavenProject project, File artifactFile, String 
artifactClassifier )
-        throws DuplicateArtifactAttachmentException;
+    void attachArtifact( MavenProject project, File artifactFile, String 
artifactClassifier );
 
     /**
      * * See {@link #attachArtifact(MavenProject, String, String, 
java.io.File)}, but with classifier set to null.
      * @param project project reference.
      * @param artifactType artifact type.
      * @param artifactFile arrifact file.
-     * @throws DuplicateArtifactAttachmentException if the same artifact 
already is attached to this project.
      */
-    void attachArtifact( MavenProject project, String artifactType, File 
artifactFile )
-        throws DuplicateArtifactAttachmentException;
+    void attachArtifact( MavenProject project, String artifactType, File 
artifactFile );
 
     /**
      * Add or replace an artifact to the current project.
@@ -55,10 +51,8 @@ public interface MavenProjectHelper
      * @param artifactType the type (e.g. jar) or null.
      * @param artifactClassifier the classifier or null.
      * @param artifactFile the file for the artifact.
-     * @throws DuplicateArtifactAttachmentException if the same artifact 
already is attached to this project.
      */
-    void attachArtifact( MavenProject project, String artifactType, String 
artifactClassifier, File artifactFile )
-        throws DuplicateArtifactAttachmentException;
+    void attachArtifact( MavenProject project, String artifactType, String 
artifactClassifier, File artifactFile );
 
     /**
      * Add a resource directory to the project.

Reply via email to