A version of this was originally posted to the Rawr mailing list, but it
obviously effects Monkebars as well.
I confess to not having done much with Monkeybars or Rawr for perhaps
close to a year. I was heads-down on a Web project, with little time
for other things, for almost two years.
At some point a year or so ago I did check some older Monkeybars apps,
which lead to some updates (I think) of Monkeybars and Rawr. In any
event, code seemed to work.
Recently there's been some renewed interest in Rawr and Monkeybars and
people have reported that even simple code does not work.
Basically, trying to assemble a bare-bones app gives a "File not found"
error.
I tried this myself and sure enough stuff is broken.
I started looking into it. Rawr works by providing a Main class as an
executable entry point for a jar of files. It figures out the name of
the main Ruby file (typically main.rb, but configurable) and does a
script eval to require that file, which should in turn handle running
the actual app.
This main file is generally in the "src/" folder, and this gets
correctly packaged up in the jar created by Rawr, but $LOAD_PATH knows
nothing about this. In fact, $LOAD_PATH is almost empty, save for some
main folders that are part of the JRuby jar.
The code for Main.java hasn't changed in some time, so this is either
something from JRuby 1.6.x or Java itself, but I believe it's a change
in how JRuby is managing jar contents and $LOAD_PATH.
If something knows more or something to the contrary please speak up.
I've been searching for information that explains how JRuby handles the
load path when you require a jar but have not found anything recent to
help clarify things.
In the meantime I started a local branch to explore a fix and have code
that does some additional parsing of build_configuration.rb to add the
contents of "source_dirs" to $LOAD_PATH. (Typically this is just "src/".)
That works, and should be sufficient, since if any other locations need
to be added to $LOAD_PATH that main ruby file can do that.
If this is *not* sufficient we'll see what else we need.
If anyone thinks it's hacky or something, please speak up (with some
explanation and, ideally, an alternative if possible).
I will push this code to the Github repo tonight or tomorrow morning and
we can see how well it works for everyone.
Meanwhile, in my explorations, I learned that JRuby allows you specify a
Ruby file to use as the main class file for an executable jar:
https://github.com/jruby/jruby/wiki/StandaloneJarsAndClasses
From the looks of this I think that Main.java can be tossed if Rawr
assumes that the main Ruby file is jar-bootstrap.rb
We can replace the Rawr-generated Main.java with a generated
jar-bootstrap.rb that simply hands off to whatever
build_configuration.rb says is the main Ruby file. jar-bootstrap.rb may
have to do $OAD_PATH prep as well.
I've not written any code to even begin to try this out.
Finally, after some E-mails and some pondering I've decided to drop
Pivotal Tracker in favor of Github Issues for both Rawr and Monkeybars
bug reports and such.
James Britt