pindah 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.txt +21 -12
- data/Manifest.txt +19 -19
- data/README.md +192 -118
- data/Rakefile +11 -20
- data/bin/pindah +9 -9
- data/lib/pindah.rb +196 -100
- data/lib/pindah_cli.rb +77 -77
- data/templates/.gitignore +2 -2
- data/templates/AndroidManifest.xml +19 -19
- data/templates/Rakefile +7 -7
- data/templates/build.xml +47 -32
- data/templates/initial_activity.mirah +10 -10
- data/templates/main.xml +13 -13
- data/templates/strings.xml +4 -4
- data/test/fixtures/HelloWorld.mirah +10 -10
- data/test/pindah_cli_test.rb +85 -85
- metadata +85 -89
- data/.gemtest +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: def898661927bc31b27c4047a5871fb3afc9e914
|
4
|
+
data.tar.gz: 813d6911b38902eaf454bb7aeac8dd8fbd77c6da
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b6456b0447f066a15b2edaad63e501c202a837628260173238126062ebac951968d38886353ad9e632d3ce6d5820986c8dbbcfaef0ec2e1e78ae63c2cba1e06
|
7
|
+
data.tar.gz: ac4c523c30ead0949c9c70be9a3a0ce043353842cc863f0e778076ecb95004c05e83f9f0b634e4de2fc4a96ebd1f5d0eacfdaf872ac79725c93e97103455cefb
|
data/History.txt
CHANGED
@@ -1,12 +1,21 @@
|
|
1
|
-
=== 0.1.
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
*
|
8
|
-
*
|
9
|
-
|
10
|
-
=== 0.1.
|
11
|
-
|
12
|
-
*
|
1
|
+
=== 0.1.3 / 2014-01-15
|
2
|
+
|
3
|
+
* Resolve all outstanding bug reports in the issue tracker.
|
4
|
+
* Add support for the current Android API levels.
|
5
|
+
* Cleanup readme documentation formatting and update requirements,
|
6
|
+
JRuby/Mirah combination compatibility, and usage information.
|
7
|
+
* Drop support for both JRuby 1.6.8 and Mirah 0.0.12.
|
8
|
+
* Bump minimum version requirements to JRuby 1.7.3 and Mirah 0.1.0.
|
9
|
+
|
10
|
+
=== 0.1.2 / 2011-06-06
|
11
|
+
|
12
|
+
* Silence Rake deprecation warnings.
|
13
|
+
|
14
|
+
=== 0.1.1 / 2011-04-02
|
15
|
+
|
16
|
+
* Declare package explicitly to work around Mirah bug.
|
17
|
+
* Make Activity creation optional.
|
18
|
+
|
19
|
+
=== 0.1.0 / 2011-02-08
|
20
|
+
|
21
|
+
* Birthday!
|
data/Manifest.txt
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
README.md
|
4
|
-
Rakefile
|
5
|
-
bin/pindah
|
6
|
-
lib/pindah.rb
|
7
|
-
lib/pindah_cli.rb
|
8
|
-
templates/AndroidManifest.xml
|
9
|
-
templates/build.xml
|
10
|
-
templates/main.xml
|
11
|
-
templates/strings.xml
|
12
|
-
templates/Rakefile
|
13
|
-
templates/initial_activity.mirah
|
14
|
-
templates/.gitignore
|
15
|
-
templates/res/drawable-mdpi/ic_launcher.png
|
16
|
-
templates/res/drawable-hdpi/ic_launcher.png
|
17
|
-
templates/res/drawable-ldpi/ic_launcher.png
|
18
|
-
test/fixtures/HelloWorld.mirah
|
19
|
-
test/pindah_cli_test.rb
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.md
|
4
|
+
Rakefile
|
5
|
+
bin/pindah
|
6
|
+
lib/pindah.rb
|
7
|
+
lib/pindah_cli.rb
|
8
|
+
templates/AndroidManifest.xml
|
9
|
+
templates/build.xml
|
10
|
+
templates/main.xml
|
11
|
+
templates/strings.xml
|
12
|
+
templates/Rakefile
|
13
|
+
templates/initial_activity.mirah
|
14
|
+
templates/.gitignore
|
15
|
+
templates/res/drawable-mdpi/ic_launcher.png
|
16
|
+
templates/res/drawable-hdpi/ic_launcher.png
|
17
|
+
templates/res/drawable-ldpi/ic_launcher.png
|
18
|
+
test/fixtures/HelloWorld.mirah
|
19
|
+
test/pindah_cli_test.rb
|
data/README.md
CHANGED
@@ -1,118 +1,192 @@
|
|
1
|
-
# Pindah
|
2
|
-
|
3
|
-
A tool for writing Android applications in [Mirah](http://mirah.org).
|
4
|
-
|
5
|
-
<img src="https://github.com/mirah/pindah/raw/master/pindah.png" alt="Pindah logo" align="right" />
|
6
|
-
|
7
|
-
## Requirements
|
8
|
-
|
9
|
-
|
10
|
-
with the
|
11
|
-
|
12
|
-
download "platform" packages corresponding with Android versions you
|
13
|
-
|
14
|
-
tools
|
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
|
-
|
1
|
+
# Pindah
|
2
|
+
|
3
|
+
A tool for writing Android applications in [Mirah](http://mirah.org).
|
4
|
+
|
5
|
+
<img src="https://github.com/mirah/pindah/raw/master/pindah.png" alt="Pindah logo" align="right" />
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
<a name="requirements"></a>
|
9
|
+
|
10
|
+
You must have the [Android SDK](http://d.android.com/sdk/) installed with the `tools/` directory placed on your $PATH.
|
11
|
+
|
12
|
+
Inside your `tools/` directory, the `android` program will allow you to download "platform" packages corresponding with the Android versions you wish to develop against. You'll need to install "Android SDK Platform Tools" and at least one platform revision to get started. At the time of this writing, Android 2.3.3 (revision 10) and above [covers 100% of the market](http://developer.android.com/resources/dashboard/platform-versions.html) and is a reasonable target for new applications.
|
13
|
+
|
14
|
+
Once the platform tools are installed, place the SDK's `platform-tools/` directory on your $PATH.
|
15
|
+
|
16
|
+
You will also need the following tools installed before you can develop with Pindah:
|
17
|
+
|
18
|
+
* [OpenJDK](http://openjdk.java.net) 6 or 7
|
19
|
+
* [JRuby](http://jruby.org) 1.7.3 (or above)
|
20
|
+
* [Mirah](http://github.com/mirah/mirah) 0.1.0 (or above)
|
21
|
+
* [rake](http://rake.rubyforge.org) 10.0.3 (or above)
|
22
|
+
|
23
|
+
### JRuby/Mirah compatability
|
24
|
+
|
25
|
+
Pindah has been successfully tested with the following JRuby and Mirah combinations:
|
26
|
+
|
27
|
+
| JRuby/Mirah | 0.1.0 | 0.1.1 | 0.1.2 |
|
28
|
+
| -----------:|:-----:|:-----:|:-----:|
|
29
|
+
| 1.7.3 | ✓ | x | x |
|
30
|
+
| 1.7.4 | ✓ | ✓ | ✓ |
|
31
|
+
| 1.7.5 | ✓ | ✓ | ✓ |
|
32
|
+
| 1.7.6 | ✓ | ✓ | ✓ |
|
33
|
+
| 1.7.7 | ✓ | ✓ | ✓ |
|
34
|
+
| 1.7.8 | ✓ | ✓ | ✓ |
|
35
|
+
| 1.7.9 | ✓ | ✓ | ✓ |
|
36
|
+
| 1.7.10 | ✓ | ✓ | ✓ |
|
37
|
+
|
38
|
+
### Ruby version management
|
39
|
+
|
40
|
+
While Linux users can obtain OpenJDK from their distribution, it is recommended that all users utilize something like [rbenv](https://github.com/sstepehenson/rbenv), [rvm](http://rvm.io), or [uru](https://bitbucket.org/jonforums/uru) to manage their Ruby installations and gems:
|
41
|
+
|
42
|
+
# rbenv
|
43
|
+
|
44
|
+
$ rbenv install jruby-1.7.4
|
45
|
+
$ rbenv --global jruby-1.7.4
|
46
|
+
$ gem install rake mirah
|
47
|
+
|
48
|
+
# rvm
|
49
|
+
|
50
|
+
$ rvm install jruby-1.7.4
|
51
|
+
$ gem install rake mirah
|
52
|
+
|
53
|
+
## Installation
|
54
|
+
|
55
|
+
To install the latest stable version of Pindah, simply install the gem from the command line:
|
56
|
+
|
57
|
+
`gem install pindah`
|
58
|
+
|
59
|
+
If you want to play with the latest development version, clone the repo onto your local machine:
|
60
|
+
|
61
|
+
$ git clone git://github.com/mirah/pindah
|
62
|
+
$ cd pindah/
|
63
|
+
$ gem build pindah.gemspec
|
64
|
+
$ gem install pindah-0.1.4.dev.gem
|
65
|
+
|
66
|
+
## Usage
|
67
|
+
|
68
|
+
Similar to other Ruby projects like Rails or Ruboto, the `pindah` executable is responsible for creating and configuring your new Android project(s). To get started with a simple project, call the `pindah` command like so:
|
69
|
+
|
70
|
+
`pindah create org.example.hello_world`
|
71
|
+
|
72
|
+
This will create an empty skeleton project with the package name `org.example.hello_world` in the current directory.
|
73
|
+
|
74
|
+
You can also configure your project with the following options:
|
75
|
+
|
76
|
+
* To create your project in a specific location, specify an optional path for your new project:
|
77
|
+
`pindah create org.example.hello_world path_to_project`
|
78
|
+
|
79
|
+
* To create and configure a basic initial activity for your project, specify an activity name after the path:
|
80
|
+
`pindah create org.example.hello_world path_to_project StartActivity`
|
81
|
+
|
82
|
+
All other project management tasks are handled by rake. For a summary of all possible tasks you can run on your new project, run `rake -T` from your project directory:
|
83
|
+
|
84
|
+
$ rake -T
|
85
|
+
|
86
|
+
rake clean # Removes output files created by other targets.
|
87
|
+
rake compile # Run compile
|
88
|
+
rake debug # Builds the application and signs it with a debug key.
|
89
|
+
rake install # Installs the newly build package.
|
90
|
+
rake installd # Installs (only) the debug package.
|
91
|
+
rake installi # Installs (only) the instrumented package.
|
92
|
+
rake installr # Installs (only) the release package.
|
93
|
+
rake installt # Installs (only) the test and tested packages.
|
94
|
+
rake instrument # Builds an instrumented packaged.
|
95
|
+
rake javac # Compiles R.java and other gen/ files.
|
96
|
+
rake logcat # Tail logs from a device or a device or emulator
|
97
|
+
rake release # Builds the application in release mode.
|
98
|
+
rake release_unsigned # Builds the application in release mode.
|
99
|
+
rake spec # Print the project spec
|
100
|
+
rake test # Runs tests from the package defined in test.package property
|
101
|
+
rake uninstall # Uninstalls the application from a running emulator or device.
|
102
|
+
|
103
|
+
### Directory structure
|
104
|
+
|
105
|
+
Pindah follows the default Android directory structure when creating new projects:
|
106
|
+
|
107
|
+
$ pindah create org.example.hello_world hello_world/ StartActivity
|
108
|
+
|
109
|
+
Created 'hello_world/src/org/example/hello_world'.
|
110
|
+
Created 'hello_world/bin'.
|
111
|
+
Created 'hello_world/libs'.
|
112
|
+
Created 'hello_world/res'.
|
113
|
+
Created 'hello_world/res/drawable-hdpi'.
|
114
|
+
Created 'hello_world/res/drawable-ldpi'.
|
115
|
+
Created 'hello_world/res/drawable-mdpi'.
|
116
|
+
Created 'hello_world/res/layout'.
|
117
|
+
Created 'hello_world/res/values'.
|
118
|
+
Created project in hello_world.
|
119
|
+
|
120
|
+
$ cd hello_world && tree
|
121
|
+
.
|
122
|
+
|-- AndroidManifest.xml
|
123
|
+
|-- libs
|
124
|
+
|-- Rakefile
|
125
|
+
|-- res
|
126
|
+
| |-- drawable-hdpi
|
127
|
+
| | `-- ic_launcher.png
|
128
|
+
| |-- drawable-ldpi
|
129
|
+
| | `-- ic_launcher.png
|
130
|
+
| |-- drawable-mdpi
|
131
|
+
| | `-- ic_launcher.png
|
132
|
+
| |-- layout
|
133
|
+
| | `-- main.xml
|
134
|
+
| `-- values
|
135
|
+
| `-- strings.xml
|
136
|
+
`-- src
|
137
|
+
`-- org
|
138
|
+
`-- example
|
139
|
+
`-- hello_world
|
140
|
+
`-- StartActivity.mirah
|
141
|
+
|
142
|
+
12 directories, 8 files
|
143
|
+
|
144
|
+
Here are a few quick notes about the directory structure pictured above:
|
145
|
+
|
146
|
+
* The `AndroidManifest.xml` file describes the contents and metadata of your application.
|
147
|
+
* The `res/` directory contains application resources like icons, layout descriptions, and strings.
|
148
|
+
* The `src` directory contains the Java and Mirah source code for your project.
|
149
|
+
|
150
|
+
Other Android-specific directories may be created and used outside of this structure, as needed. Please refer to the official Android documentation for more information about supported project file types and directory names.
|
151
|
+
|
152
|
+
### Compiling and running
|
153
|
+
|
154
|
+
To compile your new project in debug mode, simply run `rake debug` from your project directory:
|
155
|
+
|
156
|
+
$ rake debug
|
157
|
+
|
158
|
+
# [...]
|
159
|
+
|
160
|
+
$ ls -l bin/hello_world-debug.apk
|
161
|
+
|
162
|
+
-rw-r--r-- 1 user user 13222 Feb 7 23:16 bin/hello_world-debug.apk
|
163
|
+
|
164
|
+
This .apk file may be installed on a connected device or emulator with `rake installd`. It may even distributed for users to install themselves, though stable versions should be built with the `release` task.
|
165
|
+
|
166
|
+
The official documentation has [more details on building](http://developer.android.com/guide/developing/other-ide.html#Building). The main difference between Pindah and the standard Ant build is that the `Rakefile` replaces `build.xml` as well as all the properties files. The Android Developer page above also explains how to get an emulator running for testing your application.
|
167
|
+
|
168
|
+
See [Garrett](http://github.com/technomancy/Garrett) for an example of a basic project.
|
169
|
+
|
170
|
+
## Contributing
|
171
|
+
|
172
|
+
To contribute to Pindah, you need the [required environment](#requirements) setup. You can get tests with the following set of commands.
|
173
|
+
|
174
|
+
$ git clone git@github.com:mirah/pindah.git
|
175
|
+
$ bundle install
|
176
|
+
$ rake test
|
177
|
+
|
178
|
+
## Community
|
179
|
+
|
180
|
+
Problems? Suggestions? Bring them up on the [Mirah mailing list](http://groups.google.com/group/mirah/) or the #mirah
|
181
|
+
IRC channel on freenode.
|
182
|
+
|
183
|
+
## See Also
|
184
|
+
|
185
|
+
If Mirah is just too low-level for your needs or you simply prefer something more dynamic, you can try [Ruboto](https://github.com/ruboto/ruboto/). Just be warned that it typically incurs a higher performance penalty and requires a larger app memory footprint due to JRuby's runtime.
|
186
|
+
|
187
|
+
## License
|
188
|
+
|
189
|
+
Released under the Apache 2.0 license.
|
190
|
+
|
191
|
+
Copyright (c) 2011 Phil Hagelberg, Nick Plante, J.D. Huntington
|
192
|
+
|
data/Rakefile
CHANGED
@@ -1,20 +1,11 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
# vim: syntax=ruby
|
15
|
-
|
16
|
-
Rake::TestTask.new do |t|
|
17
|
-
t.libs << "test"
|
18
|
-
t.test_files = FileList['test/**/*.rb']
|
19
|
-
t.verbose = true
|
20
|
-
end
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
Rake::TestTask.new do |t|
|
8
|
+
t.libs << "test"
|
9
|
+
t.test_files = FileList['test/**/*.rb']
|
10
|
+
t.verbose = true
|
11
|
+
end
|
data/bin/pindah
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'pindah_cli'))
|
4
|
-
|
5
|
-
begin
|
6
|
-
PindahCLI.send *ARGV
|
7
|
-
rescue ArgumentError, NoMethodError
|
8
|
-
abort "Usage: #{File.basename($0)} create org.example.hello [/path/to/hello_world] [HelloActivity]"
|
9
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'pindah_cli'))
|
4
|
+
|
5
|
+
begin
|
6
|
+
PindahCLI.send *ARGV
|
7
|
+
rescue ArgumentError, NoMethodError
|
8
|
+
abort "Usage: #{File.basename($0)} create org.example.hello [/path/to/hello_world] [HelloActivity]"
|
9
|
+
end
|
data/lib/pindah.rb
CHANGED
@@ -1,100 +1,196 @@
|
|
1
|
-
require "rake"
|
2
|
-
require "fileutils"
|
3
|
-
require "
|
4
|
-
require "
|
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
|
-
end
|
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
|
-
end
|
1
|
+
require "rake"
|
2
|
+
require "fileutils"
|
3
|
+
require "tempfile"
|
4
|
+
require "pp"
|
5
|
+
require "erb"
|
6
|
+
require "pathname"
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'ant'
|
10
|
+
rescue LoadError
|
11
|
+
abort 'This Rakefile requires JRuby. Please use jruby -S rake.'
|
12
|
+
end
|
13
|
+
|
14
|
+
require "mirah"
|
15
|
+
|
16
|
+
module Pindah
|
17
|
+
class << self
|
18
|
+
include Rake::DSL
|
19
|
+
end
|
20
|
+
|
21
|
+
VERSION = '0.1.3'
|
22
|
+
|
23
|
+
def self.infer_sdk_location(path)
|
24
|
+
return ENV["ANDROID_HOME"] unless ENV["ANDROID_HOME"].nil?
|
25
|
+
|
26
|
+
tools = path.split(File::PATH_SEPARATOR).detect { |p| File.exists?("#{p}/android") || File.exists?("#{p}/android.bat") }
|
27
|
+
abort "\"android\" executable not found on $PATH" if tools.nil?
|
28
|
+
real_location = Pathname.new("#{tools}/android").realpath.dirname
|
29
|
+
File.expand_path("#{real_location}/..")
|
30
|
+
end
|
31
|
+
|
32
|
+
DEFAULTS = {
|
33
|
+
:output => File.expand_path("bin"),
|
34
|
+
:src => File.expand_path("src"),
|
35
|
+
:classpath => Dir["jars/*jar", "libs/*jar"],
|
36
|
+
:sdk => Pindah.infer_sdk_location(ENV["PATH"])
|
37
|
+
}
|
38
|
+
|
39
|
+
TARGETS = {
|
40
|
+
"1.5" => 3,
|
41
|
+
"1.6" => 4,
|
42
|
+
"2.1" => 7,
|
43
|
+
"2.2" => 8,
|
44
|
+
"2.3" => 9, "2.3.1" => 9, "2.3.2" => 9,
|
45
|
+
"2.3.3" => 10, "2.3.4" => 10,
|
46
|
+
"3.0" => 11,
|
47
|
+
"3.1" => 12,
|
48
|
+
"3.2" => 13,
|
49
|
+
"4.0" => 14, "4.0.1" => 14, "4.0.2" => 14,
|
50
|
+
"4.0.3" => 15, "4.0.4" => 15,
|
51
|
+
"4.1" => 16, "4.1.1" => 16, "4.1.2" => 16,
|
52
|
+
"4.2" => 17, "4.2.2" => 17,
|
53
|
+
"4.3" => 18,
|
54
|
+
"4.4" => 19
|
55
|
+
}
|
56
|
+
|
57
|
+
ANT_TASKS = ["javac", "compile", "clean", "debug", "release",
|
58
|
+
"release_unsigned", "instrument", "test", "install", "installd",
|
59
|
+
"installr", "installi", "installt", "uninstall"]
|
60
|
+
SIGNED_TASKS = ["release"]
|
61
|
+
ANT_TASK_MAP = (Hash.new { |h, k| h[k] = k }).merge({ "release_unsigned" => "release" })
|
62
|
+
|
63
|
+
task :generate_manifest # TODO: generate from yaml?
|
64
|
+
|
65
|
+
desc "Tail logs from a device or a device or emulator"
|
66
|
+
task :logcat do
|
67
|
+
system "adb logcat #{@spec[:log_spec]}"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Print the project spec"
|
71
|
+
task :spec do
|
72
|
+
pp @spec
|
73
|
+
end
|
74
|
+
|
75
|
+
task :default => [:install]
|
76
|
+
|
77
|
+
def self.spec=(spec)
|
78
|
+
abort "Must provide :target_version in Pindah.spec!" if !spec[:target_version]
|
79
|
+
abort "Must provide :name in Pindah.spec!" if !spec[:name]
|
80
|
+
|
81
|
+
@spec = DEFAULTS.merge(spec)
|
82
|
+
|
83
|
+
@spec[:root] = File.expand_path "."
|
84
|
+
@spec[:target] ||= TARGETS[@spec[:target_version].to_s.sub(/android-/, '')]
|
85
|
+
@spec[:classes] ||= "#{@spec[:output]}/classes/"
|
86
|
+
@spec[:classpath] << @spec[:classes]
|
87
|
+
|
88
|
+
if @spec.has_key?(:libraries)
|
89
|
+
@spec[:libraries].each do |path|
|
90
|
+
# TODO: do libraries always build to bin/classes?
|
91
|
+
@spec[:classpath] << "#{File.expand_path path}/bin/classes/"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
@spec[:classpath] << "#{@spec[:sdk]}/platforms/android-#{@spec[:target]}/android.jar"
|
96
|
+
@spec[:log_spec] ||= "ActivityManager:I #{@spec[:name]}:D " +
|
97
|
+
"AndroidRuntime:E *:S"
|
98
|
+
|
99
|
+
ant_setup
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.ant_setup
|
103
|
+
@ant = Ant.new
|
104
|
+
|
105
|
+
# TODO: this is lame, but ant interpolation doesn't work for project name
|
106
|
+
build_template = ERB.new(File.read(File.join(File.dirname(__FILE__), '..',
|
107
|
+
'templates', 'build.xml')))
|
108
|
+
@build = Tempfile.new(["pindah-build", ".xml"])
|
109
|
+
@build.write(build_template.result(binding))
|
110
|
+
@build.close
|
111
|
+
|
112
|
+
if @spec.has_key?(:libraries)
|
113
|
+
# Push the libs in through project.properties
|
114
|
+
props_template = ERB.new(File.read(File.join(File.dirname(__FILE__), '..',
|
115
|
+
'templates', 'project.properties')))
|
116
|
+
@props = File.new("project.properties", 'w')
|
117
|
+
@props.write(props_template.result(binding))
|
118
|
+
@props.close
|
119
|
+
end
|
120
|
+
|
121
|
+
user_properties = {
|
122
|
+
"target" => "android-#{@spec[:target]}",
|
123
|
+
"target-version" => "android-#{@spec[:target_version]}",
|
124
|
+
"src" => @spec[:src],
|
125
|
+
"sdk.dir" => @spec[:sdk],
|
126
|
+
"classes" => @spec[:classes],
|
127
|
+
"classpath" => @spec[:classpath].join(Java::JavaLang::System::
|
128
|
+
getProperty("path.separator"))
|
129
|
+
}
|
130
|
+
|
131
|
+
user_properties.each do |key, value|
|
132
|
+
@ant.project.set_user_property(key, value)
|
133
|
+
end
|
134
|
+
|
135
|
+
Ant::ProjectHelper.configure_project(@ant.project, java.io.File.new(@build.path))
|
136
|
+
|
137
|
+
# Turn ant tasks into rake tasks
|
138
|
+
add_tasks(ANT_TASKS)
|
139
|
+
add_tasks(@spec[:extra_tasks])
|
140
|
+
end
|
141
|
+
|
142
|
+
protected
|
143
|
+
|
144
|
+
def self.add_tasks(tasks=nil)
|
145
|
+
return if tasks.nil?
|
146
|
+
tasks.each do |name|
|
147
|
+
ant_name = ANT_TASK_MAP[name]
|
148
|
+
|
149
|
+
target_task = @ant.project.targets[ant_name]
|
150
|
+
|
151
|
+
if target_task && target_task.description
|
152
|
+
desc target_task.description.gsub(/\s\s+/, "\n")
|
153
|
+
else
|
154
|
+
desc "Run #{name}"
|
155
|
+
end
|
156
|
+
|
157
|
+
task(name) do
|
158
|
+
add_signature_properties if SIGNED_TASKS.include?(name)
|
159
|
+
@ant.project.execute_target(ant_name)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.add_signature_properties
|
165
|
+
# Add key signing config
|
166
|
+
if @spec[:key_store] && @spec[:key_alias]
|
167
|
+
|
168
|
+
# NB: due to a JRuby/Ant bug, Ant can't read these passwords from the
|
169
|
+
# command line.
|
170
|
+
#
|
171
|
+
# So, we'll work around this for now. Icky.
|
172
|
+
#
|
173
|
+
# See: http://jira.codehaus.org/browse/JRUBY-4827
|
174
|
+
puts "Please enter keystore password (store:#{@spec[:key_store]}):"
|
175
|
+
store_pw = STDIN.gets.chomp
|
176
|
+
|
177
|
+
puts "Please enter password for alias '#{@spec[:key_alias]}':"
|
178
|
+
alias_pw = STDIN.gets.chomp
|
179
|
+
|
180
|
+
signature_properties = {
|
181
|
+
"key.store" => @spec[:key_store],
|
182
|
+
"key.alias" => @spec[:key_alias],
|
183
|
+
"key.store.password" => store_pw,
|
184
|
+
"key.alias.password" => alias_pw
|
185
|
+
}
|
186
|
+
|
187
|
+
signature_properties.each do |key, value|
|
188
|
+
@ant.project.set_user_property(key, value)
|
189
|
+
end
|
190
|
+
|
191
|
+
# NB: we need to do this again to actually set the new properties.
|
192
|
+
Ant::ProjectHelper.configure_project(@ant.project, java.io.File.new(@build.path))
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|