warbler icon indicating copy to clipboard operation
warbler copied to clipboard

warble compiled war only compile .rb files under ./lib

Open southwolf opened this issue 9 years ago • 7 comments

I have a rack app contains config.ru, app.rb, but warble won't compile app.rb unless I put it under /lib. Is this a bug or a feature? Some rack based frameworks, like Cuba, also puts .rb files under project root( Sample App ), how can I use it with Warbler?

environment: jruby 9.0.1.0, warbler 2.0.0.rc1, cuba 3.4.0 Thank you!

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27541765-warble-compiled-war-only-compile-rb-files-under-lib?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).

southwolf avatar Oct 20 '15 06:10 southwolf

Really not sure, as I've used warble for the first time 10 minutes ago, but I would say, use a gemspec file. Check out the readme.

If your project has a .gemspec file in the top directory, it will be used to configure the project's dependencies, launcher script, require paths, and the files to be included in the archive. For best results make sure your gemspec specifies all of the following attributes:

  • executables
  • require_paths
  • runtime dependencies added with add_dependency

If your project do not have a .gemspec, Warbler will attempt to guess the launcher from the contents of the bin directory and use the lib directory as the lone require path. All files in the project will be included in the archive.

niuage avatar Oct 22 '15 04:10 niuage

Thank you @niuage for the reply. In this repo https://github.com/southwolf/invoice_verification/tree/f7f3d196d77b7f62b716c34d87708811439709ad

I put an app.rb under project root, configured config/warble.rb

config.includes = FileList["app.rb"]
config.compiled_ruby_files = FileList["**/*.rb"]

Warbler compiled app.rb, but didn't put into the .war file. I got no such file to load - app.class error. If I remove config.compiled_ruby_files = FileList["**/*.rb"], the app.rb will not even get compiled.

southwolf avatar Oct 23 '15 09:10 southwolf

It's weird because the default of compiled_ruby_files is to compile all the .rb of the app.

I personally got it SOMEWHAT working with just this:

Releasy::Project.new do
  name "My Application"
  version "1.3.2"
  verbose # Can be removed if you don't want to see all build messages.

  executable "main.rb"
  files ["lib/**/*.rb", "config/**/*.yml"]
  exposed_files "README.md"
  add_link "http://my_application.github.com", "My Application website"
  exclude_encoding

  add_build :windows_wrapped do
    wrapper "wrappers/ruby-1.9.3-p0-i386-mingw32.7z" # Assuming this is where you downloaded this file.
    executable_type :windows # Assuming you don't want it to run with a console window.
    add_package :zip
  end

  add_deploy :local # Only deploy locally.
end

I say "somewhat" because it runs on mac, in the folder I created the jar only. I moved on and I'm gonna build my app with Electron personally.

niuage avatar Oct 23 '15 14:10 niuage

Can you include the app.class manually by putting it in the config.includes

jkutner avatar Oct 31 '15 20:10 jkutner

@jkutner Thank you for the reply, that works.

config.includes = FileList["app.class"]
config.compiled_ruby_files = FileList["*.rb"]

southwolf avatar Nov 01 '15 06:11 southwolf

@jkutner But is that a feature or a bug that warble ignores *.rb under project root by default?

southwolf avatar Nov 01 '15 06:11 southwolf

~ same as https://github.com/jruby/warbler/issues/216 there's no standard way of knowing what is used from a config.ru for plain Rack apps. thus Warbler can not guess what to compile. there's a simple convention of using lib/*.rb beyond that not much that can be done.

kares avatar Aug 12 '16 10:08 kares