Skip to content

set-property should add the property if it does not yet exist - #1340

Open
mandritschke wants to merge 4 commits into
mojohaus:masterfrom
mandritschke:issues/1268
Open

mandritschke wants to merge 4 commits into
mojohaus:masterfrom
mandritschke:issues/1268

Conversation

@mandritschke

@mandritschke mandritschke commented Jan 26, 2026 •

Copy link
Copy Markdown

Fixes #1268

  • instead of just updating existing properties allows to insert completely new properties new properties overriding properties from parent POM
  • works for properties on the project level as well as on the profile level (that is if a profile id is given)
  • though this implementation won't create new profiles at the moment, this could be a possible enhancement, let me know if this sounds useful
  • formatting was kind of a challenge

Usage

mvn org.codehaus.mojo:versions-maven-plugin:2.21.1-SNAPSHOT:set-property \
  -Dproperty=mockitoVersion \
  -DnewVersion=4.11.1 \
  -Dinsert

Notice that set-properties will be executed recursively on child modules if there are any.
If you don't want the property to be inserted into all of these child modules use the -N option.

@wilx

wilx commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution. I found two regressions and one gap:

Reproduced all three; 80 selected unit tests pass.

@slachiewicz
slachiewicz marked this pull request as draft September 18, 2026 20:26
@slachiewicz

Copy link
Copy Markdown
Member

@mandritschke are you still working on this? The three findings from @wilx's review in September are the open items, and the branch needs a rebase onto master, which moved the tests to JUnit 5. If you don't have time, we can carry it forward with your commit and fix the findings on top.

@slachiewicz slachiewicz added the enhancement New feature or request label Oct 12, 2026
@mandritschke

Copy link
Copy Markdown
Author

Hi,
I've rebased the branch onto the latest master and addressed the two regressions mentioned in the review (thank you @wilx):

  • Properties before a profile's <id> should now update correctly.
  • The implementation now updates the last declaration of repeated property names.

Inserting into a profile without a local declaration is not done yet.

@slachiewicz
slachiewicz marked this pull request as ready for review October 13, 2026 11:11
- drop some unused states
- improve unit tests
@mandritschke

Copy link
Copy Markdown
Author

I just updated the PR:

  • New profiles can now be inserted as well.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

set-property should add the property if it does not yet exist

3 participants