-
Notifications
You must be signed in to change notification settings - Fork 194
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
Error message when building a Groovy project or changing a Groovy source in it #1087
Comments
GroovyClassLoaderFactory scans your project(s) and assembles the classpath so that the Groovy compiler can do its thing. private static void calculateClasspath(IJavaProject javaProject, Set<String> classPaths, Set<String> xformPaths) {
try {
// TODO: Leverage "excludeTestCode" parameter? http://www.eclipse.org/eclipse/news/4.8/M5/index.html#jdt-test-sources
IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(javaProject);
Arrays.sort(entries, Comparator.comparing(IRuntimeClasspathEntry::getType));
for (IRuntimeClasspathEntry unresolved : entries) {
Set<String> paths = (unresolved.getType() == IRuntimeClasspathEntry.CONTAINER ? classPaths : xformPaths);
for (IRuntimeClasspathEntry resolved : resolveRuntimeClasspathEntry(unresolved, javaProject)) {
paths.add(getAbsoluteLocation(resolved));
}
}
classPaths.addAll(xformPaths);
assert classPaths.stream().map(File::new).allMatch(File::isAbsolute);
} catch (Exception e) {
// Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
// at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory.calculateClasspath(GroovyClassLoaderFactory.java:198)
throw new RuntimeException(e);
}
}
private static IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry classpathEntry, IJavaProject javaProject) throws Exception {
//Caused by: java.lang.reflect.InvocationTargetException
// at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
// at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
// at java.lang.reflect.Method.invoke(Method.java:498)
// at org.eclipse.jdt.groovy.core.util.ReflectionUtils.throwableExecutePrivateMethod(ReflectionUtils.java:117)
//return JavaRuntime.resolveRuntimeClasspathEntry(classpathEntry, javaProject); // indirect dependency on org.eclipse.debug.core.ILaunchConfiguration
return ReflectionUtils.throwableExecutePrivateMethod(JavaRuntime.class, "resolveRuntimeClasspathEntry", new Class[] {IRuntimeClasspathEntry.class, IJavaProject.class}, JavaRuntime.class, new Object[] {classpathEntry, javaProject});
}
//Caused by: org.eclipse.buildship.core.internal.GradlePluginsRuntimeException: Model not available for TestGroovy
// at org.eclipse.buildship.core.internal.workspace.GradleClasspathContainerRuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(GradleClasspathContainerRuntimeClasspathEntryResolver.java:77)
// at org.eclipse.buildship.core.internal.workspace.GradleClasspathContainerRuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(GradleClasspathContainerRuntimeClasspathEntryResolver.java:66)
// at org.eclipse.jdt.internal.launching.RuntimeClasspathEntryResolver.resolveRuntimeClasspathEntry(RuntimeClasspathEntryResolver.java:110)
// at org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspathEntry(JavaRuntime.java:1505) Looks like your Gradle Classpath Container is in a stale state. Can you try refresh of Gradle on your project? |
Whoops, I didn't notice the references to the Gradle plugin... The problem is that the involved project is NOT a Gradle project... I think I have to report to them then, unless you think that it's something on Greclipse side that triggers that code (while it should not). What do you think? |
What does the .project file of your TestGroovy project look like? I think you might have the Gradle nature on it. |
Here it is: <?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TestGroovy</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription> No Gradle nature... |
Does your TestGroovy project have a build.gradle or a .settings/org.eclipse.buildship.core.prefs? In the Package/Project Explorer, does it have a Project and External Dependencies node (.classpath file has |
However, now that I look at the |
Greclipse needs to resolve the transitive dependencies of linked projects. I'm not sure how Buildship/Gradle thinks the classpath container belongs to the TestGroovy project. |
Turns out |
ready to test |
I updated to 3.8.0.v202004152128-e1912, but I still see the problem. The error in the log is this:
As an additional problem, when I hit Ctrl+Shift+T to open a class in TestGroovy/src, I now get this: And the Eclipse log contains this:
repeated 9 times, followed by:
and:
My question: did you change anything recently with regards to this? I mean, I have been using a similar project setup for years with no problems, but only recently it started to throw exceptions. |
I can recreate locally. And it turns out to be a bug in JDT's DefaultEntryResolver: @Override
public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry, IJavaProject project, boolean excludeTestCode) throws CoreException {
IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2)entry;
IRuntimeClasspathEntry[] entries = entry2.getRuntimeClasspathEntries(excludeTestCode);
List<IRuntimeClasspathEntry> resolved = new ArrayList<>();
for (int i = 0; i < entries.length; i++) {
IRuntimeClasspathEntry[] temp = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], project, excludeTestCode);
// should pass "entries[i].getJavaProject()" instead of ^^^^^^^
for (int j = 0; j < temp.length; j++) {
resolved.add(temp[j]);
}
}
return resolved.toArray(new IRuntimeClasspathEntry[resolved.size()]);
} I will pursue a fix with the |
@eric-milles sorry for annoying you, did you see Sarika Sinha's comment to your Gerrit? :-) |
Recently I started to get an error when I try to clean/build some plain Eclipse Groovy projects or just try to change a Groovy source in them. I was not able to fix it and I can't understand what is wrong. Fortunately, usually those projects are test projects, yet this is annoying and the only workaround I found was to delete those projects and recreate them from scratch.
This is the modal dialog that is shown when I issue a "Clean project" action:
And this is the what gets printed to the error log:
The error seems to suggest there's a problem in the project setup with regards to Groovy libraries, but the "Groovy libraries" classpath container is there (with groovy-2.5.11-indy.jar, groovy-test-2.5.11-indy.jar and ivy-2.4.0.jar), even "Groovy DSL support" container is there (although I don't use DSL support) and, most importantly, I did not manually change anything on that project that may justify some kind of project "corruption".
The text was updated successfully, but these errors were encountered: