123

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?

Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46

5 Answers5

160

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

Ricky Sixx
  • 581
  • 1
  • 10
  • 25
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 6
    Sdkman (http://sdkman.io) makes it really simple to install groovy and switch versions (at the command line at least) – tim_yates Sep 09 '17 at 08:53
  • 4
    The `libexec` subdirectory did contain the standard layout. Thank you so much! – Carl Patenaude Poulin Sep 11 '17 at 12:59
  • 2
    for some reason IDEA did not recognise the `/usr/local/opt/groovy/libexec` directory when installed with brew, neither with SDKMAN, just only downloaded and and unpacked (version 2018.1.4) – DimaSan Jun 04 '18 at 22:43
  • 1
    `/usr/local/opt/groovy/libexec` works for me with a brew installed groovy on Mac OS. – Philipp Paland Sep 16 '18 at 09:28
  • 25
    Intellij for Mac OS does not allow navigation to `/usr/local/opt/groovy/libexec`. One need to navigate to groovy dir using Cmd + Shift + G. Homebrew version is working for me. – haltTm Nov 03 '18 at 02:48
  • flawless answer @CrazyCoder – Gaurav Dec 02 '20 at 07:34
  • I followed these instructions but I get the error "no candidates found for method call" on all the groovy commands like "pipeline", "environment", etc in my groovy scripts. – Ken Roy Sep 20 '21 at 13:32
  • I get the "Error: library is not specified" error, and when I select the Use LIbrary option and click on the Create Button, I get the colored wheel on Mac. Is there a command-line setup, there must be – kamal Jan 20 '22 at 21:38
  • Can you clarify "specify this directory as the library home"? Where is that configuration? – Paulo Merson Mar 24 '23 at 14:34
23

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
user79493
  • 331
  • 2
  • 2
16

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.

Tony Qin
  • 191
  • 1
  • 5
  • 1
    Otherwise, you cannot see the hidden folder /usr/... and there is no way to select or search the folder name 'libexec'. – Tony Qin Feb 10 '19 at 22:32
4

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

buddemat
  • 4,552
  • 14
  • 29
  • 49
mpechner
  • 139
  • 7
3
  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.