Skip to content

Add mvnup SourceStrategy for migrating to <source> elements - #12355

Merged
gnodet merged 5 commits into
masterfrom
feature/mvnup-source-strategy
Jun 25, 2026
Merged

gnodet merged 5 commits into
masterfrom
feature/mvnup-source-strategy

Conversation

@gnodet

@gnodet gnodet commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds SourceStrategy (@Priority(20)) to migrate legacy source configuration to Maven 4.1.0+ <source> elements
  • Handles four migration phases:
    • Compiler properties (maven.compiler.release, maven.compiler.source/target) → <source><targetVersion>
    • Compiler plugin configuration (<release>, <source>/<target> in maven-compiler-plugin) → <source><targetVersion>
    • Source/test directories (custom <sourceDirectory>/<testSourceDirectory>) → <source><directory>
    • Resources (<resources>/<testResources>) → <source> with <lang>resources</lang>, preserving filtering, includes/excludes, and targetPath
  • Applies when --model-version is 4.1.0+ or --all is set
  • Default source/resource directories are cleaned up without creating redundant <source> entries
  • Empty containers (<properties>, <plugins>, <configuration>) are removed after migration

Test plan

  • 26 unit tests covering all phases: applicability (5), compiler properties (5), compiler plugin (4), source directories (3), resources (5), model version filtering (2), combined scenarios (2)
  • Manual test: create a 4.0.0 POM with compiler properties + resources, run mvnup --model-version 4.1.0, verify output

🤖 Generated with Claude Code

gnodet and others added 2 commits June 23, 2026 22:40
Adds a new mvnup upgrade strategy that migrates legacy source
configuration to Maven 4.1.0+ <source> elements. Handles four
migration phases:

- Compiler properties (maven.compiler.release, source/target)
  to <source><targetVersion>
- Compiler plugin configuration (<release>, <source>/<target>)
  to <source><targetVersion>
- Custom source/test directories to <source><directory>
- Resource/testResource sections to <source> with lang=resources

Applies when --model-version is 4.1.0+ or --all is set.
Runs at @priority(20), after all other strategies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added enhancement New feature or request mvn4 labels Jun 23, 2026
@gnodet gnodet added this to the 4.1.0 milestone Jun 23, 2026
gnodet and others added 3 commits June 23, 2026 23:17
- Check groupId in findCompilerPlugin (not just artifactId)
- Clean up compiler plugin config when properties already provide
  targetVersion (previously left stale release/source/target elements)
- Clean up empty pluginManagement after plugin removal
- Clean up empty build element after all children removed
- Add test for pluginManagement compiler plugin migration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review feedback from desruisseaux: extract shared logic
from copyIncludesExcludes into a static copyPatternList method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Reuse existing main/java <source> element when adding targetVersion
  instead of always creating a new one (avoids duplicate source elements)
- Only remove compiler plugin config (release/source/target) when values
  match the migrated property value (preserves intentional overrides)
- Add tests for both edge cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet merged commit d733426 into master Jun 25, 2026
23 checks passed
@gnodet
gnodet deleted the feature/mvnup-source-strategy branch June 25, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant