ruboto 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/COPYING +19 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +21 -0
  4. data/README.md +293 -0
  5. data/Rakefile +114 -0
  6. data/assets/Rakefile +386 -0
  7. data/assets/res/drawable-hdpi/icon.png +0 -0
  8. data/assets/res/drawable-ldpi/icon.png +0 -0
  9. data/assets/res/drawable-mdpi/icon.png +0 -0
  10. data/assets/res/layout/get_ruboto_core.xml +25 -0
  11. data/assets/samples/sample_activity.rb +21 -0
  12. data/assets/samples/sample_activity_test.rb +21 -0
  13. data/assets/samples/sample_broadcast_receiver.rb +6 -0
  14. data/assets/samples/sample_broadcast_receiver_test.rb +1 -0
  15. data/assets/samples/sample_service.rb +14 -0
  16. data/assets/samples/sample_service_test.rb +1 -0
  17. data/assets/src/InheritingActivity.java +195 -0
  18. data/assets/src/InheritingBroadcastReceiver.java +27 -0
  19. data/assets/src/InheritingClass.java +19 -0
  20. data/assets/src/InheritingService.java +9 -0
  21. data/assets/src/RubotoActivity.java +111 -0
  22. data/assets/src/RubotoBroadcastReceiver.java +51 -0
  23. data/assets/src/RubotoService.java +61 -0
  24. data/assets/src/org/ruboto/RubotoDialog.java +11 -0
  25. data/assets/src/org/ruboto/Script.java +545 -0
  26. data/assets/src/org/ruboto/test/ActivityTest.java +63 -0
  27. data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +124 -0
  28. data/assets/src/ruboto.rb +621 -0
  29. data/assets/test/assets/scripts/test_helper.rb +13 -0
  30. data/bin/ruboto +5 -0
  31. data/lib/java_class_gen/InheritingClass.java.erb +10 -0
  32. data/lib/java_class_gen/android_api.xml +1 -0
  33. data/lib/ruboto.rb +16 -0
  34. data/lib/ruboto/api.rb +21 -0
  35. data/lib/ruboto/commands/base.rb +392 -0
  36. data/lib/ruboto/core_ext/array.rb +6 -0
  37. data/lib/ruboto/core_ext/object.rb +10 -0
  38. data/lib/ruboto/util/asset_copier.rb +27 -0
  39. data/lib/ruboto/util/build.rb +201 -0
  40. data/lib/ruboto/util/code_formatting.rb +22 -0
  41. data/lib/ruboto/util/log_action.rb +20 -0
  42. data/lib/ruboto/util/main_fix.rb +13 -0
  43. data/lib/ruboto/util/objectspace.rb +8 -0
  44. data/lib/ruboto/util/scan_in_api.rb +40 -0
  45. data/lib/ruboto/util/update.rb +420 -0
  46. data/lib/ruboto/util/verify.rb +87 -0
  47. data/lib/ruboto/util/xml_element.rb +200 -0
  48. data/lib/ruboto/version.rb +3 -0
  49. data/test/activity/image_button_activity.rb +21 -0
  50. data/test/activity/image_button_activity_test.rb +21 -0
  51. data/test/activity/image_button_and_button_activity.rb +24 -0
  52. data/test/activity/image_button_and_button_activity_test.rb +27 -0
  53. data/test/activity/option_menu_activity.rb +21 -0
  54. data/test/activity/option_menu_activity_test.rb +20 -0
  55. data/test/activity/stack_activity.rb +21 -0
  56. data/test/activity/stack_activity_test.rb +23 -0
  57. data/test/app_test_methods.rb +41 -0
  58. data/test/minimal_app_test.rb +23 -0
  59. data/test/rake_test.rb +40 -0
  60. data/test/ruboto_gen_test.rb +32 -0
  61. data/test/ruboto_gen_with_psych_test.rb +16 -0
  62. data/test/ruboto_update_test.rb +5 -0
  63. data/test/ruboto_update_with_psych_test.rb +18 -0
  64. data/test/service_test.rb +49 -0
  65. data/test/test_helper.rb +177 -0
  66. data/test/update_test_methods.rb +33 -0
  67. metadata +157 -0
