[50/50] [abbrv] maven git commit: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
[MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure o Updated to restore the behaviour consensus had been reached in MNG-5387. o Kept 'MavenProject.getAttachedArtifacts' to return an unmodifiable list. o Updated to log an information message when an existing artifact got replaced. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/3b12cd67 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/3b12cd67 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/3b12cd67 Branch: refs/heads/MNG-5868 Commit: 3b12cd67c7be869cc15c51e2977f7b8f9235eedf Parents: cd34b08 Author: Christian SchulteAuthored: Thu Dec 17 22:43:47 2015 +0100 Committer: Karl Heinz Marbaise Committed: Sat Feb 17 21:36:53 2018 +0100 -- .../project/DefaultMavenProjectHelper.java | 13 +++ .../org/apache/maven/project/MavenProject.java | 39 +++- 2 files changed, 35 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven/blob/3b12cd67/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 1972242..d65aa73 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 @@ -94,16 +94,15 @@ 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 ) { +final int size = project.getAttachedArtifacts().size(); project.addAttachedArtifact( artifact ); + +if ( project.getAttachedArtifacts().size() == size && this.getLogger().isInfoEnabled() ) +{ +this.getLogger().info( String.format( "Replaced artifact %s.", artifact ) ); +} } public void addResource( MavenProject project, String resourceDirectory, List includes, http://git-wip-us.apache.org/repos/asf/maven/blob/3b12cd67/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 80a5193..ba153a7 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 @@ -909,19 +909,38 @@ public class MavenProject } /** - * 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. + * Adds or replaces an artifact. * - * @param artifact the artifact to add or replace. - * @throws DuplicateArtifactAttachmentException + * @param artifact The artifact to add or replace. + * + * @deprecated Please use {@link MavenProjectHelper} + * @see https://issues.apache.org/jira/browse/MNG-5868 + * @see https://issues.apache.org/jira/browse/MNG-5387 + * @see https://issues.apache.org/jira/browse/MNG-4013 + * @see https://issues.apache.org/jira/browse/MNG-3119 */ +@Deprecated public void addAttachedArtifact( Artifact artifact ) -throws DuplicateArtifactAttachmentException { -getAttachedArtifacts().add( artifact ); +getAttachedArtifacts(); +assert this.attachedArtifacts != null : "Unexpected missing attached artifacts."; + +boolean replaced = false; +for ( int i = 0, s0 = this.attachedArtifacts.size(); i < s0; i++ ) +{ +final Artifact a = this.attachedArtifacts.get( i ); + +if ( a.equals( artifact ) ) +{ +this.attachedArtifacts.set( i, artifact ); +replaced =
[4/4] maven git commit: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
[MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure o Updated to restore the behaviour consensus had been reached in MNG-5387. o Kept 'MavenProject.getAttachedArtifacts' to return an unmodifiable list. o Updated to log an information message when an existing artifact got replaced. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/7d42255e Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/7d42255e Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/7d42255e Branch: refs/heads/MNG-5868 Commit: 7d42255e6c24e185b37e31416260001eac157bc5 Parents: a3cdfbb Author: Christian SchulteAuthored: Thu Dec 17 22:43:47 2015 +0100 Committer: Christian Schulte Committed: Tue Jan 31 22:52:38 2017 +0100 -- .../project/DefaultMavenProjectHelper.java | 13 +++ .../org/apache/maven/project/MavenProject.java | 39 +++- 2 files changed, 35 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven/blob/7d42255e/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 2cce9f6..54c15bb 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,16 +91,15 @@ 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 ) { +final int size = project.getAttachedArtifacts().size(); project.addAttachedArtifact( artifact ); + +if ( project.getAttachedArtifacts().size() == size && this.getLogger().isInfoEnabled() ) +{ +this.getLogger().info( String.format( "Replaced artifact %s.", artifact ) ); +} } public void addResource( MavenProject project, String resourceDirectory, List includes, http://git-wip-us.apache.org/repos/asf/maven/blob/7d42255e/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 952622f..53ee74d 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 @@ -909,19 +909,38 @@ public class MavenProject } /** - * 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. + * Adds or replaces an artifact. * - * @param artifact the artifact to add or replace. - * @throws DuplicateArtifactAttachmentException + * @param artifact The artifact to add or replace. + * + * @deprecated Please use {@link MavenProjectHelper} + * @see https://issues.apache.org/jira/browse/MNG-5868 + * @see https://issues.apache.org/jira/browse/MNG-5387 + * @see https://issues.apache.org/jira/browse/MNG-4013 + * @see https://issues.apache.org/jira/browse/MNG-3119 */ +@Deprecated public void addAttachedArtifact( Artifact artifact ) -throws DuplicateArtifactAttachmentException { -getAttachedArtifacts().add( artifact ); +getAttachedArtifacts(); +assert this.attachedArtifacts != null : "Unexpected missing attached artifacts."; + +boolean replaced = false; +for ( int i = 0, s0 = this.attachedArtifacts.size(); i < s0; i++ ) +{ +final Artifact a = this.attachedArtifacts.get( i ); + +if ( a.equals( artifact ) ) +{ +this.attachedArtifacts.set( i, artifact ); +replaced = true; +
maven git commit: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
Repository: maven Updated Branches: refs/heads/MNG-5868 [created] 974a06401 [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure o Updated to restore the behaviour consensus had been reached in MNG-5387. o Kept 'MavenProject.getAttachedArtifacts' to return an unmodifiable list. o Updated to log an information message when an existing artifact got replaced. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/974a0640 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/974a0640 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/974a0640 Branch: refs/heads/MNG-5868 Commit: 974a064015677808a120e974fdb60969652b2f64 Parents: 2678388 Author: Christian SchulteAuthored: Thu Dec 17 22:43:47 2015 +0100 Committer: Christian Schulte Committed: Tue Jan 31 19:54:51 2017 +0100 -- .../project/DefaultMavenProjectHelper.java | 13 +++ .../org/apache/maven/project/MavenProject.java | 39 +++- 2 files changed, 35 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven/blob/974a0640/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 2cce9f6..54c15bb 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,16 +91,15 @@ 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 ) { +final int size = project.getAttachedArtifacts().size(); project.addAttachedArtifact( artifact ); + +if ( project.getAttachedArtifacts().size() == size && this.getLogger().isInfoEnabled() ) +{ +this.getLogger().info( String.format( "Replaced artifact %s.", artifact ) ); +} } public void addResource( MavenProject project, String resourceDirectory, List includes, http://git-wip-us.apache.org/repos/asf/maven/blob/974a0640/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 952622f..53ee74d 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 @@ -909,19 +909,38 @@ public class MavenProject } /** - * 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. + * Adds or replaces an artifact. * - * @param artifact the artifact to add or replace. - * @throws DuplicateArtifactAttachmentException + * @param artifact The artifact to add or replace. + * + * @deprecated Please use {@link MavenProjectHelper} + * @see https://issues.apache.org/jira/browse/MNG-5868 + * @see https://issues.apache.org/jira/browse/MNG-5387 + * @see https://issues.apache.org/jira/browse/MNG-4013 + * @see https://issues.apache.org/jira/browse/MNG-3119 */ +@Deprecated public void addAttachedArtifact( Artifact artifact ) -throws DuplicateArtifactAttachmentException { -getAttachedArtifacts().add( artifact ); +getAttachedArtifacts(); +assert this.attachedArtifacts != null : "Unexpected missing attached artifacts."; + +boolean replaced = false; +for ( int i = 0, s0 = this.attachedArtifacts.size(); i < s0; i++ ) +{ +final Artifact a = this.attachedArtifacts.get( i ); + +if ( a.equals( artifact ) ) +{ +
maven git commit: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
Repository: maven Updated Branches: refs/heads/master d980040ff -> dc7b41455 [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure o Updated to log an information message when an existing attached artifact got replaced. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/dc7b4145 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/dc7b4145 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/dc7b4145 Branch: refs/heads/master Commit: dc7b41455499e7f6b58fbbd05472142f052c Parents: d980040 Author: Christian SchulteAuthored: Fri Dec 18 23:41:52 2015 +0100 Committer: Christian Schulte Committed: Fri Dec 18 23:41:52 2015 +0100 -- .../org/apache/maven/project/DefaultMavenProjectHelper.java| 6 ++ 1 file changed, 6 insertions(+) -- http://git-wip-us.apache.org/repos/asf/maven/blob/dc7b4145/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..54c15bb 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 @@ -93,7 +93,13 @@ public class DefaultMavenProjectHelper public void attachArtifact( MavenProject project, Artifact artifact ) { +final int size = project.getAttachedArtifacts().size(); project.addAttachedArtifact( artifact ); + +if ( project.getAttachedArtifacts().size() == size && this.getLogger().isInfoEnabled() ) +{ +this.getLogger().info( String.format( "Replaced artifact %s.", artifact ) ); +} } public void addResource( MavenProject project, String resourceDirectory, List includes,
maven git commit: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
Repository: maven Updated Branches: refs/heads/master 56543e464 -> 020e35816 [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure o Updated method 'MavenProject.getAttachedArtifacts' to return an unmodifiable list. o Updated method 'MavenProject.addAttachedArtifact' to throw a 'DuplicateArtifactAttachmentException', if the same artifact already is attached. o Updated all 'attachArtifact' methods of interface 'MavenProjectHelper' to also throw a 'DuplicateArtifactAttachmentException', if the same artifact already is attached. This commit reduces the chances of 'hacking' the list of attached artifacts in unspecified ways. Such 'hacks' will now lead to 'RuntimeException's and will no longer work. Depending on what this leads to, plugins need to be updated and new methods may need to be added to 'MavenProjectHelper' for any use-cases no longer supported. Reverting this commit to stay compatible to unspecified behaviour should be the last option considered. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/020e3581 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/020e3581 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/020e3581 Branch: refs/heads/master Commit: 020e35816f184c10c3f87f103336fed4516f7af6 Parents: 56543e4 Author: Christian SchulteAuthored: Thu Dec 17 22:43:47 2015 +0100 Committer: Christian Schulte Committed: Thu Dec 17 22:43:47 2015 +0100 -- .../project/DefaultMavenProjectHelper.java | 7 --- .../org/apache/maven/project/MavenProject.java | 66 +--- .../maven/project/MavenProjectHelper.java | 12 +++- 3 files changed, 65 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven/blob/020e3581/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 2cce9f6..223e920 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,13 +91,6 @@ 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/020e3581/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 9c936e1..5710250 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,19 +909,65 @@ public class MavenProject } /** - * 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. + * 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. * - * @param artifact the artifact to add or replace. - * @throws DuplicateArtifactAttachmentException + * @see #isArtifactAttached(org.apache.maven.artifact.Artifact) + * @see #getAttachedArtifacts() + * + * @deprecated Please use {@link MavenProjectHelper} to attach artifacts to a project. */ +@Deprecated
[2/2] maven git commit: [MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure
[MNG-5868] Adding serval times the same artifact via MavenProjectHelper (attachArtifact) does not produce a failure o Updated to restore the behaviour consensus had been reached in MNG-5387. o Kept 'MavenProject.getAttachedArtifacts' to return an unmodifiable list. Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/5f048234 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/5f048234 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/5f048234 Branch: refs/heads/master Commit: 5f048234ff44dbf70fcad9f17834c64866f452e1 Parents: 536350f Author: Christian SchulteAuthored: Fri Dec 18 00:27:26 2015 +0100 Committer: Christian Schulte Committed: Fri Dec 18 00:30:02 2015 +0100 -- .../project/DefaultMavenProjectHelper.java | 7 .../org/apache/maven/project/MavenProject.java | 39 +++- 2 files changed, 29 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/maven/blob/5f048234/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 2cce9f6..223e920 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,13 +91,6 @@ 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/5f048234/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 9c936e1..8337834 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 @@ -909,19 +909,38 @@ public class MavenProject } /** - * 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. + * Adds or replaces an artifact. * - * @param artifact the artifact to add or replace. - * @throws DuplicateArtifactAttachmentException + * @param artifact The artifact to add or replace. + * + * @deprecated Please use {@link MavenProjectHelper} + * @see https://issues.apache.org/jira/browse/MNG-5868 + * @see https://issues.apache.org/jira/browse/MNG-5387 + * @see https://issues.apache.org/jira/browse/MNG-4013 + * @see https://issues.apache.org/jira/browse/MNG-3119 */ +@Deprecated public void addAttachedArtifact( Artifact artifact ) -throws DuplicateArtifactAttachmentException { -getAttachedArtifacts().add( artifact ); +getAttachedArtifacts(); +assert this.attachedArtifacts != null : "Unexpected missing attached artifacts."; + +boolean replaced = false; +for ( int i = 0, s0 = this.attachedArtifacts.size(); i < s0; i++ ) +{ +final Artifact a = this.attachedArtifacts.get( i ); + +if ( a.equals( artifact ) ) +{ +this.attachedArtifacts.set( i, artifact ); +replaced = true; +} +} + +if ( !replaced ) +{ +this.attachedArtifacts.add( artifact ); +} } public List getAttachedArtifacts() @@ -930,7 +949,7 @@ public class MavenProject { attachedArtifacts = new ArrayList<>(); } -return attachedArtifacts; +return Collections.unmodifiableList( attachedArtifacts ); } public Xpp3Dom getGoalConfiguration( String