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


##########
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:
   > it defeats the enhancements to prevent to write twice the same artifact 
and corrupt a build
   
   wrong:
   1. it avoid adding twice: see the `boolean requiresAttach`
   2. it checks if 2 attaches try to attach real different files = different 
file names = where you really need to configure a classifier
   
   as I wrote on the ML
   I think it does t
   
   > he right job at differentiating 2 cases that the initial MSOURCES-121 
merged too aggressively:
   > 1. do not fail when executed twice with the same output file
   > 2. but fail when re-attach happens to another output file = another 
classifier has to be configured



-- 
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