[jruby] How to integrate local GEMs, when running from a ScriptingContainer?

christian m.kristian at web.de
Tue Jan 12 19:12:38 JST 2016


this generate_dir_info creates directory info file .jrubydir for each
directory. some classloaders do not allow to list directories or better
they do not give me jar-url to resource which JRuby can use to list the
directory. so probably your application works without those extra .jrubydir
files but in case to want to deploy on an OSGi container then you would
need those.

just realized that it is high time to grab this conversation and make a
wiki on the jruby.org site on this topic :)


On Tue, Jan 12, 2016 at 11:00 AM, <changepoint_advi.fischer at extaccount.com>

> > From: JRuby [mailto:jruby-bounces at ruby-lang.org] On Behalf Of christian
> > jruby -S gem install GEMNAME --install-dir .
> > jruby -r jruby/commands -e JRuby::Commands.generate_dir_info ./gems
> > jruby -r jruby/commands -e JRuby::Commands.generate_dir_info
> ./specifications
> >
> > jar cvfm app.jar ..... gems specifications
> > then use IsolatedScriptingContainer which will set GEM_HOME and GEM_PATH
> to uri:classloader:/ that is where the gems are found inside the jar. no
> need to set it manually.
> > - christian
> Hi Christian,
> thanks for the explanation. In short - it basically works, after a few
> trivial modifications.
> As you said, IsolatedScriptingContainer makes the use of GEM_HOME/GEM_PATH
> unnecessary.  One difference between my setup and yours (and which turned
> out was the cause of most headache) was, that you used the project
> directory for installing the gems (--install-dir .), while I was putting
> them into a subdirectory (--install-dir gem), because I didn't want the
> directories 'specifications', 'cache' etc. to show up into our top level
> project directory. However, this requires to use a trick, when putting the
> gem into a jar: I can't simply include 'gem', nor 'gem/gems', into the jar.
> Even with an IsolatedScriptingContainer, the gems would not be found.
> Instead, I have to use
>     jar ..... -C gem gems -C gem specification
> From my understanding, the -C gem flag "lifts" the gem directories one
> level up inside the jar file, and this seems to be necessary for the gems
> to be located.
> I have also included the JRuby::Commands.generate_dir_info  commands,
> actually in a slightly different forms (you forgot the quote characters):
>     jruby -r jruby/commands -e "JRuby::Commands.generate_dir_info
> 'gem/gems'"
>     jruby -r jruby/commands -e "JRuby::Commands.generate_dir_info
> 'gem/specifications'"
> I just wonder, why these are necessary. I googled for generate_dir_info,
> but didn't find anything which would explain, what this command does and
> why it is necessary here. Could you enlighten me in this respect?
> Ronald
> If you are not the addressee, please inform us immediately that you have
> received this e-mail by mistake, and delete it. We thank you for your
> support.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ruby-lang.org/pipermail/jruby/attachments/20160112/5c879345/attachment.html>

More information about the JRuby mailing list