Fix IllegalArgumentException in getFolder() for ancestor resource dirs#2160
Open
chagong wants to merge 3 commits intoeclipse-m2e:mainfrom
Open
Fix IllegalArgumentException in getFolder() for ancestor resource dirs#2160chagong wants to merge 3 commits intoeclipse-m2e:mainfrom
chagong wants to merge 3 commits intoeclipse-m2e:mainfrom
Conversation
When a resource <directory> resolves to an ancestor of the project
(e.g., from a child module, or
<directory>..</directory>), projectLocation.relativize(folderPath)
produces '..'. Then project.getFolder('..') normalizes to IPath '/',
triggering IllegalArgumentException: Path must include project and
resource name: /.
Add a guard to detect when the relativized path starts with '..' and
return the project, so the caller (addResourceDirs) skips the resource
directory. This follows the same pattern as the existing
workaround.
Fixes eclipse-m2e#1790
Signed-off-by: Changyong Gong <chagon@microsoft.com>
df14175 to
70e8b8e
Compare
Contributor
|
This pull request changes some projects for the first time in this development cycle. Warning 🚧 This PR cannot be modified by maintainers because edits are disabled or it is created from an organization repository. To obtain the required changes apply the git patch manually as an additional commit. Git patchFurther information are available in Common Build Issues - Missing version increments. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a resource
<directory>resolves to an ancestor of the project directory,AbstractJavaProjectConfigurator.getFolder()crashes with:This happens because
projectLocation.relativize(folderPath)produces.., andproject.getFolder("..")normalizes to IPath/.Affected projects
<directory>${maven.multiModuleProjectDirectory}</directory>in<resources><directory>..</directory>in a child moduleError trace
Fix
Add a guard in
getFolder(): when the relativized path starts with.., returnprojectso the caller (addResourceDirs) skips the resource directory. This follows the same pattern as the existing${basedir}workaround inaddResourceDirs()which already returns early whenr == project.Fixes #1790