JRuby gem不可用,但JRuby仍然可以运行脚本

JRuby gem不可用,但JRuby仍然可以运行脚本,jruby,warbler,Jruby,Warbler,我正在使用ruby制作自己的日志监视器脚本,并使用Warbler使用JRuby将其编译成JAR。我正在运行JRuby 1.7.17 64位。当我运行脚本时,我尝试使用gem optparse,它与MRI和JRuby一起工作,如下所示: monitor_log>] jruby lib\monitor_log\log_watch.rb --help Usage: log_watch [options] -f, --file FILE Input fil

我正在使用ruby制作自己的日志监视器脚本,并使用Warbler使用JRuby将其编译成JAR。我正在运行JRuby 1.7.17 64位。当我运行脚本时,我尝试使用gem optparse,它与MRI和JRuby一起工作,如下所示:

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
所以我尝试使用JBundler运行它,看看JRuby是否会运行我的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
所以,然后我尝试使用Warbler运行它,将其编译成一个JAR。我得到:

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)
我想也许JRuby在默认情况下没有这个,所以我试着搜索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)
但我看不出什么明显的东西。有什么事情我做得不对吗?我将gem、optparse作为开发依赖项和运行时依赖项添加到.gempec中。我该不该这么做,还是我还缺什么

移除

spec.add_development_dependency "optparse"
spec.add_runtime_dependency "optparse"
完成了这个技巧,现在gem编译成一个可运行的JAR文件