I Just struggled a bit with Groovy, I don’t like too much layers on the programming language I use but using Groovy seemed necessary at this moment. So in case you were wondering what complaint I have to this, well it is that Groovy runs on the JVM(Java Virtual Machine), but in my opinion this is useless, since we can (in theory) as well write Java byte code and run it on the JVM (Why don’t we run our own java byte code??). But anyways, my tip today came up to me when I tried to use external jar libraries for a project. Apparently there are several ways to do this:
- First and most basic is, as it is Java byte code. Add the jars into the classpath.
- The second one is using -cp or -classpath on the groovy call and add your on lib folder as parameter.
- The third one is: Use a unique groovy folder for all the needed libraries, by adding the directory ~.groovy/lib and put in there any jar you might want to use.
- The fourth and most interesting is Grape, (which is a dependency manager like Maven for Groovy),
For the ones interested I used third option which is the more simple and fast. But I highly recommend you use Grape, in the case you feel adventurous and you start developing whole projects with Groovy.