Skip to content
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

Groovy 4.0 Support #47

Closed
JoelProminic opened this issue Jun 9, 2021 · 9 comments
Closed

Groovy 4.0 Support #47

JoelProminic opened this issue Jun 9, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@JoelProminic
Copy link

@JustinProminic noticed that Groovy 4.0.0 is in alpha currently, and he wanted to ask about upgrading the language server.

What is the current supported version of Groovy for groovy-language-server?

I know that Grails has dependencies on older versions of Groovy. We only use the groovy-language-server for Grails projects in Moonshine currently, so are we limiting the groovy support to these versions?

@JoelProminic JoelProminic added the enhancement New feature or request label Jun 9, 2021
@joshtynjala
Copy link
Collaborator

Moonshine IDE's Groovy language server currently uses Groovy 2.5.13. I recently updated the dependency in this repo to 2.5.14, but I haven't updated the .jar file used by Moonshine yet.

I've been waiting on a bug to be fixed in Groovy 3 before I upgrade the language server from Groovy 2 to Groovy 3. The bug was preventing important features from working in the language server, so Groovy 3 was basically impossible to use for a while there. As I understand it, the bug is now fixed in the Groovy 3 repository, and it should be included in an upcoming update. I have the necessary language server changes for Groovy 3 in a branch already, and I intend to merge them as soon as possible.

@JoelProminic
Copy link
Author

Thanks for the clarification. We'll need to make sure that the updated language server can work with the Grails projects in Moonshine.

If we need to determine the Groovy version for a given Grails SDK, unfortunately it seems that there is not an easy command for this. I found this suggestion, but it is very out of date: https://stackoverflow.com/questions/17916335/is-there-any-way-to-know-which-groovy-version-used-in-grails-project

@joshtynjala
Copy link
Collaborator

9f227c9

@JoelProminic
Copy link
Author

I did some tests with this on macOS and Windows, and I confirmed that it is still working for the current Grails version. I don't have an easy way to test Groovy 4.0 in Moonshine at the moment, but I'll keep this in mind when we need to upgrade.

I added a note for this update in the Moonshine 3.3.0 changelog.

@joshtynjala
Copy link
Collaborator

I have not yet added the updated Groovy language server .jar to Moonshine, so you actually tested the existing version. I'll try to get it updated later this month.

@JoelProminic
Copy link
Author

Ah, okay. This triggered update triggered a new Bamboo build for Moonshine, so I did a quick test before the 3.3.0 release.

@joshtynjala
Copy link
Collaborator

I've now updated Moonshine to use the latest Groovy language server. I was able to find a hacky way to create a Grails project in Moonshine, and a quick test gave me working code intelligence. Would be good to have it tested in a real-world project, though.

Moonshine-IDE/Moonshine-IDE@cca7359

@JoelProminic
Copy link
Author

@joshtynjala, did you do some manual configuration to make Grails use Groovy 4? From what I see, the latest version of Grails (5.1.1) supports Groovy 3.0.7, and this is the built-in version. You can check this at $GRAILS_HOME/lib/org.codehaus.groovy/groovy/

I did some tests with Grails 5.1.1 and 3.3.10 (latest officially supported version for Moonshine), and the language server worked the same as the previous version (tested with Moonshine 3.3.0).

@joshtynjala
Copy link
Collaborator

@JoelProminic No, I didn't change anything related to Grails in Moonshine. I should note that Groovy 4 is compiled into the language server, and there's no way to tell the language server to use any different version of Groovy for code intelligence. For reference, I skipped Groovy 3, and I jumped from 2 to 4, because 3 had some issues that would have broken features of the language server that had been working with 2, but those issues were resolved in 4.

With this in mind, when you build your project in Moonshine, the compilation process might be using a different version of Groovy, depending on how your project is configured. You might see some differences in errors/warnings that the language server reports in the Problems view versus what the compiler reports in the Console view. For instance, the language server will not complain about new Groovy 4 syntax, but if your project is configured to use Groovy 2/3, the build will fail because it won't understand the newer syntax.

I should add that the internal APIs of Groovy have changed between 2, 3, and 4. If using Groovy 4 in the language server is an issue, the best workaround is probably to compile multiple, separate Groovy language servers, each with a different version of Groovy. I would need to maintain multiple subprojects to abstract away the differences between Groovy internal APIs. Not ideal, but possible, if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants