GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [MSOURCES-140] fail only if re-attach different files by hboutemy · Pull Request #24 · apache/maven-source-plugin

Conversation

@hboutemy

@hboutemy hboutemy commented Mar 25, 2024

Copy link
Copy Markdown
Member

https://issues.apache.org/jira/browse/MSOURCES-140

hoping this will also solve https://issues.apache.org/jira/browse/MSOURCES-141 and https://issues.apache.org/jira/browse/MSOURCES-143

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

megglos reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@hboutemy
hboutemy force-pushed the MSOURCES-140 branch 2 times, most recently from 9078ef4 to 8f4ab52 Compare March 25, 2024 07:15
CrazyHZM
CrazyHZM approved these changes Mar 25, 2024
View reviewed changes
CrazyHZM
CrazyHZM requested changes Mar 25, 2024
View reviewed changes
Comment thread src/it/MSOURCES-121/pom.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

rmannibucau
rmannibucau reviewed Mar 25, 2024
View reviewed changes
Comment thread src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java Outdated
+ "for at least one of them.");
Artifact previouslyAttached = getPreviouslyAttached(attachedArtifact, project, getClassifier());
if (previouslyAttached != null) {
if (!outputFile.equals(previouslyAttached.getFile())) {

@rmannibucau rmannibucau Mar 25, 2024

Copy link
Copy Markdown

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.

All reactions

@hboutemy hboutemy Mar 27, 2024

Copy link
Copy Markdown
Member Author

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.

All reactions

@rmannibucau rmannibucau Mar 27, 2024

Copy link
Copy Markdown

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.

All reactions

@hboutemy hboutemy Mar 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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:

  1. it avoids 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 the 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmannibucau rmannibucau Mar 27, 2024

Copy link
Copy Markdown

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.

All reactions

@hboutemy hboutemy Mar 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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
All reactions
  • 👍 1 reaction

@olamy olamy Mar 28, 2024

Copy link
Copy Markdown
Member

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.

All reactions

@hboutemy hboutemy Mar 28, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

All reactions

@rmannibucau rmannibucau Mar 28, 2024

Copy link
Copy Markdown

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.

All reactions

@hboutemy hboutemy Mar 28, 2024

Copy link
Copy Markdown
Member Author

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.

All reactions
@hboutemy
hboutemy force-pushed the MSOURCES-140 branch from 8f4ab52 to 5184a11 Compare March 27, 2024 15:27
@hboutemy
hboutemy requested review from khmarbaise and olamy March 27, 2024 16:27
@hboutemy
[MSOURCES-140] fail only if re-attach different files
1405ec8
@hboutemy
hboutemy force-pushed the MSOURCES-140 branch from 5184a11 to 1405ec8 Compare March 28, 2024 06:07
@hboutemy
[MSOURCES-140] improve message when lifecycle run twice
681bf75
khmarbaise
khmarbaise approved these changes Apr 24, 2024
View reviewed changes
CrazyHZM
CrazyHZM approved these changes Apr 25, 2024
View reviewed changes
@hboutemy
hboutemy merged commit 53dc0f2 into master Apr 25, 2024
@hboutemy
hboutemy deleted the MSOURCES-140 branch April 25, 2024 22:22
@jira-importer

jira-importer commented Jun 10, 2025

Copy link
Copy Markdown

Resolve #212

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slachiewicz slachiewicz added this to the 3.3.2 milestone Nov 22, 2025
@slachiewicz slachiewicz assigned hboutemy Nov 22, 2025
@slachiewicz slachiewicz added the bug Something isn't working label Nov 22, 2025
@slawekjaranowski slawekjaranowski mentioned this pull request Apr 26, 2026
Bump org.apache.maven.plugins:maven-source-plugin from 3.2.1 to 3.4.0. apache/commons-parent#704
Merged
5 of 7 tasks
@slawekjaranowski slawekjaranowski linked an issue Apr 26, 2026 that may be closed by this pull request
[MSOURCES-140] Build fails when using install deploy #212
Closed
@slawekjaranowski slawekjaranowski mentioned this pull request Apr 26, 2026
[MSOURCES-143] Can't create a source and test jar in Commons using commons-parent #205
Open
@slawekjaranowski slawekjaranowski linked an issue Apr 26, 2026 that may be closed by this pull request
[MSOURCES-143] Can't create a source and test jar in Commons using commons-parent #205
Open
@slawekjaranowski slawekjaranowski mentioned this pull request Apr 26, 2026
[MSOURCES-141] Check duplication of attached jar should be configurable to not fail when using the build cache #200
Closed
This was referenced Jul 23, 2026
build: re-land camunda-spring-boot-4-starter sources jar + bump maven-source-plugin to 3.4.0 camunda/camunda#58462
Merged
fix: do not double-attach the spring-boot-3-starter sources jar camunda/camunda#58463
Merged
fix: do not double-attach the spring-boot-4-starter sources jar camunda/camunda#58464
Merged
pull Bot pushed a commit to Mu-L/camunda that referenced this pull request Jul 23, 2026
@megglos
fix: do not double-attach the spring-boot-3-starter sources jar (camu…
33ee9fb
…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)_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rmannibucau rmannibucau rmannibucau left review comments
@khmarbaise khmarbaise khmarbaise approved these changes
@CrazyHZM CrazyHZM CrazyHZM approved these changes
@olamy olamy Awaiting requested review from olamy

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@hboutemy hboutemy

Labels

bug Something isn't working

Projects

None yet

Milestone

3.4.0

Development

Successfully merging this pull request may close these issues.

[MSOURCES-143] Can't create a source and test jar in Commons using commons-parent [MSOURCES-140] Build fails when using install deploy

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@hboutemy @jira-importer @olamy @khmarbaise @rmannibucau @CrazyHZM @slachiewicz
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.