gnodet opened a new pull request, #12443:
URL: https://github.com/apache/maven/pull/12443

   ## Summary
   
   - Fix `PluginUpgradeStrategy` to set `precedingWhitespace` on `Comment` 
nodes inserted before plugin elements, so the "Override version inherited from 
parent" comment appears on its own line instead of being appended to the 
preceding `</plugin>` closing tag
   - Add test assertions to verify comments are not on the same line as closing 
tags
   
   ## Problem
   
   When mvnup adds plugin management entries for plugins inherited from a 
remote parent, it inserts a `<!-- Override version inherited from parent -->` 
comment before the `<plugin>` element. The `Comment.of(...)` factory creates a 
comment with no `precedingWhitespace`, causing it to render on the same line as 
the previous `</plugin>` closing tag:
   
   ```xml
               </plugin><!-- Override version inherited from parent -->
               <plugin>
   ```
   
   This breaks projects that enforce POM formatting (e.g. via 
`spotless-maven-plugin`), which expect:
   
   ```xml
               </plugin>
               <!-- Override version inherited from parent -->
               <plugin>
   ```
   
   ## Fix
   
   Set `precedingWhitespace` on the `Comment` node to match the plugin 
element's indentation at both insertion sites in `PluginUpgradeStrategy`:
   - `addPluginManagementEntryFromUpgrade()` — for 
`build/pluginManagement/plugins`
   - `addDirectPluginOverrides()` — for `build/plugins`
   
   Fixes gnodet/maven4-testing#23134
   
   ## Test plan
   
   - [x] Existing `PluginUpgradeStrategyTest` passes (31 tests)
   - [x] New assertions verify comments are on their own line 
(`assertFalse(xml.contains("</plugin><!--"), ...)`)
   - [x] Full `maven-cli` module verify passes (468 tests)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to