data/COPYING ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 Daniel Jackoway, Charles Nutter, Scott Moyer, Uwe Kubosch
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'main'
4
+ gem 'jruby-jars'
@@ -0,0 +1,21 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ arrayfields (4.7.4)
5
+ chronic (0.6.2)
6
+ fattr (2.2.0)
7
+ jruby-jars (1.6.4)
8
+ main (4.7.3)
9
+ arrayfields (~> 4.7.4)
10
+ chronic (~> 0.6.2)
11
+ fattr (~> 2.2.0)
12
+ map (~> 4.3.0)
13
+ map (4.3.0)
14
+
15
+ PLATFORMS
16
+ java
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ jruby-jars
21
+ main
@@ -0,0 +1,293 @@
1
+ Ruboto
2
+ =============
3
+
4
+ Ruby on Android.
5
+
6
+ Installation
7
+ -------
8
+
9
+ $ gem install ruboto
10
+
11
+ Getting Started
12
+ ---------------
13
+
14
+ Before you use Ruboto, you should do the following things:
15
+
16
+ * Install the JDK if it's not on your system already
17
+ * Install [jruby](http://jruby.org/) if you don't already have it. JRuby has a [very easy install process](http://jruby.org/#2), or you can use [rvm](http://rvm.beginrescueend.com/)
18
+ * Install [the Android SDK](http://developer.android.com/sdk/index.html)
19
+ * Add the sdk's `tools/` directory to your `$PATH`
20
+ * Generate an [Emulator](http://developer.android.com/guide/developing/tools/emulator.html) image unless you want to develop using your phone.
21
+
22
+ General Information
23
+ ------------------
24
+
25
+ The Rakefile assumes that you are in the root directory of your app, as do all commands of the `ruboto` command line utility, other than `ruboto gen app`.
26
+
27
+ The Rakefile requires you to run it through JRuby's rake.
28
+
29
+ Command-line Tools
30
+ -------
31
+
32
+ * [Application generator](#application_generator) (like the rails application generator)
33
+ * [Class generator](#class_generator) to generate additional Activities, BroadcastReceivers, Services, etc.
34
+ * [Callback generator](#class_generator) to generate specific subclasses to open up access (callbacks) for various portions of the Android API.
35
+ * [Packaging task](#packaging_task) to generate an apk file
36
+ * [Deployment task](#deployment_task) to deploy a generated package to an emulator or connected device
37
+ * [Develop without having to compile to try every change](#update_scripts)
38
+
39
+
40
+ <a name="application_generator"></a>
41
+ ### Application generator
42
+
43
+ $ ruboto gen app --package com.yourdomain.whatever --path path/to/where/you/want/the/app --name NameOfApp --target android-version --min-sdk another-android-version --activity MainActivityName
44
+ Version values must be specified using'android-' and the sdk level number (e.g., android-8 is froyo).
45
+
46
+ <a name="class_generator"></a>
47
+ ### Class generator
48
+
49
+ Generates a Java class (Activity, Service, or BroadcastReceiver) associated with a specific ruboto script. The generator also generates a corrsponding test script.
50
+
51
+ $ ruboto gen class ClassName --name YourObjectName
52
+ Ex:
53
+ $ ruboto gen class BroadcastReceiver --name AwesomenessReceiver
54
+
55
+ <a name="callback_generator"></a>
56
+ ### Callback generator
57
+
58
+ Can subclass any part of the Android API to pass control over to a script when the specified methods are called. You can also create classes that implement a single Android interface to pass control over to ruboto.
59
+
60
+ For classes that need subclassing (e.g., PhoneStateListener, SQLiteOpenHelper, View)
61
+
62
+ $ ruboto gen subclass AndroidPackageAndClassName --name YourClassName --method_base all-on-or-none --method_include methods --method_exclude methods
63
+ Ex:
64
+ $ ruboto gen subclass android.telephony.PhoneStateListener --name MyPhoneStateListener --method_base on
65
+
66
+ For interfaces that need implementing (e.g., OnClickListener or SensorListener)
67
+
68
+ $ ruboto gen interface AndroidPackageAndInterfaceName --name YourClassName
69
+ Ex:
70
+ $ ruboto gen interface android.hardware.SensorListener --name MySensorListener
71
+
72
+ Inside your script use:
73
+
74
+ # note that this is different than java_import
75
+ ruboto_import "your.package.MySensorListener"
76
+
77
+ Later:
78
+
79
+ # Create the callback object
80
+ @sensor_listener = MySensorListener.new
81
+
82
+ # Specify the block to call
83
+ @sensor_listener.handle_sensor_changed do |sensor, values|
84
+ # Do stuff
85
+ end
86
+
87
+ # Register the listener
88
+
89
+ <a name="packaging_task"></a>
90
+ ### Packaging task
91
+
92
+ This will generate an apk file.
93
+
94
+ $ rake
95
+
96
+ To generate an apk and install it to a connected device (or emulator) all in one go, run
97
+
98
+ $ rake install
99
+
100
+ <a name="deployment_task"></a>
101
+ ### Deployment task
102
+
103
+ When you're ready to post your app to the Market, you need to do a few things.
104
+
105
+ First, you'll need to generate a key to sign the app with using `keytool` if you do not already have one. If you're ok with accepting some sane defaults, you can use
106
+ $ ruboto gen key --alias alias_for_your_key
107
+ with an optional flag `--keystore /path/to/keystore.keystore`, which defaults to `~/.android/production.keystore`. It will ask for a password for the keystore and one for the key itself. Make sure that you remember those two passwords, as well as the alias for the key.
108
+
109
+ Also make sure to keep your key backed up (if you lose it, you won't be able to release updates to your app that can install right over the old versions), but secure.
110
+
111
+ Once you have your key, use the `rake publish` task to generate a market-ready `.apk` file. You will need the `RUBOTO_KEYSTORE` and `RUBOTO_KEY_ALIAS` environment variables set to the path to the keystore and the alias for the key, respectively. So either run
112
+ $ RUBOTO_KEYSTORE=~/.android/production.keystore RUBOTO_KEY_ALIAS=foo rake publish
113
+ or set those environment variables in your `~/.bashrc` or similar file and just run
114
+ $ rake publish
115
+ Now get that `.apk` to the market!
116
+
117
+ <a name="update_scripts"></a>
118
+ ### Updating Your Scripts on a Device
119
+
120
+ With traditional Android development, you have to recompile your app and reinstall it on your test device/emulator every time you make a change. That's slow and annoying.
121
+
122
+ Luckily, with Ruboto, most of your changes are in the scripts, not in the compiles Java files. So if your changes are Ruby-only, you can just run
123
+
124
+ $ rake update_scripts
125
+
126
+ to have it copy the current version of your scripts to your device.
127
+
128
+ Sorry if this takes away your excuse to have sword fights:
129
+
130
+ ![XKCD Code's Compiling](http://imgs.xkcd.com/comics/compiling.png)
131
+
132
+ Caveats:
133
+
134
+ This only works if your changes are all Ruby. If you have Java changes (which would generally just mean generating new classes) or changes to the xml, you will need to recompile your script.
135
+
136
+ Also, you need root access to your device for this to work, as it needs to write to directories that are read-only otherwise. The easiest solution is to test on an emulator, but you can also root your phone.
137
+
138
+ ### Updating Ruboto's Files
139
+
140
+ You can update various portions of your generated Ruboto app through the ruboto command:
141
+
142
+ * JRuby:
143
+
144
+ 1) If a new version of JRuby is released, you should update your gem (e.g., sudo gem update jruby-jars).
145
+
146
+ 2) From the root directory of your app:
147
+
148
+ $ ruboto update jruby
149
+
150
+ * The ruboto.rb script:
151
+
152
+ 1) From the root directory of your app:
153
+
154
+ $ ruboto update ruboto
155
+
156
+ * The core classes (e.g., RubotoActivity):
157
+
158
+ 1) These classes are generated on your machine based on the SDKs (min and target) specified when you 'gen app' (stored in the AndroidManifest.xml)
159
+
160
+ 2) You many want to regenerate them if a new version of the SDK is released, if you change your targets, or if you want more control over the callbacks you receive.
161
+
162
+ 3) From the root directory of your app:
163
+
164
+ $ ruboto gen core Activity --method_base all-on-or-none --method_include specific-methods-to-include --method_include specific-methods-to-exclude
165
+
166
+ 4) The generator will load up the SDK information and find the specified methods. The generator will abort around methods that were added or deprecated based on the SDK levels. You can either use method_exclude to remove methods individually or add '--force exclude' to remove the all. You can also us '--force include' to create them anyway (added methods are created without calling super to avoid crashin on legacy hardware).
167
+
168
+ Scripts
169
+ -------
170
+
171
+ The main thing Ruboto offers you is the ability to write Ruby scripts to define the behavior of Activites, BroadcastReceievers, and Services. (Eventually it'll be every class. It's setup such that adding in more classes should be trivial.)
172
+
173
+ Here's how it works:
174
+
175
+ First of all, your scripts are found in `src/` and the script name is the same as the name of your class, only under_scored instead of CamelCased. Android classes have all of these methods that get called in certain situations. `Activity.onDestroy()` gets called when the activity gets killed, for example. Save weird cases (like the "launching" methods that need to setup JRuby), to script the method onFooBar, you call the Ruby method handle_foo_bar on the Android object. In your scripts, they are defined as `$class_name`. That was really abstract, so here's an example.
176
+
177
+ You generate an app with the option `--activity FooActivity`, which means that ruboto will generate a FooActivity for you. So you open `src/foo_activity.rb` in your favorite text editor. If you want an activity that does nothing but Log when it gets launched and when it gets destroyed (in the onCreate and onPause methods). You want your script to look like this:
178
+
179
+ require 'ruboto.rb' #scripts will not work without doing this
180
+ $activity.handle_create do |bundle|
181
+ Log.v 'MYAPPNAME', 'onCreate got called!'
182
+ handle_pause do
183
+ Log.v 'MYAPPNAME', 'onPause got called!'
184
+ end
185
+ end
186
+
187
+ If you prefer, you can also do this. It's equivalent:
188
+
189
+ require 'ruboto.rb' #scripts will not work without doing this
190
+ $activity.handle_create do |bundle|
191
+ Log.v 'MYAPPNAME', 'onCreate got called!'
192
+ end
193
+ $activity.handle_pause do
194
+ Log.v 'MYAPPNAME', 'onPause got called!'
195
+ end
196
+
197
+ Each class has only one method that you can nest other calls inside of (ie. what is happening in that first example that removes the need for the second `$activity.`). For Activities and Services, it is `handle_create`, and for BroadcastReceivers, it is `handle_receive`. The general rule is that it corresponds to the first method in the class's lifecycle. But you should never really have to think about it because generating a class generates a sample script that calls that method.
198
+
199
+ The arguments passed to the block you give `handle_` methods are the same as the arguments that the java methods take. Consult the Android documentation.
200
+
201
+ Activities also have some special methods defined to make things easier. The easiest way to get an idea of what they are is looking over the [demo scripts](http://github.com/ruboto/ruboto-irb/tree/master/assets/demo-scripts/). You can also read the [ruboto.rb file](http://github.com/ruboto/ruboto/blob/master/assets/src/ruboto.rb) where everything is defined.
202
+
203
+ Testing
204
+ -------
205
+
206
+ For each generated class, a ruby test script is created in the test/assets/scripts directory.
207
+ For example if you generate a RubotoSampleAppActivity a file test/assets/scripts/ruboto_sample_app_activity_test.rb
208
+ file is created containing a sample test script:
209
+
210
+ activity Java::org.ruboto.sample_app.RubotoSampleAppActivity
211
+
212
+ setup do |activity|
213
+ start = Time.now
214
+ loop do
215
+ @text_view = activity.findViewById(42)
216
+ break if @text_view || (Time.now - start > 60)
217
+ sleep 1
218
+ end
219
+ assert @text_view
220
+ end
221
+
222
+ test('initial setup') do |activity|
223
+ assert_equal "What hath Matz wrought?", @text_view.text
224
+ end
225
+
226
+ test('button changes text') do |activity|
227
+ button = activity.findViewById(43)
228
+ button.performClick
229
+ assert_equal "What hath Matz wrought!", @text_view.text
230
+ end
231
+
232
+ You run the tests for your app using ant or rake
233
+
234
+ $ jruby -S rake test
235
+
236
+ $ cd test ; ant run-tests
237
+
238
+ Contributing
239
+ ------------
240
+
241
+ Want to contribute? Great! Meet us in #ruboto on irc.freenode.net, fork the project and start coding!
242
+
243
+ "But I don't understand it well enough to contribute by forking the project!" That's fine. Equally helpful:
244
+
245
+ * Use Ruboto and tell us how it could be better.
246
+ * As you gain wisdom, contribute it to [the wiki](http://github.com/ruboto/ruboto/wiki/)
247
+ * When you gain enough wisdom, reconsider whether you could fork the project.
248
+
249
+ If contributing code to the project, please run the exising tests and add tests for your changes. You run the tests using rake
250
+
251
+ $ jruby -S rake test
252
+
253
+ Getting Help
254
+ ------------
255
+
256
+ * You'll need to be pretty familiar with the Android API. The [Developer Guide](http://developer.android.com/guide/index.html) and [Reference](http://developer.android.com/reference/packages.html) are very useful.
257
+ * There is further documentation at the [wiki](http://github.com/ruboto/ruboto/wiki)
258
+ * If you have bugs or feature requests, [open an issue on GitHub](http://github.com/ruboto/ruboto/issues)
259
+ * You can ask questions in #ruboto on irc.freenode.net and on the [mailing list](http://groups.google.com/groups/ruboto)
260
+ * There are some sample scripts (just Activities) [here](http://github.com/ruboto/ruboto-irb/tree/master/assets/demo-scripts/)
261
+
262
+ Tips & Tricks
263
+ -------------
264
+
265
+ ### Emulators
266
+
267
+ If you're doing a lot of Android development, you'll probably find yourself typing `emulator -avd name_of_emulator` a lot to open emulators. It can be convenient to alias these to shorter commands.
268
+
269
+ For example, in your `~/.bashrc`, `~/.zshrc`, or similar file, you might put
270
+ alias eclair="emulator -avd eclair"
271
+ alias froyo="emulator -avd froyo"
272
+ If you have an "eclair" emulator that runs Android 2.1 and a "froyo" one that runs Android 2.2.
273
+
274
+
275
+ Alternatives
276
+ ------------
277
+
278
+ If Ruboto's performance is a problem for you, or you want something that gives you total access to the android API (as Ruboto does not yet do), check out [Mirah](http://mirah.org/) and [Garrett](http://github.com/technomancy/Garrett).
279
+
280
+ Mirah, formerly known as Duby, is a language with Ruby-like syntax that compiles to java files. This means that it adds no big runtime dependencies and has essentially the same performance as writing Java code because it essentially generates the same Java code that you would write. This makes it extremely well-suited for mobile devices where performance is a much bigger consideration.
281
+
282
+ Garrett is a "playground for Mirah exploration on Android."
283
+
284
+
285
+ Domo Arigato
286
+ ------------
287
+
288
+ Thanks go to:
289
+
290
+ * Charles Nutter, a member of the JRuby core team, for mentoring this RSoC project and starting the Ruboto project in the first place with an [irb](http://github.com/ruboto/ruboto-irb)
291
+ * All of Ruby Summer of Code's [sponsors](http://rubysoc.org/sponsors)
292
+ * [Engine Yard](http://engineyard.com/) in particular for sponsoring RSoC and heavily sponsoring JRuby, which is obviously critical to the project.
293
+ * All [contributors](http://github.com/ruboto/ruboto/contributors) and [contributors to the ruboto-irb project](http://github.com/ruboto/ruboto-irb/contributors), as much of this code was taken from ruboto-irb.
@@ -0,0 +1,114 @@
1
+ require 'rexml/document'
2
+ require 'lib/ruboto/version'
3
+
4
+ PLATFORM_PROJECT = File.expand_path('tmp/RubotoCore', File.dirname(__FILE__))
5
+ PLATFORM_DEBUG_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-debug.apk"
6
+ PLATFORM_RELEASE_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-release.apk"
7
+ MANIFEST_FILE = "AndroidManifest.xml"
8
+ GEM_FILE = "ruboto-#{Ruboto::VERSION}.gem"
9
+ GEM_FILE_OLD = "ruboto-core-#{Ruboto::VERSION}.gem"
10
+ GEM_SPEC_FILE = 'ruboto.gemspec'
11
+ GEM_SPEC_FILE_OLD = 'ruboto-core.gemspec'
12
+
13
+ # FIXME(uwe): Remove when we stop supporting JRuby 1.5.6
14
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
15
+ gem_spec = Gem::Specification.find_by_path 'jruby-jars'
16
+ else
17
+ gem_spec = Gem.searcher.find('jruby-jars')
18
+ end
19
+ raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
20
+ JRUBY_JARS_VERSION = gem_spec.version
21
+ ON_JRUBY_JARS_1_5_6 = JRUBY_JARS_VERSION == Gem::Version.new('1.5.6')
22
+ # FIXME end
23
+
24
+
25
+ task :default => :gem
26
+
27
+ desc "Generate a gem"
28
+ task :gem => [GEM_FILE, GEM_FILE_OLD]
29
+
30
+ file GEM_FILE => GEM_SPEC_FILE do
31
+ puts "Generating #{GEM_FILE}"
32
+ `gem build #{GEM_SPEC_FILE}`
33
+ end
34
+
35
+ file GEM_FILE_OLD => GEM_SPEC_FILE_OLD do
36
+ puts "Generating #{GEM_FILE_OLD}"
37
+ `gem build #{GEM_SPEC_FILE_OLD}`
38
+ end
39
+
40
+ desc "Push the gem to RubyGems"
41
+ task :release => :gem do
42
+ output = `git status --porcelain`
43
+ raise "Workspace not clean!\n#{output}" unless output.empty?
44
+ sh "git tag #{Ruboto::VERSION}"
45
+ sh "git push --tags"
46
+ sh "gem push #{GEM_FILE}"
47
+ sh "gem push #{GEM_FILE_OLD}"
48
+
49
+ end
50
+
51
+ desc "Run the tests"
52
+ task :test do
53
+ FileUtils.rm_rf Dir['tmp/RubotoTestApp_template*']
54
+ Dir['test/*_test.rb'].each do |f|
55
+ require f.chomp('.rb')
56
+ end
57
+ end
58
+
59
+ namespace :platform do
60
+ desc 'Remove Ruboto Core platform project'
61
+ task :clean do
62
+ FileUtils.rm_rf PLATFORM_PROJECT
63
+ end
64
+
65
+ desc 'Generate the Ruboto Core platform project'
66
+ task :project => PLATFORM_PROJECT
67
+
68
+ file PLATFORM_PROJECT do
69
+ 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}"
70
+ Dir.chdir(PLATFORM_PROJECT) do
71
+ manifest = REXML::Document.new(File.read(MANIFEST_FILE))
72
+ manifest.root.attributes['android:versionCode'] = '408'
73
+ manifest.root.attributes['android:versionName'] = '0.4.8.dev'
74
+ manifest.root.attributes['android:installLocation'] = 'auto' # or 'preferExternal' ?
75
+ manifest.root.elements['uses-sdk'].attributes['android:targetSdkVersion'] = '8'
76
+ File.open(MANIFEST_FILE, 'w') { |f| manifest.document.write(f, 4) }
77
+ File.open('project.properties', 'w'){|f| f << "target=android-8\n"}
78
+ File.open('Gemfile.apk', 'w'){|f| f << "source :rubygems\n\ngem 'activerecord-jdbc-adapter'\n"}
79
+ keystore_file = File.expand_path('~/android_market.keystore')
80
+ if File.exists?(keystore_file)
81
+ File.open('local.properties', 'a'){|f| f << "key.store=#{keystore_file}\nkey.alias=android_market\n"}
82
+ end
83
+ end
84
+ end
85
+
86
+ file PLATFORM_DEBUG_APK => PLATFORM_PROJECT do
87
+ Dir.chdir(PLATFORM_PROJECT) do
88
+ sh 'rake debug'
89
+ end
90
+ end
91
+
92
+ desc 'Generate a Ruboto Core platform release apk'
93
+ task :release => PLATFORM_RELEASE_APK
94
+
95
+ file PLATFORM_RELEASE_APK => PLATFORM_PROJECT do
96
+ Dir.chdir(PLATFORM_PROJECT) do
97
+ sh 'rake release'
98
+ end
99
+ end
100
+
101
+ desc 'Install the Ruboto Core platform debug apk'
102
+ task :install => PLATFORM_DEBUG_APK do
103
+ Dir.chdir(PLATFORM_PROJECT) do
104
+ sh 'rake install'
105
+ end
106
+ end
107
+
108
+ desc 'Uninstall the Ruboto Core platform debug apk'
109
+ task :uninstall => PLATFORM_PROJECT do
110
+ Dir.chdir(PLATFORM_PROJECT) do
111
+ sh 'rake uninstall'
112
+ end
113
+ end
114
+ end