112
votes

I am running IntelliJ IDEA 2017.2.3. I installed Groovy 2.4.12 via Homebrew (OS X). When I open a Groovy source file (or a Jenkinsfile), I get the following:

Groovy SDK is not configured for module 'my-module' . . . . . Configure Groovy SDK...

Clicking "Configure Groovy SDK..." leads me to the following dialog:

Error: library is not specified

I tried hitting "Create..." and selecting many different Groovy-related folders and executables, but nothing works.

How can I get IntelliJ IDEA to accept my Groovy SDK?

5

5 Answers

148
votes

IntelliJ IDEA expects the standard Groovy SDK layout which is provided with the official distributions available at https://groovy.apache.org/download.html. Just download, unpack into any directory, specify this directory as the library home.

Homebrew package layout may be different, however it may have the standard layout in the libexec subdirectory in some cases. Try /usr/local/opt/groovy/libexec (use Cmd + Shift + G to navigate to it).

22
votes

Another suggestion to add to this solution here described in MAC OS you can also add symbolic link in Library. This will make it easy to select it within IntelliJ:

sudo ln -s /usr/local/opt/groovy/libexec /Library/Groovy
13
votes

This first answer it excellent, but not sufficient. The hidden folder in Mac blocked me one more day. On Mac system, you can press Cmd + Shift + G to invoke the input dialog and input "/usr/local/opt/groovy/libexec" directly to resolve the issue that you cannot find the lib folder.

4
votes

CrazyCoder gave the correct hints. But some of us use brew as our standard.

brew install groovysdk

In intellij when you get the dialog, as stated by haltTim, Cmd + Shift + G

Navigate to /usr/local/opt/groovysdk/libexec or the cellar path /usr/local/Cellar/groovysdk/???/libexec

2
votes
  1. From the main menu select File | Project Structure ⌘;.
  2. In the Project Structure dialog, under Platform Settings, select Global Libraries. Image depicting the Intellij environment

Select Global Libraries, if nothing is there, click on add(+) icon at the top.

Then a small dialog box will appear, Select "from Maven", then another dialog box as shown below appears, iamge showing dialog box

Type in Groovy, then several options will pop up, select an option which has groovy:groovy-all and version 2.4.1(change version according to your need) and click ok. then apply and ok,

After this go to the same dialog box, of Configure SDK and select from drop-down.