-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
executable file
·94 lines (76 loc) · 2.93 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
# callback_reflection.rb creates the interfaces.txt (JRuby can't do YAML with ruby 1.8, so it's just
# and inspect on the hash) on a device. Bring it off the device and put it in the callback_gen dir.
#
# Move this into a rake task later.
#
raise "Needs JRuby 1.5" unless RUBY_PLATFORM =~ /java/
require 'ant'
require 'rake/clean'
require 'rexml/document'
generated_libs = 'generated_libs'
jars = Dir['libs/*.jar']
stdlib = jars.grep(/stdlib/).first #libs/jruby-stdlib-VERSION.jar
jruby_jar = jars.grep(/core/).first #libs/jruby-core-VERSION.jar
stdlib_precompiled = File.join(generated_libs, 'jruby-stdlib-precompiled.jar')
jruby_ruboto_jar = File.join(generated_libs, 'jruby-ruboto.jar')
ant.property :name=>'external.libs.dir', :value => generated_libs
dirs = ['tmp/ruby', 'tmp/precompiled', generated_libs]
dirs.each { |d| directory d }
CLEAN.include('tmp', 'bin', generated_libs)
ant_import
file stdlib_precompiled => :compile_stdlib
file jruby_ruboto_jar => generated_libs do
ant.zip(:destfile=>jruby_ruboto_jar) do
zipfileset(:src=>jruby_jar) do
exclude(:name=>'jni/**')
end
end
end
desc "precompile ruby stdlib"
task :compile_stdlib => [:clean, *dirs] do
ant.unzip(:src=>stdlib, :dest=>'tmp/ruby')
Dir.chdir('tmp/ruby') { sh "jrubyc . -t ../precompiled" }
ant.zip(:destfile=>stdlib_precompiled, :basedir=>'tmp/precompiled')
end
task :generate_libs => [generated_libs, jruby_ruboto_jar] do
cp stdlib, generated_libs
end
task :debug => :generate_libs
task :release => :generate_libs
task :default => :debug
task :tag => :release do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
exit!
end
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git tag #{version}"
sh "git push origin master --tags"
#sh "gem push pkg/#{name}-#{version}.gem"
end
task :sign => :release do
sh "jarsigner -keystore #{ENV['RUBOTO_KEYSTORE']} -signedjar bin/#{build_project_name}.apk bin/#{build_project_name}-unsigned.apk #{ENV['RUBOTO_KEY_ALIAS']}"
end
task :align => :sign do
sh "zipalign 4 bin/#{build_project_name}.apk #{build_project_name}.apk"
end
task :publish => :align do
puts "#{build_project_name}.apk is ready for the market!"
end
task :update_scripts do
Dir['assets/scripts/*.rb'].each do |script|
`adb push #{script} /data/data/#{package}/files/scripts`
end
end
def manifest
@manifest ||= REXML::Document.new(File.read('AndroidManifest.xml'))
end
def strings(name)
@strings ||= REXML::Document.new(File.read('res/values/strings.xml'))
value = @strings.elements["//string[@name='#{name.to_s}']"] or raise "string '#{name}' not found in strings.xml"
value.text
end
def package() manifest.root.attribute('package') end
def version() strings :version_name end
def app_name() strings :app_name end
def build_project_name() @build_project_name ||= REXML::Document.new(File.read('build.xml')).elements['project'].attribute(:name).value end