Skip to content

Fix Source targetPath incorrectly aligned to project basedir#12178

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

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

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 28, 2026

Summary

  • DefaultModelPathTranslator.alignToBaseDirectory(Source) was incorrectly resolving Source.targetPath against the project basedir, turning a relative path like .grammar into an absolute path like /path/to/project/.grammar
  • This caused the maven-resources-plugin to write files to incorrect absolute locations instead of relative to the output directory (target/classes)
  • Removed the targetPath alignment from Source path translation, matching the existing behavior for Resource.targetPath (which is correctly not aligned)

Test plan

  • New DefaultModelPathTranslatorTest — verifies Source targetPath is NOT aligned while directory IS aligned
  • New ProjectBuilderTest#testSourceTargetPathRemainsRelative — full model builder integration test with .grammar and META-INF/test targetPaths, verifying both SourceRoot API and compat Resource API
  • Existing PomConstructionTest#testTargetPathResourceRegression — still passes
  • Existing ResourceIncludeTest (10 tests) — still passes
  • Existing DefaultSourceRootTest (13 tests) — still passes
  • Full test suite for maven-impl and maven-core (547 tests) — all pass

Claude Code on behalf of Guillaume Nodet

🤖 Generated with Claude Code

gnodet added a commit that referenced this pull request May 28, 2026
Cherry-pick from fix/resource-targetpath branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-6 milestone May 28, 2026
@gnodet gnodet requested a review from desruisseaux May 29, 2026 11:10
@gnodet gnodet force-pushed the fix/resource-targetpath branch from fde9762 to 7811510 Compare June 1, 2026 19:19
DefaultModelPathTranslator.alignToBaseDirectory(Source) was resolving
Source.targetPath against the project basedir, turning relative paths
like "META-INF/tags/rdc" into absolute paths. This caused
maven-resources-plugin to write files to incorrect absolute locations
instead of relative to the output directory (target/classes).

Removed the targetPath alignment from Source path translation, matching
the existing correct behavior for Resource.targetPath.

Added test coverage for both Source (4.1.0 model) and legacy Resource
(4.0.0 model) targetPath through the compat layer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the fix/resource-targetpath branch from 7811510 to 11c30c2 Compare June 1, 2026 19:24
gnodet added a commit that referenced this pull request Jun 1, 2026
Cherry-pick from fix/resource-targetpath branch (squashed commit).

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>
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.

1 participant