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:08 UTC
[maven] 02/04: more simple
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 38b0a85e2ce9db6e7ec328e79f6b63c3ed46f33e
Author: olivier lamy <ol...@apache.org>
AuthorDate: Tue Jun 2 07:07:29 2020 +1000
more simple
Signed-off-by: olivier lamy <ol...@apache.org>
---
.../main/java/org/apache/maven/project/MavenProject.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 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 f76d22d..a03b529 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
@@ -127,7 +127,7 @@ public class MavenProject
private List<RemoteRepository> remotePluginRepositories;
- private List<Artifact> attachedArtifacts;
+ private List<Artifact> attachedArtifacts = new ArrayList<>();
private MavenProject executionProject;
@@ -926,18 +926,20 @@ public class MavenProject
* coordinates.
*
* @param artifact the artifact to add or replace.
- * @throws DuplicateArtifactAttachmentException
+ * @deprecated Please use {@link MavenProjectHelper}
+ * @throws DuplicateArtifactAttachmentException not used anymore but leave it for backward compatibility
*/
public void addAttachedArtifact( Artifact artifact )
throws DuplicateArtifactAttachmentException
{
// if already there we remove it and add again
- if ( getAttachedArtifacts().contains( artifact ) )
+ int index = attachedArtifacts.indexOf( artifact );
+ if ( index > 0 )
{
LOGGER.warn( "artifact {} already attached, remove previous instance and add again" );
- getAttachedArtifacts().remove( artifact );
+ attachedArtifacts.set( index, artifact );
}
- getAttachedArtifacts().add( artifact );
+ attachedArtifacts.add( artifact );
}
public List<Artifact> getAttachedArtifacts()
@@ -946,7 +948,7 @@ public class MavenProject
{
attachedArtifacts = new ArrayList<>();
}
- return attachedArtifacts;
+ return Collections.unmodifiableList( attachedArtifacts );
}
public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId,