-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependent Projects with multiple source and output folders not handled (on Mars SR 1) #162
Comments
I pulled this project down and made some tweaks to the .classpath and .project files so there is a true dependency between them. I tried to upload that but the form won't recognize my zip file... What I am seeing is that the Java sources work correctly, finding classes from multiple output locations. The Groovy source in the dependent project however is running into this error:
Is this the same error you have run into? Or do you have a different error? |
I'm looking at CompilerUtils in the JDT core project, and that does indeed look like the right place to make a change. Andy commented in there that multiple output paths should be handled but were not. Within computeDependenciesFromProject, source classpath entries from the dependent project are explicitly skipped. I think that is the bit that needs alteration. Although it is not 100% clear what to do since the exported attribute on the project sourcepath entries is false. |
Your change does look correct. If you don't mind, I incorporated the check into the classpath entry loop. Could I go with this version and you close your merge request? private static void computeDependenciesFromProject(IProject baseProject, String otherProject, Set<String> accumulatedPathEntries)
throws JavaModelException {
IProject iproject = baseProject.getWorkspace().getRoot().getProject(otherProject);
IJavaProject iJavaProject = JavaCore.create(iproject);
// add the project's output location
accumulatedPathEntries.add(pathToString(iJavaProject.getOutputLocation(), iproject));
IClasspathEntry[] cpes = iJavaProject.getResolvedClasspath(true);
if (cpes != null) {
for (IClasspathEntry cpe : cpes) {
if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE && cpe.getOutputLocation() != null) {
// add the source folder's output location (if different from the project's)
accumulatedPathEntries.add(pathToString(cpe.getOutputLocation(), iproject));
} else if (cpe.isExported()) {
IPath cpePath = cpe.getPath();
String segmentZero = cpePath.segment(0);
if (segmentZero != null && segmentZero.equals(otherProject)) {
accumulatedPathEntries.add(iproject.getFile(cpePath.removeFirstSegments(1)).getRawLocation().toOSString());
} else if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
// segmentZero is a project name
computeDependenciesFromProject(baseProject, segmentZero, accumulatedPathEntries);
} else {
String otherPathElement = null;
if (segmentZero != null && segmentZero.equals(iproject.getName())) {
otherPathElement = iproject.getFile(cpePath.removeFirstSegments(1)).getRawLocation().toOSString();
} else {
otherPathElement = cpePath.toOSString();
}
accumulatedPathEntries.add(otherPathElement);
}
}
}
}
} |
Thanks a lot for taking care of this one :) This looks good to me, please go ahead with your solution. I'll close the pull request. |
Can you try with the latest snapshot and close if resolved? |
This looks good, the code compiles now. |
On a big project that consists of many projects each having different source folders and each source folder having its own output folder.
The groovy compiler only has access to the default output folder of each project. This leads to class not found exceptions in projects depending on classes that are not found in the default output folder.
Steps to reproduce:
The attached zip file contains 2 eclipse projects spock-concept and spock-concept-sub. Import them in eclipse (I used Mars SR1). And try to run
/spock-concept-sub/src/test/java/sub/ValueHolderUserSpec.groovy
This project has an internal groovy compiler error because it does not find the trait ValueHolderAware from its separate output source folder of the dependent project.
groovy-eclipse-issue.zip
The text was updated successfully, but these errors were encountered: