As many Perl programmers know CPAN (the Comprehensive Perl Archive Network) is an invaluable repository for Perl modules. You can easily download and install a module and add its functionality to your script. In order for scripting languages like Groovy to gain some traction with the bioinformatics crowd there needs to be a similar repository for JARs. Fortunately for Groovy there’s no need to reinvent the wheel. We can use Groovy’s packaging system (called Grape) with the existing ibiblio, and java.net maven repositories, and you can even use your local maven repository.
To install a module on your local system you simply type: grape install
where group is the maven group id for the module, and module is the name of the module you want to install. To figure out the group and module IDs you can visit the mvnrepository site.
Suppose you want to install the Lucene search engine library so that you can index some papers that you’ve downloaded. You enter grape install org.apache.lucene lucene-core and the module is downloaded and installed locally.
This is nice if you know the dependencies, but what if you want to share your script with a colleague, how do you insure that all of the dependencies are downloaded? You can use the @Grab annotation within your script. This way, every time your script is run it resolves the dependencies prior to executing your script. The snippet below shows all the code that you need to add to your script.
@Grab(group=’org.apache.lucene’, module=’lucene-core’, version=’3.0.0′)
// lucene code goes here
NOTE: The BioJava 3 wiki page gives you an idea of the types of modules that are currently being developed.