-
Notifications
You must be signed in to change notification settings - Fork 173
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
"Model not available" error on non-Gradle project #984
Comments
During the analysis for groovy/groovy-eclipse#1087, it turns out that the problem is likely to be determined by the fact that my Groovy non-Gradle project depends on a Gradle project. It seems like an attempt to resolve transitive dependencies from the Groovy Plugin triggers an attempt from Buildship to resolve even the dependent project as a Gradle project, and this fails because it is not, indeed. |
Sorry for the late reply. Given the complexity, it would take a a considerable effort just to reproduce the problem on my side. Could you prepare a minimal example workspace exhibiting the problem? I'd be happy to take a look. |
Hi Donat, Let me know if you still need me to prepare a test case. |
Here is the example structure:
When calling API JavaRuntime.resolveRuntimeClasspathEntry(IRuntimeClasspathEntry,IJavaProject) to get the resolved runtime classpath of JavaProject, the Gradle container fails with exception: As stated, there are more details in the eclipse bug. I believe this could be fixed on your side as well. When resolving a classpath entry, there is the passed java project reference as well as a reference available through an accessor. Whichever is used, if the other were used instead, the NPE could be avoided. I don't know if the semantics of the two references are different, but one is not always available. Groovy Development Tools makes the |
The exception happens only if the referenced Gradle project hasn't been synced and the classpath I think I understand the situation a bit better. The use-case happens when the referenced Gradle project has not been synced and consequently the classpath container data is still uninitialized. For the context of Buildship, this is correct. All Gradle projects are added to the workspace via synchronization, therefore the classpath container data is always present. I see two paths to solve the situation in Buildship:
I'm leaning towards the first approach as it would give back the same state to |
Not sure if I understand this correctly. But I can reproduce this problem consistently, on each save of a Groovy file in the dependent project, independently on whether the classpath container "Project and external dependencies" in the dependency project is populated or not. Gradle => Refresh Gradle Project on the dependency project does not help. Indeed this setup currently never works at all. |
OK, that is really weird. The class responsible for loading/saving model data is simple: https://github.com/eclipse/buildship/blob/321da3ad3e351f8c9ba7300a142f978fd2851081/org.eclipse.buildship.core/src/main/java/org/eclipse/buildship/core/internal/preferences/DefaultModelPersistence.java |
Hi Donat, reproducing is really easy. I prepared a workspace for you: This was produced by simply doing:
In order to try this:
|
Thanks for the sample project. Now I think I understand the problem. The runtime classpath entry resolver points to a wrong project when the resoultion starts from an external project. I'll create a snapshot release for you to evaluate. |
@mauromol Could you please try this snapshot release? https://download.eclipse.org/buildship/updates/e416/snapshots/3.x/3.1.5.v20210301-1119-s/ |
@donat I made a quick test and I don't get the exception any more! So it seems like it's working fine now. Thank you! |
Thanks for the confirmation! |
The fix is now merged and part of the latest snapshot release. |
Facing this issue for normal Java project on the following version: Version: 2023-03 (4.27.0) Edit: The problem got solved after I removed the buildship Gradle classpath entry from the .classpathfile |
Hello, Looks like I have the same issue : |
Expected Behavior
No error at all. I would even expect Buildship to do nothing on a non-Gradle project.
Current Behavior
Recently I started to get an error when building some Groovy projects (through "clean project" or through a change in a Groovy source file). These projects are NOT Gradle projects.
This is a screenshot:
And this is the contents of the Eclipse error log:
The mentioned
TestGroovy
project is an Eclipse Groovy project with neither a Gradle nature nor abuild.gradle
script.This error was also reported to the Groovy Eclipse plugin issue tracker: groovy/groovy-eclipse#1087
Context
Just trying to perform an incremental or full build of a plain Eclipse Groovy project (not being a Gradle project).
Started to happen recently, although I can't say when. Perhaps from when I upgraded to Eclipse 2019-12, but I don't know for sure.
Current Buildship version is 3.1.3.v20191118-1057.
Steps to Reproduce
Create a simple Groovy project (not a Gradle project).
Restart your IDE.
Do Project | Clean... to clean that project.
I don't know if this can be reproduced consistently just after the first restart after creating the Groovy project. I'm pretty sure that upon creation, no error is given until you restart, because I know for sure that I used this
TestGroovy
project for a while, with no problems. Currently, I can reproduce this problem always, whenever I try yo clean this project or to save a change in any of the Groovy source files in it.I was not able to find a way to fix this problem. I usually have to delete the affected project and re-create from scratch. Fortunately for me, this is happening on test projects.
Your Environment
This happens on both a Windows and a Linux systems. They both use the same Eclipse, Groovy Eclipse plugin and Buildship versions.
The text was updated successfully, but these errors were encountered: