require 'open-uri' RMQ_URI_BASE = 'http://www.rabbitmq.com/releases/rabbitmq-java-client' RMQV = '2.8.7' directory './tmp' file "./tmp/rabbitmq-java-client-bin-#{RMQV}.tar.gz" => ['./tmp'] do |f| puts "*** Downloading tarball" open("#{RMQ_URI_BASE}/v#{RMQV}/rabbitmq-java-client-bin-#{RMQV}.tar.gz") do |f| open('./tmp/rabbitmq-java-client-bin.tar.gz', 'w') do |out| out.write(f.read) end end end file "./tmp/rabbitmq-java-client-bin-#{RMQV}/rabbitmq-client.jar" => ["./tmp/rabbitmq-java-client-bin-#{RMQV}.tar.gz"] do puts "*** Extracting tarball" Dir.chdir('./tmp') do `tar xzvf rabbitmq-java-client-bin.tar.gz` puts "*** Extracted, exit code = #{$?}" end end file './lib/java/rabbitmq-client.jar' => ["./tmp/rabbitmq-java-client-bin-#{RMQV}/rabbitmq-client.jar"] do puts "*** Copying jars" Dir["./tmp/rabbitmq-java-client-bin-#{RMQV}/*.jar"].each do |jar| puts "*** Copying #{jar} to ./lib/java" FileUtils.cp(jar, './lib/java', :verbose => true) end end desc 'Download and copy over the rabbitmq client jar' task :rabbitmq_client_jar => ['./lib/java/rabbitmq-client.jar'] task :default => [:rabbitmq_client_jar]