Adding other paths to LOAD_PATH in nogemspec trait
Hi, I'm using warbler to build a jar for a standalone application (thus, nogemspec) and I'd like to have other paths (apart from lib/) to be included in the $LOAD_PATH.
The trait "Warbler::Traits::NoGemspec", doesn't have any configuration to include other paths than lib/. I'm thinking of making a pull request that adds it, but I'd like some insight if you are interested in the feature and if you have any preference for the config name.
Thanks!
This sounds like exactly what I am looking for! I need to add a 'components' directory to $LOAD_PATH. I would be interested in your fork. Thanks
Hi, we monkeypatched Warbler::Traits::NoGemspec
I'm not completely sure if this works with newer versions of warbler or newer versions of jruby, but this is what our patch looks like:
## Make warbler include jars in loadpath
# https://github.com/jruby/warbler/issues/111
require 'warbler/traits/nogemspec'
class Warbler::Traits::NoGemspec
def after_configure
add_init_load_path(config.pathmaps.application.inject("lib") {|pm,x| pm.pathmap(x)})
add_init_load_path(config.pathmaps.application.inject("jars") {|pm,x| pm.pathmap(x)})
end
end
Sorry I can't be of any more help, the issue it's a bit old and I don't remember much of the whole problem.
Thanks for feedback! I was a little confused earlier in that I am working with a Rails 3.0.20 app and the traits that are executed for me are:
- Warbler::Traits::War
- Warbler::Traits::Rails
- Warbler::Traits::Bundler (so no "nogemspec" trait execution)
I was able to get my app running under jetty (executable war) by modifying the $LOAD_PATH directly in application.rb:
$LOAD_PATH.unshift(Rails.root)
I am thinking this is sort of a hack. It seems like you should be able to add this path directly from your warble.rb or Gemfile? Perhaps this is what the "Bundler 'path' components" are suppose to enable (line 65-73 in traits/bundler.rb)?