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:06 UTC
[maven] branch no_duplicate_artifacts_in_attached_artifacts created
(now c75891c)
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a change to branch no_duplicate_artifacts_in_attached_artifacts
in repository https://gitbox.apache.org/repos/asf/maven.git.
at c75891c argh my bad wrong on index test
This branch includes the following new commits:
new 6c8c215 if attached artifacts already contains the artifact remove it and add the new one
new 38b0a85 more simple
new b058a03 fix replacing artifact
new c75891c argh my bad wrong on index test
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven] 01/04: if attached artifacts already contains the artifact
remove it and add the new one
Posted by ol...@apache.org.
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 6c8c21566d7c515b90ee3dcdfd9b83f23789cd07
Author: olivier lamy <ol...@apache.org>
AuthorDate: Mon Jun 1 12:21:13 2020 +1000
if attached artifacts already contains the artifact remove it and add the new one
Signed-off-by: olivier lamy <ol...@apache.org>
---
.../src/main/java/org/apache/maven/project/MavenProject.java | 11 +++++++++++
1 file changed, 11 insertions(+)
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 896d641..f76d22d 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
@@ -72,6 +72,8 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.repository.RemoteRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The concern of the project is provide runtime values based on the model.
@@ -90,6 +92,9 @@ import org.eclipse.aether.repository.RemoteRepository;
public class MavenProject
implements Cloneable
{
+
+ private static final transient Logger LOGGER = LoggerFactory.getLogger( MavenProject.class );
+
public static final String EMPTY_PROJECT_GROUP_ID = "unknown";
public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project";
@@ -926,6 +931,12 @@ public class MavenProject
public void addAttachedArtifact( Artifact artifact )
throws DuplicateArtifactAttachmentException
{
+ // if already there we remove it and add again
+ if ( getAttachedArtifacts().contains( artifact ) )
+ {
+ LOGGER.warn( "artifact {} already attached, remove previous instance and add again" );
+ getAttachedArtifacts().remove( artifact );
+ }
getAttachedArtifacts().add( artifact );
}
[maven] 03/04: fix replacing artifact
Posted by ol...@apache.org.
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()
[maven] 02/04: more simple
Posted by ol...@apache.org.
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,
[maven] 04/04: argh my bad wrong on index test
Posted by ol...@apache.org.
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 c75891cff8d76825efc23a38691222442799c53d
Author: olivier lamy <ol...@apache.org>
AuthorDate: Tue Jun 2 16:29:37 2020 +1000
argh my bad wrong on index test
Signed-off-by: olivier lamy <ol...@apache.org>
---
maven-core/src/main/java/org/apache/maven/project/MavenProject.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 31a7ff3..ec5efff 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
@@ -934,7 +934,7 @@ public class MavenProject
{
// if already there we remove it and add again
int index = attachedArtifacts.indexOf( artifact );
- if ( index > 0 )
+ if ( index >= 0 )
{
LOGGER.warn( "artifact {} already attached, replace previous instance", artifact );
attachedArtifacts.set( index, artifact );