If the libraries are stored in the Maven repository, accessible where you want to run it, one solution would be to use Grape to grab the libraries.
This has several advantages:
- You do not need to worry about classpath at all
- You do not need to distribute libraries - just make sure Groovy is available on the client
- Libraries are downloaded only once, so even if you update the application, you only need to redistribute the
.groovy
file.
A simple example:
#!/usr/bin/env groovy @Grab(group='commons-io', module='commons-io', version='2.3') import org.apache.commons.io.FileUtils ... use FileUtils like normal ...
There are already many existing libraries at mvnrepository.com .
Even if you have non-public libraries, it is relatively easy to host your own libraries in a local / private repository .
source share