|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Running a JRuby Script With MavenHi all. I'm using JRuby as a scripting language to call on Java libraries such as Apache Tika to do various kinds of work. I'd like to use Maven to run these JRuby scripts because I'd like it to take care of finding jar file dependencies, and adding them to the classpath from the Maven repository.
I've found some info online, but it seems to be fancy stuff like how to build a JRuby plugin or how to set up a scripting interface in a Java 6 app. I just want to run a JRuby script. I know I'll need to set up the jar file dependencies in the pom.xml file, but that's trivial to do. Can someone help me with this? It would be very greatly appreciated. Alternatively, is there some way I can use Maven's dependency management to generate a list of jar filespecs that I can use as a classpath in a command line script? I know I can call "mvn dependency:resolve" and get output such as this that I could parse: [INFO] [dependency:resolve] [INFO] [INFO] The following files have been resolved: [INFO] asm:asm:jar:2.2.3:runtime [INFO] asm:asm-commons:jar:2.2.3:runtime [INFO] asm:asm-tree:jar:2.2.3:runtime [INFO] backport-util-concurrent:backport-util-concurrent:jar:3.0:runtime [INFO] classworlds:classworlds:jar:1.1-alpha-2:compile [INFO] jline:jline:jar:0.9.91:runtime [INFO] junit:junit:jar:3.8.1:compile [INFO] org.apache.maven:maven-artifact:jar:2.0.4:compile [INFO] org.apache.maven:maven-artifact-manager:jar:2.0.4:compile ...but if there's an easier way that would be nice. Thanks for any help, - Keith Bennett |
|
|
Re: Running a JRuby Script With MavenFor some time now I was planning on writing a blog post that might answer your questions. I was just lazy about it in the past weeks. :P
There I explain how we tackled the problem of managing dependencies in a JRuby/Java/Maven environment. Hope it's useful for you. Here's the link: JRuby on Rails and legacy java apps: Managing dependencies Regards, Leonardo Borges www.leonardoborges.com On Mon, Jun 29, 2009 at 11:38 PM, Keith R. Bennett <kbennett@...> wrote:
|
|
|
Re: Running a JRuby Script With MavenLeonardo -
Thanks for providing that, but I don't know how I would modify it to suit my needs. I've thought about it more, and here is a restatement of my needs that will hopefully be clearer: I'm looking to find or write a plugin that would drive JRuby scripts with a specified set of jar file dependencies. The scripts would merely be arguments to the Maven command, and don't even need to be in the project tree. Here's what I'd like this plugin to do: * calculate transitive dependencies * download them if necessary * build a command line with the classpath, "java -jar ...jruby.jar", and any arguments passed to the Maven command * run that command Although it is not a clean fit with Maven's usual use pattern, I don't know of any tools other than Maven that can do anywhere as good a job at downloading dependencies and storing them in one central location. Everything I need to do is already done by Maven; I just don't know how to isolate those behaviors and tie them together. It could be run something like this: mvn run-jruby my-script.rb arg1 arg2 All scripts run using this Maven project would share the same set of jar file dependencies. I don't see this as a big problem, as I'm envisioning using them for system administration tasks that would probably share the same dependencies anyway. It would be nice if there were a variant to just output the generated command too; this way, if the script were run many times, the repository would not be checked each time. Regards, Keith |
|
|
Re: Running a JRuby Script With MavenOn Sun, Jul 12, 2009 at 9:23 PM, keithrbennett<keithrbennett@...> wrote:
> > Leonardo - > > Thanks for providing that, but I don't know how I would modify > it to suit my needs. I've thought about it more, and here is a > restatement of my needs that will hopefully be clearer: > > I'm looking to find or write a plugin that would drive JRuby > scripts with a specified set of jar file dependencies. > > The scripts would merely be arguments to the Maven command, and > don't even need to be in the project tree. Here's what I'd like > this plugin to do: > > * calculate transitive dependencies > > * download them if necessary > > * build a command line with the classpath, "java -jar > ...jruby.jar", and any arguments passed to the Maven command > > * run that command We have a jruby-rake-plugin that should be able to do this. You can either look in JRuby's source repository for maven/jruby-rake-plugin for inspiration to build your own or you can use as-is. Try this in your pom.xml plugins section: <plugin> <groupId>org.jruby.plugins</groupId> <artifactId>jruby-rake-plugin</artifactId> <version>1.3.1</version> <executions> <execution> <id>my-custom-script</id> <phase>generate-resources</phase> <goals><goal>rake</goal></goals> <configuration> <script> task :default do # load or write your script here end </script> </configuration> </execution> </executions> <dependencies> <!-- your dependent jars here --> </dependencies> </plugin> This should run JRuby with the provided dependencies available on the classpath when the script launches. /Nick --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Running a JRuby Script With MavenNick -
Thanks very much for that information. I look forward to checking it out. Keep up the great work! - Keith |
| Free embeddable forum powered by Nabble | Forum Help |