This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Rakefile
91 lines (74 loc) · 2.29 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# encoding: utf-8
require 'ant'
namespace :build do
source_dir = 'ext/src'
build_dir = 'ext/build'
ruby_dir = 'lib'
task :setup do
mkdir_p build_dir
ant.path :id => 'compile.class.path' do
pathelement :location => File.join(ENV['MY_RUBY_HOME'], 'lib', 'jruby.jar')
File.foreach(File.expand_path('../.classpath', __FILE__)) do |path|
pathelement :location => path.chop!
end
end
end
task :compile => :setup do
ant.javac :destdir => build_dir, :includeantruntime => 'no', :target => '1.6', :source => '1.6', :debug => 'on' do
classpath :refid => 'compile.class.path'
src { pathelement :location => source_dir }
end
end
task :jars => :compile do
ant.jar :destfile => 'lib/rubydoop.jar', :basedir => build_dir, :includes => '**/*.class'
end
task :clean do
rm_rf build_dir
rm Dir['lib/rubydoop*.jar']
end
end
desc 'Build the lib/rubydoop.jar'
task :build => 'build:jars'
namespace :setup do
task :hadoop do
hadoop_release = ENV['HADOOP_RELEASE'] || 'hadoop-1.0.3/hadoop-1.0.3-bin'
hadoop_url = "http://archive.apache.org/dist/hadoop/common/#{hadoop_release}.tar.gz"
FileUtils.mkdir_p('tmp')
Dir.chdir('tmp') do
command = (<<-END).lines.map(&:strip).join(' && ')
rm -fr hadoop*
curl --progress-bar -O '#{hadoop_url}'
tar xf hadoop*.tar.gz
END
system(command)
end
end
task :test_project do
Dir.chdir('spec/resources/test_project') do
Bundler.clean_system('bundle install --retry 3 --path ../../../vendor/test_project-bundle --binstubs .bundle/bin')
end
end
task :classpath do
File.open('.classpath', 'w') do |io|
hadoop_home = File.expand_path(File.dirname(Dir["tmp/hadoop*/bin"].first))
%x(#{hadoop_home}/bin/hadoop classpath).chomp.split(':').each do |pattern|
Dir[pattern].each do |path|
io.puts(path)
end
end
end
end
end
desc 'Download Hadoop and set up classpath'
task :setup => ['setup:hadoop', 'setup:test_project', 'setup:classpath']
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |r|
r.rspec_opts = '--tty'
end
task :spec => :build
require 'bundler'
namespace :gem do
Bundler::GemHelper.install_tasks
end
desc 'Release a new gem version'
task :release => [:spec, 'gem:release']