Pages

Sunday, December 30, 2012

CTR: resolving dependencies in Groovy with Grapes

+Mark Fortner commented on Google+ that my script was missing a @Grab statement. I had seen that mentioned before, but never looked at it. It turns out the be very useful, and it makes Groovy scripts standalone. That is, it will resolve the missing dependencies, using Maven repositories. Fortunately, CDK modules are available from repositories, e.g. the one at Plovdiv University, and I gave it a try. My first attempt went bad, but +Nina Jeliazkova explained me what Maven mistake I was making, and now I got a working setup:


@GrabResolver(
  name='idea',
  root='http://ambit.uni-plovdiv.bg:8083/nexus/content/repositories/thirdparty/'
)
@Grapes([
  @Grab(
    group='org.openscience.cdk',
    module='cdk-io', version='1.4.11'
  ),
  @Grab(
    group='org.openscience.cdk',
    module='cdk-silent', version='1.4.11' 
  )
])

So, depending on the exact script, something like the above will remove any need of setting CLASSPATHs. The above Groovy code is for counting heavy atoms.

2 comments:

  1. Nice, I've got a nightly (1.5.2-SNAPSHOT) maven build of master on the EBI snapshots repo which might be of use. I've swapped out some of the dependencies for more up to date ones (i.e. jena-rdf and jniinchi 0.8) but I've been using it without any issues for a while now.

    Snapshots Repo:
    http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo-snapshots/
    http://www.ebi.ac.uk/~maven/m2repo_snapshots (direct)

    Also reminds me I need to deploy 1.4.16 to the stables. I've got from 1.4.6+ on: http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/

    ReplyDelete
    Replies
    1. Oh, very nice! I think your mentioned that before and I should have remembered. Can you please add it to this wiki page?

      https://sourceforge.net/apps/mediawiki/cdk/index.php?title=Maven_repositories

      Delete