Warbler without jruby-core.jar and jruby-stdlib.jar

I am trying to build a library jar without embedding the jruby-jars
within the resulting jar. This library will be used in a web
application that already has jruby-complete.jar on the classpath, so I
don’t want it also included in this jar.

There was an older post indicating this could be accomplished using the
following configuration setting:
config.java_libs.reject! {|jar| jar =~ /jruby-(complete|core|stdlib)/}

The problem is that I am also telling warbler to compile the .rb files:
config.features = %w(compiled)

The solution to excluding the jruby jars only seems to work when the
compiled feature is not used. When the compiled feature is enabled, the
following error is reported:

C:\projects\RedbridgeExample>c:\jruby\jruby-1.6.5\bin\jruby -S warble
jar
Unrecognized option: -S
Could not create the Java virtual machine.
rm -f redbridge-example.jar
Creating redbridge-example.jar
rm -f lib/my_example.class lib/helpers/my_helper.class
lib/models/my_class.class

Warbler does go on to build the jar, but the .class files were never
generated, so they are missing. Are there other configuration settings
that I may have missed?

Jack

So, there’s no configuration option for this, but you could
monkey-patch Warbler::Jar#run_javac to add the external jruby jars in
the classpath during the compile. Here’s the source:

def run_javac(config, compiled_ruby_files)
  %x{java -classpath

#{config.java_libs.join(File::PATH_SEPARATOR)} org.jruby.Main -S
jrubyc “#{compiled_ruby_files.join(’” “’)}”}
end

You could put that in config/warble.rb as follows, right above
“Warbler::Config.new do |config”:

module Warbler
class Jar
def run_javac(config, compiled_ruby_files)
# dupe the above command but set your own classpath
end
end
end

/Nick

If I patch the jar.rb file directly in the warbler gem with that code it
works as expected.

Adding the code to the warble.rb configuration file breaks warbler
though, and it won’t run. Here is the stacktrace:

C:\projects\RedbridgeExample>c:\jruby\jruby-1.6.5\bin\jruby -S warble
jar --trace
warble aborted!
uninitialized constant Warbler::Task::Warbler::Config
org/jruby/RubyModule.java:2590:in const_missing' c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2503:inconst_missing’
(eval):20:in initialize' org/jruby/RubyKernel.java:1088:ineval’
c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/warbler-1.3.2/lib/warbler/task.rb:46:in
initialize' c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/warbler-1.3.2/lib/warbler/application.rb:27:inload_rakefile’
c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in
run' c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling’
c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
run' c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/warbler-1.3.2/lib/warbler/application.rb:70:inrun’
c:/jruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/warbler-1.3.2/bin/warble:11:in
(root)' org/jruby/RubyKernel.java:1063:inload’
c:/jruby/jruby-1.6.5/bin/warble:19:in `(root)’

C:\projects\RedbridgeExample>

Christian MICHON wrote in post #1031842:

On Fri, Nov 11, 2011 at 11:42 PM, Jack B.
[email protected]wrote:

config.features = %w(compiled)
Creating redbridge-example.jar
Posted via http://www.ruby-forum.com/.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I would not do it this way. I would rather do this instead:

1/ Do not change your configuration file to exclude the jar files.
2/ Build the war files as you used to (especially the compilation part,
which is usually hard to get done right)
3/ Then either manually remove the jar files from the war using 7-zip,
or
create a jruby script using ‘zip/zip’ to perform the removal
4/ Test
5/ deploy

I used this procedure when I included jruby*jar, my gems and my jdbc
connectors in tomcat/lib (I was using a manual approach for point 3).

Warbler is fine if you build/test/deploy 1 war, but if you’ve 10+ web
apps
to deploy, in a DRY approach you should add the jars to tomcat/lib.

Don’t get me wrong: warbler is truly a great product.

I’d rather not rely on a manual process to remove the jar files.
Eventually somebody will forget to do this step.

It sounds like the appropriate action is to create a Rake task for my
application that will first call warbler to build the application jar,
then use zip/zip to remove the unwanted jruby-jars from the resulting
application jar.

On Fri, Nov 11, 2011 at 11:42 PM, Jack B.
[email protected]wrote:

config.features = %w(compiled)
Creating redbridge-example.jar
Posted via http://www.ruby-forum.com/.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I would not do it this way. I would rather do this instead:

1/ Do not change your configuration file to exclude the jar files.
2/ Build the war files as you used to (especially the compilation part,
which is usually hard to get done right)
3/ Then either manually remove the jar files from the war using 7-zip,
or
create a jruby script using ‘zip/zip’ to perform the removal
4/ Test
5/ deploy

I used this procedure when I included jruby*jar, my gems and my jdbc
connectors in tomcat/lib (I was using a manual approach for point 3).

Warbler is fine if you build/test/deploy 1 war, but if you’ve 10+ web
apps
to deploy, in a DRY approach you should add the jars to tomcat/lib.

Don’t get me wrong: warbler is truly a great product.