When running a script that is using grape system to @Grab a dependency in the ibiblio repo, it fails till I manually call grape resolve
from the command line. After that, it's in the local cache and the script runs fine.
Is there some other annotation that I need to use to get it to work the first time from the script? It feels kludgy to tell users to first "grape resolve" and then @Grab works.
This is the script, grabbing the jedis jar for redis:
#!/usr/bin/env groovy
@Grab('redis.clients:jedis:2.0.0')
import redis.clients.jedis.*
Jedis redis = new Jedis("localhost")
Which fails with this exception if I have a clean ~/.groovy/grapes cache:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: redis.clients#jedis;2.0.0: ibiblio: unable to get resource for redis/clients#jedis;2.0.0: res=/redis/clients/jedis/2.0.0/jedis-2.0.0.pom: java.net.MalformedURLException: no protocol: /redis/clients/jedis/2.0.0/jedis-2.0.0.pom]
It only runs once I execute grape resolve
manually from the command line:
grape -V resolve redis.clients jedis 2.0.0
(part of the output shows it's downloading from ibiblio):
...
ibiblio: found md file for redis.clients#jedis;2.0.0
=> http://repo1.maven.org/maven2/redis/clients/jedis/2.0.0/jedis-2.0.0.pom (2.0.0)
downloading http://repo1.maven.org/maven2/redis/clients/jedis/2.0.0/jedis-2.0.0.pom ...
ibiblio: downloading http://repo1.maven.org/maven2/redis/clients/jedis/2.0.0/jedis-2.0.0.pom
ibiblio: downloading http://repo1.maven.org/maven2/redis/clients/jedis/2.0.0/jedis-2.0.0.pom.sha1
sha1 OK for http://repo1.maven.org/maven2/redis/clients/jedis/2.0.0/jedis-2.0.0.pom
[SUCCESSFUL ] redis.clients#jedis;2.0.0!jedis.pom(pom.original) (1184ms)
...
After it's in the local cache, the script works fine with @Grab.
I have not manually added a ~/.groovy/grapeConfig.xml file so it's using the default one that comes with groovy. I'm using groovy 1.8:
groovy -v
Groovy Version: 1.8.0 JVM: 1.6.0_24
I tried adding this manually above the grab:
@GrabResolver(name='ibiblio', m2Compatible='true', root='http://repo1.maven.org/maven2/')
but that didn't help. Am I missing something?