Running a JRuby Script With Maven

Hi 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 B.


View this message in context:
http://www.nabble.com/Running-a-JRuby-Script-With-Maven-tp24261672p24261672.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

For 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. :stuck_out_tongue:

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
dependencieshttp://www.leonardoborges.com/writings/2009/07/01/jruby-on-rails-and-legacy-java-apps-managing-dependencies/

Regards,
Leonardo Borges