Skip to content

Fix resource folder handling for ancestor directories#2160

Open
chagong wants to merge 1 commit into
eclipse-m2e:mainfrom
chagong:fix/getFolder-ancestor-resource-dir
Open

Fix resource folder handling for ancestor directories#2160
chagong wants to merge 1 commit into
eclipse-m2e:mainfrom
chagong:fix/getFolder-ancestor-resource-dir

Conversation

@chagong
Copy link
Copy Markdown

@chagong chagong commented Apr 15, 2026

Problem

When a Maven resource directory resolves outside the project, AbstractJavaProjectConfigurator.getFolder() can pass an invalid relative path to Eclipse resource lookup. For ancestor resource directories such as <directory>..</directory>, that can normalize to / and fail with:

IllegalArgumentException: Path must include project and resource name: /

This affects projects whose child modules inherit or define resource directories outside the module directory, including cases seen with Apache Dubbo and Google Guava.

Fix

Normalize the project and resource paths before comparing them, and skip ancestor resource directories in addResourceDirs() before calling project.getFolder(). getFolder() now keeps its non-null container contract for other callers and reports ancestor paths as invalid linked-resource targets.

Fixes #1790

@eclipse-m2e-bot
Copy link
Copy Markdown
Contributor

eclipse-m2e-bot commented Apr 16, 2026

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

org.eclipse.m2e.jdt/META-INF/MANIFEST.MF

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 patch
From f916ef9027ade5f4d91b6a2a2fa941315b11dd5b Mon Sep 17 00:00:00 2001
From: Eclipse M2E Bot <m2e-bot@eclipse.org>
Date: Sat, 25 Apr 2026 13:55:46 +0000
Subject: [PATCH] Version bump(s) for null object or invalid expression stream


diff --git a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
index 0109ba6b..7fb51874 100644
--- a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
+++ b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.eclipse.m2e.jdt;singleton:=true
-Bundle-Version: 2.5.100.qualifier
+Bundle-Version: 2.5.200.qualifier
 Bundle-Localization: plugin
 Export-Package: org.eclipse.m2e.jdt,
  org.eclipse.m2e.jdt.internal;x-friends:="org.eclipse.m2e.jdt.ui",
-- 
2.53.0

Further information are available in Common Build Issues - Missing version increments.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

Test Results

  339 files  ±0    339 suites  ±0   1h 4m 26s ⏱️ + 4m 47s
  721 tests ±0    704 ✅ +3  16 💤 ±0  1 ❌  - 2 
2 163 runs  ±0  2 114 ✅ +3  48 💤 ±0  1 ❌  - 2 

For more details on these failures, see this check.

Results for commit 3f3e690. ± Comparison against base commit 7ff8669.

♻️ This comment has been updated with latest results.

@fbricon
Copy link
Copy Markdown
Contributor

fbricon commented Apr 16, 2026

@chagong you need to rebase your project against main (merge commits are strictly forbidden)
The build fails because you have to bump the org.eclipse.m2e.jdt version to 2.5.200

@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from 6fda881 to 8b07819 Compare April 17, 2026 08:06
@chagong
Copy link
Copy Markdown
Author

chagong commented Apr 17, 2026

@fbricon I actually undid the bump up bundle version. And by looking at the error log:

[2026-04-17T08:14:35.740Z] Caused by: org.eclipse.tycho.core.exceptions.VersionBumpRequiredException: Baseline problems found! Project version: 2.5.100.20260417-0757, baseline version: 2.5.100.20260205-1607, suggested version: 2.5.200

Looks like it requires me to bump that version?

@fbricon
Copy link
Copy Markdown
Contributor

fbricon commented Apr 17, 2026

try running "mvn clean verify -DskipTests -Dtycho.p2.baselineMode=failCommon" locally

@chagong
Copy link
Copy Markdown
Author

chagong commented Apr 20, 2026

@fbricon Looks like over 13 modules need version bumps. Do you want me to do it in this PR?

@fbricon
Copy link
Copy Markdown
Contributor

fbricon commented Apr 20, 2026

@chagong can you do it in a different PR?

@chagong
Copy link
Copy Markdown
Author

chagong commented Apr 21, 2026

@chagong can you do it in a different PR?

#2163

@HannesWell
Copy link
Copy Markdown
Contributor

Looks like over 13 modules need version bumps. Do you want me to do it in this PR?

I have to say that I'm in strong doubt that this is really necessary. With the information I have, I cannot explain why this would be necessary. Furthermore I also just submitted a PR where this problem didn't surface.

As #2160 (comment) suggests, you definitively need a version increment in org.eclipse.m2e.jdt.
If you'd permit edits by maintainers for this PR, the tooling do everything for you as recommended by this project.
If you don't want to do this, please see the linked FAQ on how to properly apply the version increment (e.g. the separation in another PR).

@HannesWell
Copy link
Copy Markdown
Contributor

HannesWell commented May 1, 2026

@chagong please rebase this on the latest main. The baseline check should pass now since we had another PR applying the version bump for the touched Plug-in already.

@chagong chagong marked this pull request as ready for review May 6, 2026 01:32
@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from 3fcf536 to efd7fa4 Compare May 6, 2026 02:02
@chagong
Copy link
Copy Markdown
Author

chagong commented May 7, 2026

@HannesWell pls let the workflows run.

@HannesWell
Copy link
Copy Markdown
Contributor

@chagong generally the build looks good now.
If you address the comments above, please also make sure to squash all your changes into one final commit and force push it again to this PR's branch. There is no need to record the development process in git.
Thanks in advance.

@chagong
Copy link
Copy Markdown
Author

chagong commented May 7, 2026

@HannesWell resolve your comments, but not sure about the CI failure, seems should not be caused by this PR.

@chagong
Copy link
Copy Markdown
Author

chagong commented May 11, 2026

@HannesWell can you take a look?

@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from 74ddc2a to f654158 Compare May 20, 2026 07:35
@chagong
Copy link
Copy Markdown
Author

chagong commented May 21, 2026

@fbricon @HannesWell can you let the workflows run?

@chagong
Copy link
Copy Markdown
Author

chagong commented May 22, 2026

@fbricon @HannesWell is it ok to merge?

Copy link
Copy Markdown
Contributor

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

It looks better now, but I tried it with the Guava repository and noticed that returning null in getFolder() breaks the import too. See my comment below for details.

Furthermore, please squash all your commits into one with a suitable message for this change (not just an aggregation of all current ones), including the requested change and force push it to this PR's branch.

Then this should be ready.

@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from f654158 to 61adf9e Compare May 25, 2026 01:51
@chagong chagong changed the title Fix IllegalArgumentException in getFolder() for ancestor resource dirs Fix resource folder handling for ancestor directories May 25, 2026
@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from 61adf9e to 87db7ab Compare May 25, 2026 02:44
Handle resource directories whose canonical path is an ancestor of the project without passing invalid relative paths to Eclipse resource lookup.

Skip ancestor resource directories in addResourceDirs before resolving them as workspace folders, and keep getFolder returning a non-null container for its other callers.

Signed-off-by: Changyong Gong <chagon@microsoft.com>
@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from 87db7ab to 3f3e690 Compare May 25, 2026 03:15
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.

java.lang.IllegalArgumentException: Path must include project and resource name: /

4 participants