Skip to content

Fix Source.targetPath incorrectly aligned to basedir#12206

Open
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/resource-targetpath-compat
Open

Fix Source.targetPath incorrectly aligned to basedir#12206
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/resource-targetpath-compat

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Jun 2, 2026

Summary

  • DefaultModelPathTranslator.alignToBaseDirectory(Source) was incorrectly resolving Source.targetPath against the project basedir, converting relative paths like META-INF/tags/rdc into absolute paths like /path/to/project/META-INF/tags/rdc
  • This caused maven-resources-plugin to copy resources to wrong locations when using POM 4.1.0 <source> elements with <targetPath>
  • The targetPath is relative to the output directory (target/classes), not the project basedir, so it must not be aligned during model path translation

Test plan

  • Unit tests: DefaultModelPathTranslatorTest — verifies Source directory is aligned but targetPath is not, dot-prefixed targetPath stays relative, Resource directory is aligned but targetPath is not
  • Integration tests: ProjectBuilderTest#testSourceTargetPathRemainsRelative — verifies POM 4.1.0 <source> targetPath stays relative through SourceRoot API and compat layer
  • Integration tests: ProjectBuilderTest#testResourceTargetPathRemainsRelativeInCompatLayer — verifies POM 4.0.0 <resource> targetPath stays relative
  • Manual verification: POM 4.1.0 with <source><targetPath>META-INF/tags/rdc</targetPath></source> now copies to target/classes/META-INF/tags/rdc/ (was copying to /path/to/project/META-INF/tags/rdc/)
  • Existing test suites pass for impl/maven-impl and impl/maven-core

🤖 Generated with Claude Code

The DefaultModelPathTranslator was aligning Source.targetPath to the
project basedir, converting relative paths like "META-INF/tags/rdc"
into absolute paths. This caused maven-resources-plugin to copy
resources to wrong locations (e.g., /META-INF/tags/rdc instead of
target/classes/META-INF/tags/rdc).

The targetPath is relative to the output directory (target/classes or
target/test-classes), not the project basedir, so it must not be
resolved against basedir during model path translation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Jun 2, 2026
Cherry-pick from fix/resource-targetpath-compat branch.
Supersedes earlier #12178 cherry-pick with expanded fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-6 milestone Jun 2, 2026
Copy link
Copy Markdown
Contributor

@Bukama Bukama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing tests

Error:  Failures: 
Error:    MavenITmng4559MultipleJvmArgsTest.testMultipleJvmArgs:56 expected: <value1> but was: <${test.prop1}>
Error:    MavenITmng4559SpacesInJvmOptsTest.testIt:52 expected: <foo bar> but was: <${prop.jvm-opts}>

@gnodet gnodet force-pushed the fix/resource-targetpath-compat branch from 29c67b5 to ba00e3c Compare June 3, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants