jrubywarbler

JRuby gem not available, but JRuby can still run the script


I'm making my own log monitor script using ruby, and compiling it with JRuby into a JAR using Warbler. I'm running JRuby 1.7.17 64bit. I'm trying to use the gem optparse, which works with MRI, and JRuby, when I run the script like:

monitor_log>] jruby lib\monitor_log\log_watch.rb --help
Usage: log_watch [options]
    -f, --file FILE                  Input file to monitor
    -p, --pattern PATTERN            Pattern to match in the file
    -h, --help                       Show this screen

So I attempted to run it using JBundler to see if JRuby would run my gem,

monitor_log>] jbundle exec jruby bin/log_watch.rb --help
Usage: log_watch [options]
    -f, --file FILE                  Input file to monitor
    -p, --pattern PATTERN            Pattern to match in the file
    -h, --help                       Show this screen

So, then I attempted to run this using Warbler to compile it into a JAR. and I get:

monitor_log>] warble executable jar
warble aborted!
Bundler::GemNotFound: Could not find gem 'optparse (>= 0) java' in the gems available on this machine.
c:\Ruby\jruby-1.7.17\bin\warble:23:in `(root)'
(See full trace by running task with --trace)

I thought that maybe JRuby didn't have this by default, so I tried so search for the gem,

monitor_log>] jruby -S gem search optparse
*** REMOTE GEMS ***

micro-optparse (1.2.0)
optparse-command (0.1.8)
optparse-defaults (0.1.0)
optparse-lite (0.0.0)
optparse-off (0.0.1)
optparse-pathname (0.0.1)
optparse-range (0.0.3)
optparse-simple (0.4.2)
optparse_ex (0.0.4)
pickled_optparse (0.1.1)
remi-optparse-simple (0.1.0)
rubysl-optparse (2.0.1)
subcommand-optparse (0.0.3)

but nothing real obvious stood out to me. Is there something I'm not doing correctly? I added the gem, optparse to the .gemspec as a development dependency, and a runtime dependency. Should I not do that or is there something else I'm missing?


Solution

  • Removing the

    spec.add_development_dependency "optparse"
    spec.add_runtime_dependency "optparse"
    

    did the trick and now the gem compiles into a runnable JAR file.