forked from zpasal/hbase-gui-admin
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.rb
64 lines (47 loc) · 1.48 KB
/
build.rb
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
# run java tool, build class files if not exist
# Usage:
# - # ruby run.rb [classname]
require 'find'
require 'fileutils'
$src_dir = 'src'
$lib_dir = 'lib'
$bin_dir = 'bin'
$tar_name = ARGV[0]
$tmp_dir = 'tmp'
$binlib_dir = 'bin/lib'
def get_file_list(dir, type)
file_list = []
Find.find(dir) { |file|
file_list << file if file =~ /\.#{type}$/
}
return file_list
end
def exec_cmd(cmd)
puts cmd
system cmd
end
def main_class_name
return File.basename(File.expand_path(File.dirname(__FILE__)))
#return "main";
end
def main_class_file_exists?
main_class_file = "#{$tmp_dir}/#{main_class_name}.class"
File.exists?(main_class_file)
end
exec_cmd "rm -rf ./#{$bin_dir}/*"
exec_cmd "rm -rf ./#{$tmp_dir}/*"
exec_cmd "mkdir -p ./#{$binlib_dir}/"
exec_cmd "mkdir -p ./#{$tmp_dir}/classes/"
exec_cmd "cp -r ./#{$lib_dir}/* ./#{$binlib_dir}/"
$classpath_jar = get_file_list($binlib_dir, 'jar').join(':')
$classpath_src = $src_dir
$classpath_bin = $bin_dir
exec_cmd "cp -r src/META-INF ./tmp/classes/"
if !main_class_file_exists?
$source_files = get_file_list($src_dir,'java')
exec_cmd "javac -encoding UTF-8 -d #{$tmp_dir}/classes -classpath #{$classpath_jar} #{$source_files.join(' ')}"
end
#exec_cmd "java -classpath #{$classpath_jar}:#{$classpath_bin} main.main #{ARGV.join(' ')}"
#build a jar
#exec_cmd "jar -cvf ./#{$bin_dir}/#{$tar_name}.jar -C ./build/classes ."
#exec_cmd "jar -mcf MANIFEST.MF ./bin/TestS.jar -C ./#{$tmp_dir}/classes ."