Skip to content

mvnup: skip dedup inside plugin <configuration> elements - #12582

Merged
gnodet merged 2 commits into
maven-4.0.xfrom
fix/mvnup-dedup-configuration
Jul 29, 2026
Merged

mvnup: skip dedup inside plugin <configuration> elements#12582
gnodet merged 2 commits into
maven-4.0.xfrom
fix/mvnup-dedup-configuration

Conversation

@gnodet

@gnodet gnodet commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

mvnup apply's DuplicateElementStrategy incorrectly removes elements from plugin <configuration> sections, breaking builds of projects like Apache Accumulo.

  • The strategy deduplicates by tag name only — when it encounters multiple <arg> children inside <compilerArgs>, it keeps only the last one
  • In accumulo-access, this transforms <arg>-Xlint:all</arg> <arg>-Xlint:-processing</arg> <arg>-Xmaxwarns</arg> <arg>5</arg> into just <arg>5</arg>, causing error: invalid flag: 5
  • The fix stops deduplication at <configuration> boundaries — POM schema elements above it are still deduplicated, but free-form plugin XML below it is left untouched
  • This was the root cause of the accumulo, accumulo-access, and accumulo-classloaders failures in the maven4-testing compatibility suite for RC-6

Reproduction

# Clone accumulo-access, run mvnup apply with RC-6, then build:
git clone https://github.com/apache/accumulo-access.git && cd accumulo-access
mvnup apply   # removes 168 lines across 3 POMs, including compiler args
mvn clean package -DskipTests
# → error: invalid flag: 5  (on accumulo-access-test-data module)

Test plan

  • 6 new tests covering compilerArgs, exec arguments, checkstyle modules, RAT excludes, lifecycle-mapping pluginExecutions, and mixed POM-level + config scenarios
  • All 268 existing mvnup strategy tests pass
  • End-to-end verification: fixed mvnup apply on accumulo-access produces zero POM modifications and build succeeds

🤖 Generated with Claude Code

@gnodet
gnodet force-pushed the fix/mvnup-dedup-configuration branch from c709d0c to 2751d09 Compare July 29, 2026 12:36
gnodet and others added 2 commits July 29, 2026 15:58
Move the plugin POM to src/test/resources-filtered/ (which already
has <filtering>true</filtering> in the core-it-suite build) and
replace the hardcoded version with ${maven-version}, defined in the
ITs parent POM.

Maven resource filtering resolves the token at build time, so the
version always matches the Maven build under test — including during
the release process, where the release plugin bumps the version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The DuplicateElementStrategy removes duplicate XML elements using
last-wins semantics to satisfy Maven 4's stricter POM parser. However,
it was also deduplicating inside plugin <configuration> sections, where
the XML schema is free-form and plugin-specific.

This broke builds that use repeated same-named elements as list entries
(e.g. multiple <arg> in <compilerArgs>, multiple <module> in checkstyle
config, multiple <exclude> in RAT config). The tool kept only the last
occurrence of each tag name, silently dropping valid configuration.

Fix: skip deduplication entirely when inside a <configuration> element.
These sections contain plugin-specific XML whose schema is unknown to
mvnup — treating same-named children as duplicates is incorrect.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the fix/mvnup-dedup-configuration branch from 2751d09 to 246c9c8 Compare July 29, 2026 13:58
@gnodet
gnodet marked this pull request as ready for review July 29, 2026 15:18
@gnodet
gnodet merged commit a7d35a2 into maven-4.0.x Jul 29, 2026
23 checks passed
@gnodet
gnodet deleted the fix/mvnup-dedup-configuration branch July 29, 2026 15:18
@github-actions github-actions Bot added this to the 4.0.0-rc-7 milestone Jul 29, 2026
@github-actions

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

@gnodet gnodet added the bug Something isn't working label Jul 29, 2026
@gnodet gnodet modified the milestones: 4.0.0-rc-7, 4.0.0-rc-6 Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant