I downloaded the 1.5 version of Jruby today, and was eager to try out
the
new Ant integration. I found Charles Nutter’s “Ivy and Ant” tutorial
(http://blog.headius.com/2010/04/using-ivy-with-jruby-15s-ant.html), and
tried running the Rakefile that downloads and installs Ivy. Here’s what
I
have in my Rakefile:
require ‘ant’
namespace :ivy do
ivy_install_version = ‘2.0.0-beta1’
ivy_jar_dir = ‘./ivy’
ivy_jar_file = “#{ivy_jar_dir}/ivy.jar”
task :download do
mkdir_p ivy_jar_dir
ant.get :src =>
“http://repo1.maven.org/maven2/org/apache/ivy/ivy/#{ivy_install_version}/ivy-#{ivy_install_version}.jar”,
:dest => ivy_jar_file,
:usetimestamp => true
end
task :install => :download do
ant.path :id => ‘ivy.lib.path’ do
fileset :dir => ivy_jar_dir, :includes => ‘*.jar’
end
ant.taskdef :resource => "org/apache/ivy/ant/antlib.xml",
#:uri => "antlib:org.apache.ivy.ant",
:classpathref => "ivy.lib.path"
end
end
I then tried executing the rakefile using the following commands:
c:> cd ivtytest
c:\ivytest> C:\td\apps\ruby-1.5.0\bin\jruby -S rake ivy:download
(in C:/td/apps/jruby-1.5.0/bin/test)
mkdir -p ./ivy
java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/AntMain
java/lang/ClassLoader.java:-2:in defineClass1' java/lang/ClassLoader.java:632:in
defineClassCond’
java/lang/ClassLoader.java:616:in defineClass' java/security/SecureClassLoader.java:141:in
defineClass’
java/net/URLClassLoader.java:283:in defineClass' java/net/URLClassLoader.java:58:in
access$000’
java/net/URLClassLoader.java:197:in run' java/security/AccessController.java:-2:in
doPrivileged’
java/net/URLClassLoader.java:190:in findClass' java/lang/ClassLoader.java:307:in
loadClass’
sun/misc/Launcher.java:301:in loadClass' java/lang/ClassLoader.java:248:in
loadClass’
org/apache/tools/ant/Project.java:308:in initProperties' org/apache/tools/ant/Project.java:295:in
init’
(eval):1:in create_project' c:/td/apps/jruby-1.5.0/lib/ruby/site_ruby/shared/ant/ant.rb:122:in
tap’
c:/td/apps/jruby-1.5.0/lib/ruby/site_ruby/shared/ant/ant.rb:122:in
create_proje ct' c:/td/apps/jruby-1.5.0/lib/ruby/site_ruby/shared/ant/ant.rb:17:in
initialize’
c:/td/apps/jruby-1.5.0/lib/ruby/site_ruby/shared/ant/ant.rb:167:in new' c:/td/apps/jruby-1.5.0/lib/ruby/site_ruby/shared/ant/ant.rb:167:in
ant’
c:/td/apps/jruby-1.5.0/lib/ruby/site_ruby/shared/ant/ant.rb:200:in ant' C:/td/apps/jruby-1.5.0/bin/test/Rakefile:10 c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
cal
l’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
exe cute' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
eac
h’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
exe cute' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
inv
oke_with_call_chain’
c:/td/apps/jruby-1.5.0/lib/ruby/1.8/monitor.rb:191:in mon_synchronize' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
inv
oke_with_call_chain’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
inv oke' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
in
voke_task’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
to p_level' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
ea
ch’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
to p_level' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
st
andard_exception_handling’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
to p_level' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
ru
n’
c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
st andard_exception_handling' c:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
ru
n’
C:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/td/apps/jruby-1.5.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in
load' c:/td/apps/jruby-1.5.0/bin/rake:19 rake aborted! undefined method
get’ for nil:NilClass
From what I can gather, it appears that I’m using the wrong version of
Ant. Here’s what’s in my classpath:
c:\td\apps\apache-ant-1.7.1\lib\ant.jar
…and here’s what I get for a version:
Apache Ant version 1.7.1 compiled on June 27 2008
Is the issue my version of Ant? If so, then what version should I use?
Thanks!
Tom Purl