Here at work I’m trying to push Groovy as the standard scripting language to replace Perl.
The only thing that bothers me about Groovy is that the classpath that has to be setup. This almost always forces me to setup a wrapper bash script to call most of my groovy scripts. Ick!
The groovy grapes @grab annotation sounds promising but I do not have access to a Maven repository nor am I likely at this point get management approval to go through the exercise to set one up.
Is it possible to set up grapes to read from the file system?
If anyone has done something like this I’d be interested to know how you went about it.
Here is a more concrete example
We use an oracle database. To access this database we have to add ojdbc6.jar (ships with Oracle 11g client) to the classpath.
Is there a way to use grape such that I can grab that jar instead of mucking with the classpath manually?
I know I can put a symlink in ~/.groovy/lib to where the file is (which I have done and it does work) but this now means that ojdbc6 will be in the classpath for all of my groovy scripts. I’m not sure that this is such a good idea.
I’m not sure what the grab would look like but maybe something like …
@Grab(group='com.oracle, module=jdbc', version='???')Is this possible?
Well, if what your describing trades a –cp switch with a –D I might give up on Grape.
Also, the documentation you refer not very extensive and the link to Ivy documentaion is broken.
I suppose I’ll start doing some google searches on ivy too see what I can come up with.
If you need to change the directory grape uses for downloading libraries you can specify the grape.root system property to change the default (which is ~/.groovy/grape)
//TODO expand on discussion of grapeConfig.xml
You can customize the ivy settings that Grape uses by creating a ~/.groovy/grapeConfig.xml file. If no such file exists, here are the default settings used by Grape:
For more information on how to customize these settings, please refer to the Ivy documentation.
mvn install:install-file -Dfile=classes12_g.jar -DgroupId=com.oracle \ -DartifactId=oracle -Dversion=10.2.0.2.0 -Dpackaging=jar -DgeneratePom=true
Well, if what your describing trades a –cp switch with a –D I might give up on Grape.
Also, the documentation you refer not very extensive and the link to Ivy documentaion is broken.
On Tue, Sep 6, 2011 at 5:40 PM, Nelson, Erick [HDS] <Erick....@hdsupply.com> wrote:
Here is a more concrete example
We use an oracle database. To access this database we have to add ojdbc6.jar (ships with Oracle 11g client) to the classpath.
Is there a way to use grape such that I can grab that jar instead of mucking with the classpath manually?
If I sounded like I was whining, I apologize.
As far as Maven is concerned, I’ve tried to convince, multiple times. The answer is always no, which is unfortunate and short sighted. I’ve even tried to make the case that it would probably improve our build process here on our Websphere Commerce app. Unless I can justify it as another line item in a future approved Capitalized project there will be no maven for me at this organization. They are very strict here about adding what they see as a “new technology”.
As to your suggestions below, thank you. I installed a local maven repository on my development box, and with your notes below it worked like a charm except I had to add a grape config so that it could properly load the oracle jdbc driver. I found the details on that tidbit here http://mrhaki.blogspot.com/2010/04/groovy-goodness-configuring-grape-to.html . I’m not quite sure I understand it, but it works. (Now, back to the maven docs to learn what all your –D switches really did…..)
@Grab('com.oracle:oracle:11.2.0.1.0')
@GrabConfig(systemClassLoader = true)
Question: the default grapesConfig.xml pointed to by the groovy docs page found here http://svn.codehaus.org/groovy/tags/GROOVY_1_6_0/src/main/groovy/grape/defaultGrapeConfig.xml has the following section in it.
<filesystem name="cachedGrapes"> <ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/> <artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/> </filesystem>
This section does not seem to be necessary as my code works with or without it. What is its purpose?
From: Brian Schlining
[mailto:bschl...@gmail.com]
Sent: Tuesday, September 06, 2011
9:09 PM
To: us...@groovy.codehaus.org
Subject: Re: [groovy-user] groovy
grapes (@grab) without Maven ?
Cripes, quit whinging.
There's also a "zero technology" solution. You don't strictly need maven software, just a http based site with a maven repo structure. I'm assuming that something like apache has been approved for you.
Question: the default grapesConfig.xml pointed to by the groovy docs page found here http://svn.codehaus.org/groovy/tags/GROOVY_1_6_0/src/main/groovy/grape/defaultGrapeConfig.xml has the following section in it.
<filesystem name="cachedGrapes"><ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/><artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/></filesystem>This section does not seem to be necessary as my code works with or without it. What is its purpose?