rmannibucau commented on code in PR #24:
URL: 
https://github.com/apache/maven-source-plugin/pull/24#discussion_r1541972601


##########
src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java:
##########
@@ -303,15 +304,24 @@ protected void packageSources(List<MavenProject> 
theProjects) throws MojoExecuti
             }
 
             if (attach) {
+                boolean requiresAttach = true;
                 for (Artifact attachedArtifact : 
project.getAttachedArtifacts()) {
-                    if (isAlreadyAttached(attachedArtifact, project, 
getClassifier())) {
-                        getLog().error("We have duplicated artifacts 
attached.");
-                        throw new MojoExecutionException("Presumably you have 
configured maven-source-plugin "
-                                + "to execute twice in your build. You have to 
configure a classifier "
-                                + "for at least one of them.");
+                    Artifact previouslyAttached = 
getPreviouslyAttached(attachedArtifact, project, getClassifier());
+                    if (previouslyAttached != null) {
+                        if (!outputFile.equals(previouslyAttached.getFile())) {

Review Comment:
   I'd close it as invalid but think they hide multiple issues:
   
   * maven core shouldn't define attach-sources even for release profile -> 
fixed in v4
   * any build shouldn't attach twice the same artifact -> TBD in related 
projects (so "not an issue" on maven side)
   
   Ambiguity is that point #2 comes from point #1 which is in maven core.
   Ideally a real "maven" fix should be to drop the release profile in 3.x 
branch (no strong opinion on it) 
https://github.com/apache/maven/blob/maven-3.x-next/maven-model-builder/src/main/resources/org/apache/maven/model/pom-4.0.0.xml#L59.
   
   So for source plugin: invalid, for maven 3.9: valid, for maven 4: not an 
issue.
   
   Hope it makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to