How to configure new Groovy SDK

Answered

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.

16 comments
Comment actions Permalink

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!"

0
Comment actions Permalink

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.

2
Comment actions Permalink

And what is the way to change the groovy SDK version for the project once it has been set?

0
Comment actions Permalink

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.

 

 

1
Comment actions Permalink

I have really no Idea how to change Groovy SDK on existing project.... 

0
Comment actions Permalink

Remove the existing Groovy library you have now in the module dependencies and in the global libraries, then add a new library:

1
Comment actions Permalink

Thank you :)

Is there a way to change groovy compiler ?

0
Comment actions Permalink

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!

 

0
Comment actions Permalink

Please submit a ticket via https://intellij-support.jetbrains.com/hc/requests/new and attach a sample project to reproduce this issue.

0
Comment actions Permalink

In 2018.3 there is no Groovy Framework to select (on an existing groovy project). There is also no global library option for Groovy.

 

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

  1. File -> Project Structure -> Global Libraries -> + Java
  2. Point it at ~/.sdkman/candidates/groovy/2.5.6
  3. *then add* ~/.sdkman/candidates/groovy/2.5.6/lib to that library using the + at the top (this makes it understand this is Groovy) because it doesn't auto import the classes
  4. -> OK
  5. back in to Project Structure -> Modules
  6. Remove old groovy-2.4.x and add Library groovy-2.5.6
  7. -> OK
  8. *Close and re-open IDE*

Simple really ;-)

0
Comment actions Permalink

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

0
Comment actions Permalink

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.

0
Comment actions Permalink

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 -.-

0
Comment actions Permalink

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.

0

Please sign in to leave a comment.