How to configure new Groovy SDK
I am using IntelliJ 11.1.3 and there doesn't seem to be any intuitive way to configure a new Groovy SDK. So let's say I download a new version of Groovy and want to create an SDK so I can assign it to my project. How do I do this?
There also seems to be a huge usuability issue with adding a Groovy SDK to an exising project. For example, if I want to add Groovy support to an exising java project. There doesn't seem any intuitive way to do this.
The only way I found to add groovy to an existing project is to create a new File then give it a .groovy extension. At that point IntelliJ does helpfully offer to configure a SDK (with the option to create a new one with a different version). How could I add the SDK without having to give a file the .groovy extension though?
I would think going to Project Structure->SDK's would be it. But that only offers to create Java, Android, or IntelliJ SDK's. Likewise Global Libraries only offers Java and JavaScript libraries. Creating a Groovy library there doesn't give the ability to create Groovy Scripts/Classes via the New menu (right-click context menu)
The whole adding Groovy SDK's and adding Groovy to an existing project really needs some usability work.
Please sign in to leave a comment.
Remove the existing Groovy library you have now in the module dependencies and in the global libraries, then add a new library:
Thanks for that pointer! That is quite helpful.
IMHO, you should be able to configure a new Groovy SDK in the same place I add a Java SDK. That seems to be the most intuitive place, at least to me, to look for it.
And what is the way to change the groovy SDK version for the project once it has been set?
I concur with the frustration expressed by many above having landed here after spending more than an hour trying to add a Groovy test class to a Java project - IntelliJ config usability is very poor indeed imho.
Hi Michael,
I accept your feedback. Thank you!
To add Groovy support to a module open 'Project' toolwindow, invoke context menu on the module, and click 'Add framework support...'
--
Max Medvedev
JetBrains, Inc
"Develop with pleasure!"
Add your new Groovy version as a global library
File->Project Structure->Global Libraries,
Then on the modules section of Project Structure click the dependency tab, then add the global library as a dependency (and remove the previous one). Click the + sign then Library->Global Library.
Thank you :)
Is there a way to change groovy compiler ?
This is not working at all, I found 3 different ways to add Groovy SDK
and it still keeps ignoring it.
I have under "Global Libraries" a "groovy-2.4.13" and if I add under
"Modules" a Framework "Groovy" the dropdown list is empty, showing
"No library selected". If I use the "Create" button and re-add the SDK,
it will be displayed under "Dependencies" but still the dropdown list is empty,
the "Build" says "Cannot compile GRoovy files: no Groovy library is defined"...
Even using the Hint "Configure Groovy SDK..." shows again an empty
dropdown list, and using Create has absolutley no effect at all.
I feel IntellJ has a lot of bugs, especially with Groovy, also with Cucumber but
that's another chapter. Every IDE can do Java, you should be able to do more
with such a pricey product!
I have really no Idea how to change Groovy SDK on existing project....
Please submit a ticket via https://intellij-support.jetbrains.com/hc/requests/new and attach a sample project to reproduce this issue.
In 2018.3 there is no Groovy Framework to select (on an existing groovy project). There is also no global library option for Groovy.
You probably already have Groovy library in the module dependencies, please double check: https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#working-with-module-dependencies.
Indeed I do, but this subject is about changing the Groovy version. To do it you need to add a *java* library for the new Groovy version i.e.
Simple really ;-)
Removing the existing library and adding a new one via the framework support like described in the previous answer seems to be a bit easier than what you suggest:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206224119/comments/360000152759
You mean the UI is: remove the module dependency on groovy so you get the option of adding framework support for groovy where you can then add a new library at which point it removes the add framework support option? I, and it seems others above, would never have guessed that as a workflow. We don't want to remove framework support for Groovy, we want to change the version of Groovy.
This is still an issue and the mechanics are so flawed. If I get the option in a dialog about a non-configured groovy to set a library that contains groovy, why is it not accepting my selection. This issue is no 7 years old and still exists. Usability is zero on this, I even had to restart my IDE... in 2019, Ultimate indeed -.-
Alex, this thread is about changing the version of the existing library, not adding a missing library. If you have issues with that, please file a bug at https://youtrack.jetbrains.com/issues/IDEA and provide the steps to reproduce the problem, attach a sample project.
The process of these operations is indeed cumbersome and not intuitive enough.
However, in the search engine can quickly find this post and solve the problem, this is still good.
I agree this issue is pretty ridiculous considering it was first reported 11 years ago and is still mystifying users. Even after reading this entire thread I still couldn't figure out how to get IntelliJ to let me add groovy as an external lib. Finally I looked at the config files in another project where it was already working properly and found a way to do it. So, without further ado, the easiest way I've found to add/change groovy in my projects is to drop a new config file into the .idea/libraries folder, such as this one:
Filename: groovy_3_0_9.xml
Then open your project structure settings, (File-->Project Structure), click the Libraries tab and you should see your missing groovy lib listed there in red. Click on it and then select "change version". It should list the available groovy versions. If your version is not already selected, select it, then click "ok". It will download the libs to your $PROJECT_DIR/lib/ directory and you should be good to go.
Another vote for making this workflow more intutive. :-)
Intellij Idea Ultimate 2024.1 doesn't have the option “Add framework support...”. Also when I try to add a global library, I click on the "+" and the only options I have are Java, From Mave, Scala, and Kotlin. How to add Groovy? I have a Java project that also has some groovy code, and Java classes cannot resolve groovy classes in the same module/project
Marc, you can always add specific Groovy libraries from Maven, but the other option is to use the New Project wizard to create your Groovy project (File > New > Project). It will let you specify a build system and Groovy SDK, and optionally also add boilerplate code to it:
Thank you Arina for the reply. I don't need to create a new project, I already have a project. The solution was to configure the folder with groovy code as sources, then all groovy classes could be resolved.