GeezerVison is showing github.com — [MSOURCES-140] fail only if re-attach different files by hboutemy · Pull Request #24 · apache/maven-source-plugin
Conversation
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
megglos reacted with heart emoji
Uh oh!
There was an error while loading. Please reload this page.
|
|
+ "for at least one of them.");
|
|
|
Artifact previouslyAttached = getPreviouslyAttached(attachedArtifact, project, getClassifier());
|
|
|
if (previouslyAttached != null) {
|
|
|
if (!outputFile.equals(previouslyAttached.getFile())) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we must check the (current and "future") content is the same otherwise we hide a bug with such a logic - ie if between first and second run you add sources then the output artifact is likely wrong.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too complex, without real benefit: before, mvn install deploy worked in any case
this notion of recording really the content each time attach is done is over-complexifying things: it will detect for example if build is not reproducible = not at all the intent
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, while I agree it is useless this means this PR too otherwise it defeats the enhancements to prevent to write twice the same artifact and corrupt a build so do we just close it?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hboutemy
Mar 27, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it defeats the enhancements to prevent to write twice the same artifact and corrupt a build
wrong:
- it avoids adding twice: see the
boolean requiresAttach
- 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 the right job at differentiating 2 cases that the initial MSOURCES-121 merged too aggressively:
- do not fail when executed twice with the same output file
- but fail when re-attach happens to another output file = another classifier has to be configured
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hboutemy
Mar 27, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then do nothing? keep ignoring? keep saying "fixed in Maven 4"? keep saying "don't do"? keep saying "if you do that, you are wrong"?
we're staying in circle being a pain in the ass of users who just conclude: "last working version was 3.2.1"
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
olamy reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with Herve here.
We should be more users friendly here.
Let's simply introduce a new flag called ignoreAlreadyAttachedArtifact.
If the artifact is already attached and the flag true then simply accept to override the previous entry (but log a warn) otherwise just fail as the change introduces MSOURCES-121
At least users will have the choice.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hboutemy
Mar 28, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok to drop this PR in favor of a new boolean config parameter: it will improve user experience a little bit
who can code it, please?
I don't see how to code "override the previous entry"
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hboutemy just replace it by documentation, if you reread the threads it is just people don't understanding maven superpom notion, we did our homework and fixed it now it is just a matter of managing the legacy.
@hboutemy @olamy I'm ok with ignoreAlreadyAttachedArtifact if it is not a @Parameter and if it is initialized with mvn.version == 3 + a comment must be false for maven 4 since see MSOURCES-121 and @github/#24. I'm not ok to do positive enhancements then revert them because we are not able to explain what maven does or do a new maven release - literally this PR from my window.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added new IT for MSOURCES-140 and improved messages to clarify cases:
[ERROR] Artifact org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT already attached to a file target/jar-no-fork-1.0-SNAPSHOT-sources.jar: attach to target/jar-no-fork-1.0-SNAPSHOT-secondary-sources.jar should be done with another classifier
if build is trying to attach 2 different files with same coordinates => failure and ask for configuring classifier
[INFO] Artifact org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT already attached to target/jar-no-fork-1.0-SNAPSHOT-sources.jar: ignoring same re-attach (same artifact, same file)
if re-executing same goal configuration twice: just ignore the second time
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jul 23, 2026
pull Bot
pushed a commit
to Mu-L/camunda
that referenced
this pull request
Jul 23, 2026
…nda#58463)
## What
Follow-up cleanup to the `camunda-spring-boot-3-starter` sources-jar
build: stop double-attaching the sources artifact. Adds
`<attach>false</attach>` to the `attach-sources` (`jar-no-fork`)
execution.
## Why
The deploy command runs `source:jar` (default-cli), which attaches a
`sources` artifact for every module, and the starter's `attach-sources`
(`jar-no-fork`, `attach=true` by default) attaches it a second time. On
`main`/`stable/8.9` (`maven-source-plugin` 3.4.0) that identical
re-attach is a harmless no-op (MSOURCES-140,
apache/maven-source-plugin#24). On `stable/8.8`/`stable/8.7` (3.3.1) the
same re-attach is rejected with `We have duplicated artifacts attached.`
and wedges the `Deploy snapshot artifacts` job under the `-T1C` reactor
(the ~5-day incident; immediate stopgap: bump to 3.4.0 in camunda#58462).
This makes the design robust regardless of plugin version: the execution
still writes the sources jar to disk for shade to consume — shade's
`createSourcesJar` reads the project's own sources jar **off disk**
(`shadedSourcesArtifactFile()` + `isFile()`), not from the attached
artifact — and shade attaches the shaded sources jar as the final
`sources` artifact. So `attach=false` removes only the redundant attach,
not the input shade needs, and it does not regress camunda#48090.
## Validation
- `Deploy snapshot artifacts` completes with no `duplicated artifacts`
line.
- The shipped `-sources.jar` still contains the base-module sources
(shade merge intact).
## Related
Companion to camunda#58462 (the 3.4.0 bump / re-land on `stable/8.8`). The
`stable/8.8`+`stable/8.7` counterpart of this cleanup is camunda#58464 (stacked
on camunda#58462).
---
_Generated by [Claude Code](https://claude.com/claude-code)_
Reviewers
CrazyHZM
CrazyHZM approved these changes
olamy
Awaiting requested review from olamy
Uh oh!
There was an error while loading. Please reload this page.
Labels
bug
Something isn't working
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|