Eclipse Plugin sets wrong project classpath for external projects
A source code analyzer
Brought to you by:
adangel,
juansotuyo
PMD-Plugin: 4.0.7.v20150522-1709
Eclipse Luna SR2
Scenario:
Source code of project is in directory /code/project.git/myProject
Eclipse Workspace is in directory /code/project.workspace
The projects are imported into the workspace using "Import" -> "Existing Projects into Workspace"
A check now wants to load a class using ClassTypeResolver.loadClass(...).
This does not work for any project-local classes.
It seems as if the PMD plugin is using the classpath /code/project.workspace/myProject/bin. This does not work, as the project is just "linked" into the workspace. The classpath should contain "/code/project.git/myProject/bin.
The same is true for classes from project-local jars.
How to fix:
In the Mehod net.sourceforge.pmd.eclipse.runtime.cmd.JavaProjectClassLoader.addURL(IPath path) the filesystem absolute path of a workspace resource is determined. This should be done with:
path = workspaceRoot.findMember(path).getLocation();