-
-
Notifications
You must be signed in to change notification settings - Fork 68
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 plugin script cannot resolve IntelliJ and Live Plugin API classes #175
Comments
It seems as if this helps: But unfortunately, I have literally hundreds of projects in my workspace. Furthermore, whenever e.g. Maven is the leading build tool, each automatic or manual re-import resets the dependencies, i.e. I have to start over and re-add the IDE and plugin libraries over and over. Please advise me how to set this up in a better and more persistent way. Thank you. P.S.: I do not speak Kotlin, which is the reason why I chose Groovy. |
Not really. Groovy highlighting in the editor has always been a bit of a hack to make a point that it would be nice to have it. It seems like there are APIs in IntelliJ to achieve that but I never got around to figuring it out how to do that for Groovy (and I switched to using Kotlin a few years ago). You could create a separate project for your live plugin with all the dependencies and it will have syntax highlighting 🤔 Each live plugin is just a folder and you can find the path with the copy path action Or once the plugin becomes more established I sometimes create a "proper plugin" project with plugin.xml but still keep it reloadable via live plugin for faster feedback by adding plugin jar to live plugin classpath (https://github.com/dkandalov/live-plugin/blob/master/plugin-examples/groovy/additional-classpath/plugin.groovy). These suggestions break the promise of minimal setup for live plugins though 😕 |
Well, there is the next problem. Globbing does not work as advertised. This fails: // add-to-classpath $HOME/.m2/repository/org/mockito/mockito-core/3.3.3/mockito*.jar I only got the plugin working with the full path: // add-to-classpath $HOME/.m2/repository/org/mockito/mockito-core/3.3.3/mockito-core-3.3.3.jar |
Another issue is that the imports do not seem to work. I wanted to convert this Kotlin live plugin to Groovy and extend it, but some plugin classes are not found: Besides, the corresponding compilation stack trace with butchered line breaks is also not super beautiful:
P.S.: If you want separate issues for each of these problems, I understand. I was just in the middle of writing my first Groovy plugin, and all the mentioned problems are occurring in the same context, even though they are of course logically separate. And sorry again for not being a Kotlin person. I am sure, it would be worth the time to learn that interesting language. But not just for this plugin. |
Hm, this works fine for me, maybe it's broken on Windows 🤦
Agreed about butchered line breaks. Looking at the errors:
I would approach converting Kotlin plugin to Groovy by rewriting it in small incremental steps. I didn't really think about the case of converting Kotlin live plugin to Groovy 🤔 Ideally, LivePlugin APIs would be the same or very similar in both Groovy and Kotlin, but the Groovy one was first and I learned few things since then. Besides, LivePlugin API is a small wrapper around IntelliJ APIs which is quite big so it's impossible to cover it all and maintain it. The end goal would be to convince Jetbrains to maintain nice to use reloadable APIs (and some of them are!). |
Only, if you used platform-specific tools for implementing it, such as shell scripts.
Of course, this is exactly what I started to do. But it already failed at the very first step, importing classes from other plugins and resolving them, without even any active plugin code. Not knowing Kotlin, I did not notice that there obviously you do not need
Does that mean, Groovy support remains as-is and you are hinting me at switching to Kotlin, or are you going to adjust the Groovy part, making it comparable in its capabilities to the Kotlin ones? |
This comment was marked as resolved.
This comment was marked as resolved.
I wasn't hinting at switching to Kotlin 😅 Although my next plans for live plugin would be about integrating proper IDE runner, configurable compile and runtime classpaths, maybe built-in PSI viewer, object inspector, plugin reload while typing, etc. I haven't considered revisiting Groovy API, it's the first time anyone asked about it 🤔 |
Well, I love to write tests in Spock (or Geb, if they are web UI tests), therefore I know some Groovy. Using that language, I can get live plugin stuff done without learning a new language first. Comfort zone... |
This isn't Groovy specific. I installed LivePlugin today and it fails in the same way for both Kotlin and Groovy. For some reason the class path of the plugin isn't correct for the editor. For running it works fine! Clicking the "Add to project" menu item does not work to resolve this for some reason. It might be a regression in IntelliJ. After restarting the IDE a "apply script context" bar appeared and clicking it fixed the highlighting. |
@mikehearn What are the IDE and plugin versions? (because it works for me on two machines) |
This is IJ Ultimate, latest version, and LivePlugin was installed from the marketplace yesterday. So presumably it's the latest version. |
I just installed the plugin for the first time in IDEA 2023.3.6 Ultimate and opened the Groovy "hello world" example. I can successfully run the plugin, but in the editor it looks like this:
Is there anything else I need to configure?
The text was updated successfully, but these errors were encountered: