Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding other paths to LOAD_PATH in nogemspec trait #111

Open
jbarreneche opened this Issue Sep 12, 2012 · 3 comments

Comments

Projects
None yet
2 participants

jbarreneche commented Sep 12, 2012 edited by kares

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!

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1446642-adding-other-paths-to-load_path-in-nogemspec-trait?utm_campaign=plugin&utm_content=tracker%2F136961&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F136961&utm_medium=issues&utm_source=github).

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.

ryanrolland commented Jul 21, 2016 edited

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment