-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
68 lines (57 loc) · 2.43 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
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/rdoctask'
require 'fileutils'
CLEAN.include("bin/**/*")
#TODO: Get jruby-core
lib_path = "lib"
desc "Compile the Java source into class files"
#I've a feeling that this won't be DRY very quickly. We should work on making it so.
task "javac" do |t|
#compiling all the files (ultimately want to check file times to build only the ones we are interested in?)
puts "Compiling Util" if RakeFileUtils.verbose_flag
dest_path = "bin"
Dir.mkdir "#{dest_path}" unless File.exist? "#{dest_path}"
build_path = ["src/java"]
files = build_path.collect do |path|
Dir.glob("#{path}/**/*.java")
end
dependencies = ["wrapper.jar", "jruby-complete.jar", "args4j-2.0.9.jar", "junit-4.4.jar"]
cp = Array.new
dependencies.each do |dependency|
cp << "#{lib_path}/#{dependency}"
end
puts "javac -classpath \"#{cp.join(File::PATH_SEPARATOR)}\" -sourcepath \"#{build_path.join(File::PATH_SEPARATOR)}\" -d #{dest_path} #{files.join(' ')}" if RakeFileUtils.verbose_flag
`javac -classpath "#{cp.join(File::PATH_SEPARATOR)}" -sourcepath "#{build_path.join(File::PATH_SEPARATOR)}" -d #{dest_path} #{files.join(' ')}`
unless $?.exitstatus == 0
puts "Build failed on #{t.name}, see above errors."
exit -1
end
end
desc "Create utilities jar file"
task "jar" => "javac" do |t|
puts "Building util.jar" if RakeFileUtils.verbose_flag
classes = "bin"
#TODO: handle versioning and handle creating a manifest from a manifest file.
jarname = "util"
`jar cf #{classes}/#{jarname}.jar -C #{classes} .`
unless $?.exitstatus == 0
puts "Build failed on #{t.name}"
exit -1
end
end
desc "Copy the jar and ruby files to the bin folder"
#TODO: get us to pass the jarname from the previous task (the dependent one.) FIXME to work
task "deploy" => "jar" do |t|
puts "copying jar and ruby files to #{lib_path}" if RakeFileUtils.verbose_flag
jarname = "util.jar"
dest_name = "#{lib_path}"
deploy_ruby = true
Dir.mkdir "#{dest_name}/ruby" unless File.exist? "#{dest_name}/ruby"
Dir.mkdir "#{dest_name}/ruby/service" unless File.exist? "#{dest_name}/ruby/service"
FileUtils.cp_r "src/ruby/.", "#{dest_name}/ruby/service", :remove_destination => true
FileUtils.cp "bin/util.jar", "#{dest_name}/util.jar"
end