I have a groovy script that I’m writing and I’m trying to [link to | include | reference] another groovy “library” that I’ve [written | downloaded].
I import the “library” at the top of my script:
But, when trying to run my script, it fails with an error:
W:\path_to_file\script.groovy: 9: unable to resolve class com.mycompany.SomeGroovyLib @ line 9, column 1. import com.mycompany.SomeGroovyLib ^
I’m using IntelliJ IDEA 2017.2.6 on Windows with groovy 2.4.6 but the same happens on earlier versions.
This is a simple one.
From the “File” menu , choose the “Project Structure…” menu item :
Then, from the “Project Structure” dialog, choose the “Modules” item in the left pane , then the “Dependencies” tab . Now choose the + symbol on the right hand side of the dialog  and choose the “1 JARs or directories…” option .
Now, navigate to the path of your groovy library such that the path of your import statement …:
…can be found immediately within the folder you select:
Finally, you will be prompted to choose what type of thing you’re linking to and you should select “Classes”:
Now you can “ok” your way back through the 2 dialogs and your project should build.