forked from ruboto/ruboto
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
94 lines (79 loc) · 2.95 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
require 'rexml/document'
PLATFORM_PROJECT = File.expand_path('tmp/RubotoCore', File.dirname(__FILE__))
PLATFORM_DEBUG_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-debug.apk"
PLATFORM_RELEASE_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-release.apk"
MANIFEST_FILE = "AndroidManifest.xml"
# FIXME(uwe): Remove when we stop supporting JRuby 1.5.6
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
gem_spec = Gem::Specification.find_by_path 'jruby-jars'
else
gem_spec = Gem.searcher.find('jruby-jars')
end
raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
JRUBY_JARS_VERSION = gem_spec.version
ON_JRUBY_JARS_1_5_6 = JRUBY_JARS_VERSION == Gem::Version.new('1.5.6')
# FIXME end
task :default => :gem
desc "Generate a gem"
task :gem do
`gem build ruboto-core.gemspec`
end
desc "Push the gem to RubyGems"
task :release do
sh "gem push #{Dir['ruboto-core-*.gem'][-1]}"
end
desc "Run the tests"
task :test do
FileUtils.rm_rf Dir['tmp/RubotoTestApp_template*']
Dir['test/*_test.rb'].each do |f|
require f.chomp('.rb')
end
end
namespace :platform do
desc 'Remove Ruboto Core platform project'
task :clean do
FileUtils.rm_rf PLATFORM_PROJECT
end
desc 'Generate the Ruboto Core platform project'
task :project => PLATFORM_PROJECT
file PLATFORM_PROJECT do
sh "ruby -rubygems -I#{File.expand_path('lib', File.dirname(__FILE__))} bin/ruboto gen app --package org.ruboto.core --name RubotoCore --with-jruby #{'--with-psych' unless ON_JRUBY_JARS_1_5_6} --path #{PLATFORM_PROJECT}"
Dir.chdir(PLATFORM_PROJECT) do
manifest = REXML::Document.new(File.read(MANIFEST_FILE))
manifest.root.attributes['android:versionCode'] = '2'
manifest.root.attributes['android:versionName'] = '0.4.1'
manifest.root.attributes['android:installLocation'] = 'auto' # or 'preferExternal' ?
manifest.root.elements['uses-sdk'].attributes['android:targetSdkVersion'] = '8'
File.open(MANIFEST_FILE, 'w') { |f| manifest.document.write(f, 4) }
File.open('default.properties', 'w'){|f| f << "target=android-8\n"}
keystore_file = File.expand_path('~/android_market.keystore')
if File.exists?(keystore_file)
File.open('local.properties', 'a'){|f| f << "key.store=#{keystore_file}\nkey.alias=android_market\n"}
end
end
end
file PLATFORM_DEBUG_APK => PLATFORM_PROJECT do
Dir.chdir(PLATFORM_PROJECT) do
sh 'rake debug'
end
end
desc 'Generate a Ruboto Core platform release apk'
task :release => PLATFORM_RELEASE_APK
file PLATFORM_RELEASE_APK => PLATFORM_PROJECT do
Dir.chdir(PLATFORM_PROJECT) do
sh 'rake release'
end
end
desc 'Install the Ruboto Core platform debug apk'
task :install => PLATFORM_DEBUG_APK do
Dir.chdir(PLATFORM_PROJECT) do
sh 'rake install'
end
end
desc 'Uninstall the Ruboto Core platform debug apk'
task :uninstall => PLATFORM_PROJECT do
Dir.chdir(PLATFORM_PROJECT) do
sh 'rake uninstall'
end
end
end