Created
March 22, 2011 21:13
-
-
Save jaydonnell/882081 to your computer and use it in GitHub Desktop.
using ant and ivy from rake with jruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ant' | |
def ivy_retrieve(org, mod, rev) | |
ant.retrieve :organisation => org, | |
:module => mod, | |
:revision => rev, | |
:pattern => 'javalib/[conf]/[artifact].[ext]', | |
:inline => true | |
end | |
artifacts = %w[ | |
junit junit 4.7 | |
] | |
build_dir = "classes" | |
file build_dir | |
task :setup => [build_dir, "ivy:install"] do | |
ant.property :name => "src.dir", :value => "src/main/java" | |
ant.path(:id => "project.class.path") do | |
pathelement :location => "classes" | |
end | |
artifacts.each_slice(3) do |*artifact| | |
puts artifact.count | |
puts artifact.class | |
ivy_retrieve(*artifact[0]) | |
end | |
end | |
task :compile => :setup do | |
mkdir_p build_dir | |
ant.javac(:destdir => build_dir) do | |
classpath :refid => "project.class.path" | |
src { pathelement :location => "${src.dir}" } | |
end | |
end | |
task :jar => :compile do | |
ant.jar :destfile => "urlverifier.jar", :basedir => build_dir | |
end | |
task :default => :jar | |
namespace :ivy do | |
ivy_install_version = '2.2.0' | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment