Skip to content

Fix IllegalArgumentException in getFolder() for ancestor resource dirs#2160

Open
chagong wants to merge 3 commits intoeclipse-m2e:mainfrom
chagong:fix/getFolder-ancestor-resource-dir
Open

Fix IllegalArgumentException in getFolder() for ancestor resource dirs#2160
chagong wants to merge 3 commits intoeclipse-m2e:mainfrom
chagong:fix/getFolder-ancestor-resource-dir

Conversation

@chagong
Copy link
Copy Markdown

@chagong chagong commented Apr 15, 2026

Problem

When a resource <directory> resolves to an ancestor of the project directory, AbstractJavaProjectConfigurator.getFolder() crashes with:

IllegalArgumentException: Path must include project and resource name: /

This happens because projectLocation.relativize(folderPath) produces .., and project.getFolder("..") normalizes to IPath /.

Affected projects

  • Apache Dubbo — parent POM uses <directory>${maven.multiModuleProjectDirectory}</directory> in <resources>
  • Google Guava — same pattern
  • Any project using <directory>..</directory> in a child module

Error trace

org.eclipse.core.runtime.CoreException: Could not update project dubbo-common configuration
Caused by: java.lang.IllegalArgumentException: Path must include project and resource name: /
    at org.eclipse.core.runtime.Assert.isLegal(Assert.java:68)
    at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2274)
    at org.eclipse.core.internal.resources.Container.getFolder(Container.java:211)
    at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getFolder(AbstractJavaProjectConfigurator.java:1007)
    at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addResourceDirs(AbstractJavaProjectConfigurator.java:639)

Fix

Add a guard in getFolder(): when the relativized path starts with .., return project so the caller (addResourceDirs) skips the resource directory. This follows the same pattern as the existing ${basedir} workaround in addResourceDirs() which already returns early when r == project.

Fixes #1790

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>
@chagong chagong force-pushed the fix/getFolder-ancestor-resource-dir branch from df14175 to 70e8b8e Compare April 15, 2026 02:43
@eclipse-m2e-bot
Copy link
Copy Markdown
Contributor

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 fe05ea4172d5890888fc48edae6ea6fc5910aa77 Mon Sep 17 00:00:00 2001
From: Eclipse M2E Bot <m2e-bot@eclipse.org>
Date: Thu, 16 Apr 2026 07:38:12 +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

Test Results

0 files   -   336  0 suites   - 336   0s ⏱️ - 1h 14m 56s
0 tests  -   713  0 ✅  -   694  0 💤  - 16  0 ❌  - 1 
0 runs   - 2 139  0 ✅  - 2 088  0 💤  - 48  0 ❌  - 1 

Results for commit 6fda881. ± Comparison against base commit 92ca2ef.

@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

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: /

3 participants