JRuby 1.5 Integrates Maven and Ant
JRuby 1.5 Integrates Maven and Ant
Join the DZone community and get the full member experience.Join For Free
Take 60 minutes to understand the Power of the Actor Model with "Designing Reactive Systems: The Role Of Actors In Distributed Architecture". Brought to you in partnership with Lightbend.
To find out how fast or slow JRuby 1.5 is loading Gems or libraries, run this script:
jruby -b -J-Djruby.debug.loadService.timing=true -e "require 'rubygems'"You'll get output like this:
#>jruby -b -J-Djruby.debug.loadService.timing=true script\server
<- builtin/core_ext/symbol - 35ms
<- enumerator - 6ms
<- rubygems/defaults - 5ms
<- thread - 7ms
<- etc - 5ms
<- rbconfig - 7ms
<- rubygems/exceptions - 5ms
<- rubygems/requirement - 6ms
Next, if you want to find out what libraries JRuby requires or where it loads them, you can run this:
jruby -J-Djruby.debug.loadService=true -e "require 'yaml'"and get output like this:
jruby -J-Djruby.debug.loadService=true -e "require 'yaml'"
LoadService: trying builtinLib: builtin/core_ext/symbol.class
LoadService: trying builtinLib: builtin/core_ext/symbol.rb
LoadService: trying resourceFromLoadPath: D:/work/jruby-dev/jruby/lib/ruby/site_ruby/1.8/builtin/core_ext/symbol.class
LoadService: trying resourceFromLoadPath: D:/work/jruby-dev/jruby/lib/ruby/site_ruby/1.8/builtin/core_ext/symbol.rb
LoadService: trying resourceFromLoadPath: D:/work/jruby-dev/jruby/lib/ruby/site_ruby/shared/builtin/core_ext/symbol.class
LoadService: trying resourceFromLoadPath: D:/work/jruby-dev/jruby/lib/ruby/site_ruby/shared/builtin/core_ext/symbol.rb
LoadService: found: file:/D:/work/jruby-dev/jruby/lib/ruby/site_ruby/shared/builtin/core_ext/symbol.rb
LoadService: trying builtinLib: enumerator.class
LoadService: trying builtinLib: enumerator.rb
LoadService: trying resourceFromLoadPath: D:/work/jruby-dev/jruby/lib/ruby/site_ruby/1.8/enumerator.class
LoadService: trying resourceFromLoadPath: D:/work/jruby-dev/jruby/lib/ruby/site_ruby/1.8/enumerator.rb
Also, if you're having any issues when launching JRuby on Windows, you can try running jruby.exe -Xtrace output.log and look at the extensive log output in the output.log file.
Ant and Rake
While JRuby 1.5 has implemented tighter integration with Apache Ant, the JRuby developers have also developed a seamless, two-way integration between Rake and Ant. This basically means you can mix and match the tools in the same project. Java developers who struggle with Ant's minimal support for imperative programming constructs will perhaps find comfort in Rake's cleaner syntax and full imperative programming environment.
Ruby developers using Rake will find the Ant integration to be helpful for performing common Java tasks since Rake doesn't have many standardized cross-platform tasks like Ant. Ant will also create build.xml files so that you can use software like NetBeans, which needs such a file. You can essentially harness the strengths of each tool. In Rake, Ant can be invoked and Ant targets can be called as Rake tasks. Importing an Ant buildfile makes its targets available to Rake as tasks, allowing Rake users to interact with Ant buildfiles and their dependent systems.
Here's a blog post showing how to use Apache Ivy with JRuby 1.5's Ant integration.
With some help from Sonatype, JRuby 1.5 has achieved full RubyGems integration with every single Maven artifact. Users of JRuby 1.5 will get access to around 60k additional libraries with this new feature. Any Java library ever published into the public Maven repository can be installed as Gems (or used for dependencies) in JRuby 1.5.
The JRuby team pulled this off with Sonatype by creating a Maven server that looks like a standard Gem repository to JRuby. With this change, many Java libraries are as easy to use as Ruby libraries in JRuby. As companies continue to use JRuby for retail websites and airline refueling applications, the language will become increasingly lucrative to enterprise developers.
Opinions expressed by DZone contributors are their own.