gem_in_a_jar, as found here:
http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar/
cannot be used in rails unless the gems are specified in bundler's Gemfile, this might make no sense but it will...
For this example we will arbitrarily use the time-warp gem
Now we have our 'Gem in a jar' via tw-gem.jar.
Consider the following script (tw-test.rb):
We will launch this script via tw_test_backtick.rb:
Here is the result:
So our gem in a jar worked!
Now let us put this code into a rails app:
In rails root we will place tw-gem.jar and tw-test.rb, and then in RAILS_ROOT/config/initializers we create runbackticks.rb as follows:
Next we start up WEBrick:
In rails it fails to find the appropriate 'gem in a jar' even though it is invoked via back ticks (remember the 'gem in a jar' is in rails root)!
The only (awful) fix I can find is to modify the 'Gemfile' and add the line " gem 'time-warp'" then run bundler's install as follows:
Now it works:
But it does not really work as I can make tw-gem.jar be of size zero, so it never really uses the jar.
In a nutshell I have no way to separate the dependencies of my jobs from those of my rails app which runs the jobs.
BTW if, in tw_test.rb, I change the require 'tw_gem.jar' to tw_gem2.jar it does complain about not finding the jar (from the rails app) so I know it is finding the jar.
|