forked from mirah/dubious
/
dubious_tasks.rb
97 lines (82 loc) · 2.85 KB
/
dubious_tasks.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
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
92
93
94
95
96
97
require 'mirah/appengine_tasks'
# sets mirah compile opts
# @param [Hash] opts
# @option opts [String] :dest_path
# @option opts [Array<String>] :source_paths
# @option opts [Array<String>] :compiler_options commandline style options
def mirah_compile_options opts
Mirah.dest_paths << opts[:dest_path]
Mirah.source_paths.push *opts[:source_paths]
Mirah.compiler_options.push *opts[:compiler_options]
end
if JRUBY_VERSION < "1.5.6"
def mirahc *files
if files[-1].kind_of?(Hash)
options = files.pop
else
options = {}
end
source_dir = options.fetch(:dir, Mirah.source_path)
dest = File.expand_path(options.fetch(:dest, Mirah.dest_path))
files = files.map {|f| f.sub(/^#{source_dir}\//, '')}
flags = options.fetch(:options, Mirah.compiler_options)
args = ['-d', dest, *flags] + files
chdir(source_dir) do
cmd = "mirahc #{args.join ' '}"
puts cmd
if files.any? {|f|f.include? 'controllers'}
system cmd
else
Mirah.compile(*args)
Mirah.reset
end
end
end
end
SERVLET_JAR = File.join(AppEngine::SDK::SDK_ROOT, *%w{lib shared servlet-api.jar})
unless $CLASSPATH.include? SERVLET_JAR
$CLASSPATH << SERVLET_JAR
end
CLASSPATH = [SERVLET_JAR, AppEngine::SDK::API_JAR].join(":")
MIRAH_HOME = ENV['MIRAH_HOME'] ? ENV['MIRAH_HOME'] : Gem.find_files('mirah').first.sub(/lib\/mirah.rb/,'')
MODEL_SRC_JAR = File.join(MIRAH_HOME, 'examples', 'appengine', 'war',
'WEB-INF', 'lib', 'dubydatastore.jar')
#there is an upload task in appengine_tasks, but I couldn't get it to work
desc "publish to appengine"
task :publish => 'compile:app' do
sh "appcfg.sh update ."
end
desc "run development server"
task :server
task :default => :server
task :generate_build_properties do
def git_data(dir, file='')
returning = nil
chdir dir do
# ["commit abc....123", "2010-06-23 12:58:06 -0700"]
IO.popen("git rev-list --pretty=format:%ci -1 HEAD #{file}") do |f|
returning = [f.gets.chomp, f.gets.chomp]
end
end
returning
end
dubious_data = git_data(".")
mirah_data = git_data(MIRAH_HOME)
bite_data = git_data(MIRAH_HOME + '/../bitescript')
model_data = git_data(File.dirname(MODEL_SRC_JAR),File.basename(MODEL_SRC_JAR))
prop_file = "config/build.properties"
File.open(prop_file, 'w') do |f|
f.write <<-EOF
# the current build environment
application.build.time=#{Time.now.xmlschema}
dubious.version.commit=#{dubious_data[0][7..-1]}
dubious.version.time=#{Time.parse(dubious_data[1]).xmlschema}
mirah.version.commit=#{mirah_data[0][7..-1]}
mirah.version.time=#{Time.parse(mirah_data[1]).xmlschema}
bitescript.version.commit=#{bite_data[0][7..-1]}
bitescript.version.time=#{Time.parse(bite_data[1]).xmlschema}
model.version.commit=#{model_data[0][7..-1]}
model.version.time=#{Time.parse(model_data[1]).xmlschema}
EOF
end
end