Visitar URL original
set-property should add the property if it does not yet exist by mandritschke · Pull Request #1340 · mojohaus/versions · GitHub
Skip to content

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

Merged
slachiewicz merged 4 commits into
mojohaus:masterfrom
mandritschke:issues/1268
Nov 7, 2026
Merged

slachiewicz merged 4 commits into
mojohaus:masterfrom
mandritschke:issues/1268

Conversation

@mandritschke

@mandritschke mandritschke commented Jan 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1268

With insert (-Dinsert), set-property adds the property when the POM doesn't declare it, for example to override a property inherited from the parent. With profileId, it inserts into that profile and creates the profile or its properties when they are missing. Without insert, the goal still updates existing properties only.

Updating a property also handles two cases it missed: a property declared before a profile's <id>, and a property name declared more than once, where the last declaration is updated.

mvn versions:set-property -Dproperty=mockitoVersion -DnewVersion=4.11.1 -Dinsert

The goal runs on every module of a multi-module build; use -N to insert the property into the parent POM only.

@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

This comment has been minimized.

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

Copy link
Copy Markdown
Contributor 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
@mandritschke

Copy link
Copy Markdown
Contributor Author

I just updated the PR:

  • New profiles can now be inserted as well.

`\s` also matches line breaks, so a blank line before the first indented
element became part of the indentation and inserted properties gained
extra blank lines. The new members are @SInCE 2.25.0, the next minor.
@slachiewicz
slachiewicz merged commit 5fe17fb into mojohaus:master Nov 7, 2026
12 checks passed
@github-actions github-actions Bot added this to the 2.24.1 milestone Nov 7, 2026
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