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?
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:
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.
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.