I'm able to make a jar/.exe/.app out of a simple script with Rawr, but
I can't seem to run one that uses a gem. It complains that it can't
find the gem at runtime. I've read
<
http://kenai.com/projects/monkeybars/pages/UseRubyGemsInYourApplication>
and tried to follow the instructions, but without success. Might
anyone be able to help?
I'm not sure if I should just paste my source files here, or use a
pastebin or something. The script is very short, but everything taken
together still requires scrolling. Please let me know how I should
post my code. Thanks.
All right, I'm just going to paste my code. It's possible no one
responded because no one here is that familiar with Rawr (or at least
its internals), but I might as well ask anyway.
My script runs just fine with Jruby. It uses the Barby (bar code
generator) gem, which I unpacked into lib/ruby. I renamed the unpacked
directory to just barby. Here is the script, main.rb:
require 'rubygems'
puts 'Load path:'
$LOAD_PATH.each { |dir| puts dir }
puts
require 'barby'
puts 'Hello, world.'
__END__
My build_configuration.rb is:
configuration do |c|
c.project_name = 'RawrTest'
c.output_dir = 'package'
c.main_ruby_file = 'main'
c.main_java_file = 'org.rubyforge.rawr.Main'
# Compile all Ruby and Java files recursively
# Copy all other files taking into account exclusion filter
c.source_dirs = ['src', 'lib/ruby']
c.source_exclude_filter = []
# Location of the jruby-complete.jar. Override this if your jar
lives elsewhere.
# This allows Rawr to make sure it uses a compatible jrubyc when compiling,
# so the class files are always compatible, regardless of your system JRuby.
#c.jruby_jar = 'lib/java/jruby-complete.jar'
c.compile_ruby_files = true # I have also tried setting this to false
#c.java_lib_files = []
c.java_lib_dirs = ['lib/java']
#c.files_to_copy = Dir['other_files/dir/**/*']
c.target_jvm_version = 1.5
#c.jars[:data] = { :directory => 'data/images', :location_in_jar =>
'images', :exclude => /bak/}
#c.jvm_arguments = "-server"
#c.java_library_path = "lib/java/native"
# Bundler options
# c.do_not_generate_plist = false
end
__END__
Finally, my src/manifest.rb:
Dir.glob(File.expand_path(File.dirname(__FILE__) +
'/**/*').gsub('%20', ' ')).each do |directory|
next if directory =~ /\/barby\//
$LOAD_PATH << directory unless directory =~ /\.\w+$/
#File.directory? is broken in current JRuby for dirs inside jars
end
# Not sure what to put in the middle of this file
require 'resolver' # I've also tried it without this
case Monkeybars::Resolver.run_location
when Monkeybars::Resolver::IN_FILE_SYSTEM
# assorted stuff omitted
when Monkeybars::Resolver::IN_JAR_FILE
add_to_load_path "barby/lib"
end
__END__
I believe all the other files in the directory are the ones created by
'rawr install'. When I run the program, my load path is listed, and
then there is an exception:
Exception in thread "main"
file:/Users/eric/Sources/RawrTest/package/jar/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require': no such file to load -- barby (LoadError)
from file:/Users/eric/Sources/RawrTest/package/jar/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from src/main.rb:7:in `require'
from <script>:1
...internal jruby stack elided...
from Kernel.require(file:/Users/eric/Sources/RawrTest/package/jar/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31)
from Kernel.require(src/main.rb:7)
from Kernel.require(<script>:1)
from (unknown).(unknown)
1)
Thanks in advance.