warbler icon indicating copy to clipboard operation
warbler copied to clipboard

Generating a compiled war does not compile all controller files

Open brentsowers1 opened this issue 12 years ago • 8 comments

When I run "warble compiled war", .class files are not being generated for some of my controllers. I have 10 controller .rb files, and only 3 .class files are being generated. The .rb files for these controllers that don't have a .class are identical to the other .rb files, just a require to load the .class.

The behavior is consistent, it is always the same 7 controller files that do not have .class files in the WAR. And, running just "warble compiled" generates the same .class files, only 3 in controllers when there should be 10.

An unmodified scaffold controller will not have an associated .class file, so that's an easy way to reproduce this. I'm running JRuby 1.6.5 in 1.9 mode, and Rails 3.1.3.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1446664-generating-a-compiled-war-does-not-compile-all-controller-files?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).

brentsowers1 avatar Jan 17 '12 22:01 brentsowers1

Are you able to give a list of your app/controllers directory, on disk and inside the war after warble compiled war? Do you have anything custom related to compiled files in config/warble.rb?

nicksieger avatar Jan 17 '12 22:01 nicksieger

Here is the directory listing of the apps/controllers directory on disk. jrubies_controller is the pure scaffold controller.

application_controller.rb  oauth_clients_controller.rb  products_controller.rb      subscription_controller.rb
home_controller.rb         oauth_controller.rb          sessions_controller.rb

And here are the contents of the WEB-INF/app/controllers directory after extracting the WAR file locally:

application_controller.class  jrubies_controller.rb        products_controller.rb      subscription_controller.rb
application_controller.rb     oauth_clients_controller.rb  sessions_controller.class
home_controller.class         oauth_controller.rb          sessions_controller.rb

The only change I made to config/warble.rb was to add these lines:

config.dirs = %w(app config lib log vendor tmp script db/migrate)

config.includes = FileList["Rakefile"]

config.webxml.jruby.compat.version = "1.9"

I ran warble compiled war:debug, and I see this in the output, so it looks like it is attempting to compile these:

  pending_add: []
  exclude_patterns:
- !ruby/regexp '/(^|[\/\])CVS([\/\]|$)/'
- !ruby/regexp '/(^|[\/\]).svn([\/\]|$)/'
- !ruby/regexp '/.bak$/'
- !ruby/regexp '/~$/'
  exclude_procs:
- *10802
  items:
- app/controllers/oauth_controller.rb
- app/controllers/settings_controller.rb
- app/controllers/oauth_logins_controller.rb
- app/controllers/sessions_controller.rb
- app/controllers/subscription_controller.rb
- app/controllers/application_controller.rb
- app/controllers/home_controller.rb
- app/controllers/jrubies_controller.rb
- app/controllers/accounts_controller.rb
- app/controllers/oauth_clients_controller.rb
- app/controllers/products_controller.rb
  ...
  trait_objects:
  ...
  WEB-INF/app/controllers/oauth_controller.rb -> <blob>
  WEB-INF/app/controllers/settings_controller.rb -> <blob>
  WEB-INF/app/controllers/oauth_logins_controller.rb -> <blob>
  WEB-INF/app/controllers/sessions_controller.rb -> <blob>
  WEB-INF/app/controllers/subscription_controller.rb -> <blob>
  WEB-INF/app/controllers/application_controller.rb -> <blob>
  WEB-INF/app/controllers/home_controller.rb -> <blob>
  WEB-INF/app/controllers/jrubies_controller.rb -> <blob>
  WEB-INF/app/controllers/accounts_controller.rb -> <blob>
  WEB-INF/app/controllers/oauth_clients_controller.rb -> <blob>
  WEB-INF/app/controllers/products_controller.rb -> <blob>
  ...

brentsowers1 avatar Jan 17 '12 22:01 brentsowers1

Was this issue ever resolved? I am running into the same problem where only a small percentage of my ruby files are getting compiled to .class files when I run "wable compiled" or "warble compiled war". The same files get compiled each time, so it's repeatable, but I have no idea why it compiles some files and not others. My environment is: Warbler version 1.3.5 jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]

Any ideas? Thanks in advance!

mockaroo avatar May 11 '12 15:05 mockaroo

I did some digging and I think the problem has to do with support for ruby 1.9. Ruby files that use the new 1.9 hash syntax {foo: "bar"} instead of the old way {:foo => "bar"} won't result in .class files. For example, the following works:

class SomeFoosController < ApplicationController
  def update
    respond_to do |format|
        format.html { redirect_to 'somwhere', :notice => 'some notice' }
    end
  end
end

but the following doesn't:

class SomeFoosController < ApplicationController
  def update
    respond_to do |format|
        format.html { redirect_to 'somwhere', notice: 'some notice' }
    end
  end
end

It should be noted that I have

config.webxml.jruby.compat.version = "1.9"

in my config/warble.rb

I hope this helps.

mockaroo avatar May 12 '12 06:05 mockaroo

Thanks for figuring out what causes this behavior mvbrocato, I can at least get around the problem now.

brentsowers1 avatar May 12 '12 14:05 brentsowers1

I figured out a fix: if you change your run_javac method in jar.rb to the following, 1.9 sources compile fine:

def run_javac(config, compiled_ruby_files)
  # Need to use the version of JRuby in the application to compile it
  config.webxml.jruby.compat.version ||= "1.8"
  %x{java -classpath #{config.java_libs.join(File::PATH_SEPARATOR)} org.jruby.Main --#{config.webxml.jruby.compat.version} -S jrubyc \"#{compiled_ruby_files.join('" "')}\"}
end

It looks like config.webxml.jruby.compat.version was not being passed on to jrubyc. Nick, do you think you could check in a patch for this? I'm kind of a newb to Github otherwise I'd do it myself.

Thanks guys, hope this helps!

mockaroo avatar May 15 '12 04:05 mockaroo

Thanks for that @mvbrocato. Yeah, in fact Warbler needs to be updated to be able to target/specify the app running in 1.9 mode across the board. I'll see if we can at least get this fix in sooner than later.

nicksieger avatar May 15 '12 16:05 nicksieger

There is a pull request with the fix https://github.com/jruby/warbler/pull/90 Works for us

vanyak avatar May 16 '12 00:05 vanyak