[MSOURCES-140] fail only if re-attach different files by hboutemy · Pull Request #24 · apache/maven-source-plugin

Not really, I understand this PR but you introduce a regression which is that you can attach twice the same artifact due to two executions so this "fix" is actually a regression.

requiresAttach is never needed until the build is broken - ie you build twice the source artifact which means you had a broken one until it is exactly the same content (why I originally proposed to test it since it must never happen in sane builds so cost is supposed to be 0).

requiresAttach is more a ignoreAlreadyAttachedArtifact but looses the "attached artifact was not wrongly used" by another mojo case (ie you enable to process a source jar which is not the one deployed).

The fix for the two tickets is quite easy and is on build side (it is already fixed on maven side):

  • disable attach-sources phase which was embedded in maven 3.9 (or use maven 4 which does not have it anymore)
  • use the same attach-sources than in 3.9 (jar-no-fork instead of jar)

So think we don't need to loose the check which was introduced in the plugin.

To make it more obvious I think https://issues.apache.org/jira/browse/MSOURCES-121 is right and shouldn't be reverted by this PR.