-
Notifications
You must be signed in to change notification settings - Fork 13
/
Rakefile
152 lines (123 loc) · 4.59 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
require 'rubygems'
require 'rubygems/package_task'
require 'rake/clean'
require 'bundler/setup'
require 'rspec/core/rake_task'
Bundler.setup
begin
require 'ant'
rescue LoadError
puts 'This Rakefile requires JRuby. Please use jruby -S rake.'
exit 1
end
Gem::PackageTask.new Gem::Specification.load('dubious.gemspec') do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
RSpec::Core::RakeTask.new
task :default => :spec
require 'dubious_tasks'
OUTDIR = File.expand_path 'build'
SRCDIR = File.expand_path 'src'
CLEAN.include(OUTDIR)
CLOBBER.include("lib/dubious.jar", "javalib/mirahdatastore.jar")
def class_files_for files
files.map do |f|
explode = f.split('/')[1..-1]
explode.last.gsub!(/(^[a-z]|_[a-z])/) {|m|m.sub('_','').upcase}
explode.last.sub! /\.(duby|java|mirah)$/, '.class'
OUTDIR + '/' + explode.join('/')
end
end
LIB_MIRAH_SRC = Dir["src/**/*{.duby,.mirah}"]
LIB_JAVA_SRC = Dir["src/**/*.java"]
LIB_SRC = LIB_MIRAH_SRC + LIB_JAVA_SRC
LIB_CLASSES = class_files_for LIB_SRC
STDLIB_CLASSES= LIB_CLASSES.select{|l|l.include? 'stdlib'}
task :set_compile_options do
mirah_compile_options :compiler_options => ['--classpath', [OUTDIR+'/', SERVLET_JAR,*FileList["lib/*.jar", "javalib/*.jar"].map{|f|File.expand_path(f)}].join(':')],
:dest_path => OUTDIR,
:source_paths => SRCDIR
end
file "#{OUTDIR}/dubious/Inflection.class" => :'compile:java'
file "#{OUTDIR}/dubious/ScopedParameterMap.class" => :'compile:java'
file "#{OUTDIR}/dubious/ActionController.class" => ["#{OUTDIR}/dubious/Params.class",
"#{OUTDIR}/dubious/FormHelper.class",
"#{OUTDIR}/dubious/AssetTimestampsCache.class",
"#{OUTDIR}/dubious/CustomRoutes.class",
]
file "#{OUTDIR}/dubious/Inflections.class" => [
"#{OUTDIR}/dubious/TextHelper.class",
"#{OUTDIR}/dubious/Inflection.class"
]
file "#{OUTDIR}/dubious/TextHelper.class" => [
"#{OUTDIR}/dubious/Inflection.class",
]
file "#{OUTDIR}/dubious/FormHelper.class" => [
"#{OUTDIR}/dubious/Inflections.class",
"#{OUTDIR}/dubious/InstanceTag.class",
"#{OUTDIR}/dubious/Params.class",
"#{OUTDIR}/dubious/TimeConversion.class",
*STDLIB_CLASSES]
file "#{OUTDIR}/dubious/InstanceTag.class" => "#{OUTDIR}/dubious/SanitizeHelper.class"
file "#{OUTDIR}/dubious/Params.class" => "#{OUTDIR}/dubious/ScopedParameterMap.class"
file "lib/dubious.jar" => LIB_CLASSES do
includes = FileList[OUTDIR+'/dubious/**/*', OUTDIR+'/stdlib/**/*', OUTDIR + '/testing/**/*'].map {|d|d.sub "#{OUTDIR}/",''}.join(',')
ant.jar :destfile => "lib/dubious.jar",
:basedir => OUTDIR,
:includes => includes
end
desc "compiles mirah & java lib files"
task :compile => LIB_CLASSES
desc "compiles jar for gemification"
task :jar => "lib/dubious.jar"
desc "pull dependencies"
task :dependencies => 'javalib/mirahdatastore.jar'
directory 'javalib'
file 'javalib/mirahdatastore.jar' => 'javalib' do
cp Gem.find_files('mirahdatastore.jar'), 'javalib/'
end
namespace :compile do
task :dubious => "lib/dubious.jar"
task :java => OUTDIR do
ant.javac :srcdir => SRCDIR,
:destdir => OUTDIR,
:classpath => CLASSPATH,
:includeantruntime => true
end
end
directory OUTDIR
(LIB_CLASSES).zip(LIB_SRC).each do |klass,src|
file klass => [:dependencies, :set_compile_options, src]
end
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(Gem.find_files('mirahdatastore.jar')),'mirahdatastore.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