You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Maven: only rewrite a declaration's own <version> when bumping - #16969
Maven::FileUpdater#updated_file_declaration replaced every occurrence of the old version string in the whole <plugin>/<dependency> node. A plugin bump therefore also rewrote matching values nested in <executions> or <configuration>.
For example, bumping maven-enforcer-plugin 3.6.3 → 3.7.0 also changed <requireMavenVersion><version>3.6.3</version>, which raised the project's minimum Maven version to one that doesn't exist.
Now only the declaration's own <version> child is rewritten.
Anything you want to highlight for special attention from reviewers?
Depth check: each <version> match is checked for element depth 1 within the declaration, using the new element_depth helper, which counts tags (ignoring comments and self-closing tags) in the text before the match.
The issue's suggested fix cuts the declaration off at the first <executions>/<configuration>/<dependencies>. That misses plugins that declare <version> after those blocks, so I used a depth check instead.
Comment handling: the version regex still allows XML comments between the value and </version>. The existing "with a comment on the version" spec depends on this.
Rubocop: I added rubocop:disable Metrics/ClassLength on FileUpdater, which now exceeds the 350-line limit.
Sibling ecosystems: I did not check gradle or sbt for the same problem.
How will you know you've accomplished your goal?
Added the plugin_config_same_version.xml fixture, which is the minimal repro from the issue, and a spec that asserts the plugin <version> becomes 3.7.0 while requireMavenVersion stays 3.6.3.
The existing Maven specs still pass, including the version-comment and whitespace cases.
In the local run I have confirmed the expected behaviour
Checklist
I have run the complete test suite to ensure all tests and linters pass.
I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
I have written clear and descriptive commit messages.
I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
I have ensured that the code is well-documented and easy to understand.
v-thavaahariharangit
changed the title
[WIP] Update maven-enforcer-plugin from 3.6.3 to 3.7.0
Maven: only rewrite a declaration's own <version> when bumping
Nov 18, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The updater can fail on valid plugin declarations containing CDATA, comments, or tag whitespace, while missing packaging metadata causes the regression test to bypass the plugin rewrite.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The updater fails on valid version elements with attributes and can miscalculate XML depth, skipping replacements and raising Expected content to change!.
The new opening-tag pattern rejects valid version elements with attributes, such as <version xmlns="http://maven.apache.org/POM/4.0.0">3.6.3</version>. Both FileParser and DeclarationFinder remove namespaces and recognize this requirement, and the previous replacement updated it. Now no replacement occurs, so update_version_in_file raises Expected content to change!. Allow attributes on the opening version tag while preserving them in the replacement.
Quoted attributes and processing instructions corrupt tag depth
When configuration precedes the plugin's own version, a self-closing tag such as <arg value="a > b"/> is counted as an opening element, so the version update is skipped and update_version_in_file raises Expected content to change!. Processing instructions containing tag-shaped text can also corrupt the depth calculation. Consume quoted attributes and processing instructions as complete tokens, exclude processing instructions from the depth count, and add regression coverage for these cases.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the opening-tag regex mishandles > inside quoted XML attributes, causing previously working Maven version updates to fail.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the regex can skip valid Maven version declarations with adjacent processing instructions, leaving versions unchanged and causing updates to fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
What are you trying to accomplish?
Fixes: #16797
Maven::FileUpdater#updated_file_declarationreplaced every occurrence of the old version string in the whole<plugin>/<dependency>node. A plugin bump therefore also rewrote matching values nested in<executions>or<configuration>.For example, bumping
maven-enforcer-plugin3.6.3 → 3.7.0 also changed<requireMavenVersion><version>3.6.3</version>, which raised the project's minimum Maven version to one that doesn't exist.Now only the declaration's own
<version>child is rewritten.Anything you want to highlight for special attention from reviewers?
<version>match is checked for element depth 1 within the declaration, using the newelement_depthhelper, which counts tags (ignoring comments and self-closing tags) in the text before the match.<executions>/<configuration>/<dependencies>. That misses plugins that declare<version>after those blocks, so I used a depth check instead.</version>. The existing "with a comment on the version" spec depends on this.rubocop:disable Metrics/ClassLengthonFileUpdater, which now exceeds the 350-line limit.gradleorsbtfor the same problem.How will you know you've accomplished your goal?
plugin_config_same_version.xmlfixture, which is the minimal repro from the issue, and a spec that asserts the plugin<version>becomes3.7.0whilerequireMavenVersionstays3.6.3.In the local run I have confirmed the expected behaviour

Checklist
<version>with the same value inside that plugin's<configuration>#16797