motion-gradle 1.0.5 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -8
- data/lib/motion/project/gradle.erb +22 -14
- data/lib/motion/project/gradle.rb +87 -21
- data/lib/motion/project/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab7bf0fb48a2a11c7185f459e73eb4c29a8cd5ed
|
4
|
+
data.tar.gz: ec1558bda34ca51e8685eff54ff71162b26c2975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86af7c01d52090e405c6a59b6e1ce264f9900981c6eb3407c22d39bacf7826b7d15fa0bfa653ec729f5bd83288140e7faa069507ecdfb493fa89821b769b33cc
|
7
|
+
data.tar.gz: 31a5aefb68bfd69046c44daeae47fda97a780d857bdd03ded26f63436f531a948783360681a2d346299d57558ec73aad76894be1a50150eb52deeb3d6553c115
|
data/README.md
CHANGED
@@ -41,22 +41,18 @@ You also need to install `Extras/Android Support Repository` with the Android SD
|
|
41
41
|
|
42
42
|
2. Still in the `Rakefile`, set your dependencies
|
43
43
|
|
44
|
+
From version 1.1.0 you can use the same gradle dependency string that Java users use.
|
45
|
+
|
44
46
|
```ruby
|
45
47
|
Motion::Project::App.setup do |app|
|
46
48
|
# ...
|
47
49
|
app.gradle do
|
48
|
-
dependency '
|
49
|
-
dependency '
|
50
|
-
dependency 'ehcache', :version => '1.2.3'
|
50
|
+
dependency 'net.sf.ehcache:ehcache:2.9.0'
|
51
|
+
dependency 'com.joanzapata.pdfview:android-pdfview:1.0.+@aar'
|
51
52
|
end
|
52
53
|
end
|
53
54
|
```
|
54
55
|
|
55
|
-
* :version will default to latest: +
|
56
|
-
|
57
|
-
* :artifact will default to dependency name
|
58
|
-
|
59
|
-
|
60
56
|
## Configuration
|
61
57
|
|
62
58
|
If the `gradle` command is not found in your PATH, you can configure it:
|
@@ -1,22 +1,22 @@
|
|
1
1
|
apply plugin: 'java'
|
2
2
|
apply plugin: 'eclipse'
|
3
3
|
|
4
|
-
task generateDependencies(type:
|
5
|
-
|
6
|
-
|
7
|
-
exclude 'META-INF/NOTICE'
|
8
|
-
exclude 'META-INF/NOTICE.txt'
|
9
|
-
|
10
|
-
baseName = 'dependencies'
|
11
|
-
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
|
12
|
-
with jar
|
4
|
+
task generateDependencies(type: Copy) {
|
5
|
+
from sourceSets.main.runtimeClasspath
|
6
|
+
into 'dependencies/'
|
13
7
|
}
|
14
8
|
|
15
9
|
repositories {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
<% if android_repository %>
|
11
|
+
maven {
|
12
|
+
url "<%= ENV['RUBYMOTION_ANDROID_SDK'] %>/extras/android/m2repository/"
|
13
|
+
}
|
14
|
+
<% end %>
|
15
|
+
<% if google_repository %>
|
16
|
+
maven {
|
17
|
+
url "<%= ENV['RUBYMOTION_ANDROID_SDK'] %>/extras/google/m2repository/"
|
18
|
+
}
|
19
|
+
<% end %>
|
20
20
|
<% @repositories.each do |url| %>
|
21
21
|
maven {
|
22
22
|
url "<%= url %>"
|
@@ -27,6 +27,14 @@ repositories {
|
|
27
27
|
|
28
28
|
dependencies {
|
29
29
|
<% @dependencies.each do |dependency| %>
|
30
|
-
|
30
|
+
<% if dependency.is_a?(String) %>
|
31
|
+
compile '<%= dependency %>'
|
32
|
+
<% else %>
|
33
|
+
<% if dependency[:extension] %>
|
34
|
+
compile group: '<%= dependency[:name] %>', name: '<%= dependency[:artifact] %>', version: '<%= dependency[:version] %>', ext: '<%= dependency[:extension]%>'
|
35
|
+
<% else %>
|
36
|
+
compile group: '<%= dependency[:name] %>', name: '<%= dependency[:artifact] %>', version: '<%= dependency[:version] %>'
|
37
|
+
<% end %>
|
38
|
+
<% end %>
|
31
39
|
<% end %>
|
32
40
|
}
|
@@ -21,6 +21,7 @@ module Motion::Project
|
|
21
21
|
|
22
22
|
class Gradle
|
23
23
|
GRADLE_ROOT = 'vendor/Gradle'
|
24
|
+
attr_reader :dependencies
|
24
25
|
|
25
26
|
def initialize(config)
|
26
27
|
@gradle_path = '/usr/bin/env gradle'
|
@@ -31,7 +32,8 @@ module Motion::Project
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def configure_project
|
34
|
-
|
35
|
+
vendor_aars
|
36
|
+
vendor_jars
|
35
37
|
end
|
36
38
|
|
37
39
|
def path=(path)
|
@@ -39,27 +41,93 @@ module Motion::Project
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def dependency(name, options = {})
|
42
|
-
|
44
|
+
if name.include?(':')
|
45
|
+
@dependencies << name
|
46
|
+
else
|
47
|
+
App.info('[deprecated]', "dependency('name', options) syntax is deprecated please use a gradle config string, eg: dependency('com.joanzapata.pdfview:android-pdfview:1.0.+@aar') ")
|
48
|
+
@dependencies << normalized_dependency(name, options)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
|
-
def repository(url
|
52
|
+
def repository(url)
|
46
53
|
@repositories << url
|
47
54
|
end
|
48
55
|
|
49
56
|
def install!(update)
|
50
57
|
generate_gradle_build_file
|
51
|
-
|
58
|
+
system("#{gradle_command} --build-file #{gradle_build_file} generateDependencies")
|
52
59
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
# this might be uneeded in the future
|
61
|
+
# if RM does support .aar out of the box
|
62
|
+
extract_aars
|
63
|
+
end
|
64
|
+
|
65
|
+
def android_repository
|
66
|
+
android_repository = File.join(ENV['RUBYMOTION_ANDROID_SDK'], 'extras', 'android', 'm2repository')
|
67
|
+
unless exist = File.exist?(android_repository)
|
68
|
+
App.info('[warning]', "To avoid issues you should install `Extras/Android Support Repository`. Open the gui to install it : #{android_gui_path}")
|
57
69
|
end
|
70
|
+
exist
|
71
|
+
end
|
58
72
|
|
59
|
-
|
73
|
+
def google_repository
|
74
|
+
google_repository = File.join(ENV['RUBYMOTION_ANDROID_SDK'], 'extras', 'google', 'm2repository')
|
75
|
+
unless exist = File.exist?(google_repository)
|
76
|
+
App.info('[warning]', "To avoid issues you should install `Extras/Google Repository`. Open the gui to install it : #{android_gui_path}")
|
77
|
+
end
|
78
|
+
exist
|
60
79
|
end
|
61
80
|
|
62
81
|
# Helpers
|
82
|
+
def vendor_aars
|
83
|
+
aars_dependendies = Dir[File.join(GRADLE_ROOT, 'aar/*')]
|
84
|
+
aars_dependendies.each do |dependency|
|
85
|
+
vendor_options = {:jar => File.join(dependency, 'classes.jar')}
|
86
|
+
|
87
|
+
res = File.join(dependency, 'res')
|
88
|
+
if File.exist?(res)
|
89
|
+
vendor_options[:resources] = res
|
90
|
+
vendor_options[:manifest] = File.join(dependency, 'AndroidManifest.xml')
|
91
|
+
end
|
92
|
+
|
93
|
+
native = File.join(dependency, 'jni')
|
94
|
+
if File.exist?(native)
|
95
|
+
archs = @config.archs.uniq.map do |arch|
|
96
|
+
@config.armeabi_directory_name(arch)
|
97
|
+
end
|
98
|
+
|
99
|
+
libs = Dir[File.join(native, "{#{archs.join(',')}}", "*.so")]
|
100
|
+
if libs.count != archs.count
|
101
|
+
App.info('[warning]', "Found only #{libs.count} lib(s) -> #{libs.join(',')} for #{archs.count} arch(s) : #{archs.join(',')}")
|
102
|
+
end
|
103
|
+
vendor_options[:native] = libs
|
104
|
+
end
|
105
|
+
|
106
|
+
@config.vendor_project(vendor_options)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def vendor_jars
|
111
|
+
jars = Dir[File.join(GRADLE_ROOT, 'dependencies/*.jar')]
|
112
|
+
jars.each do |jar|
|
113
|
+
@config.vendor_project(:jar => jar)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def android_gui_path
|
118
|
+
@android_gui_path ||= File.join(ENV['RUBYMOTION_ANDROID_SDK'], 'tools', 'android')
|
119
|
+
end
|
120
|
+
|
121
|
+
def extract_aars
|
122
|
+
aars = Dir[File.join(GRADLE_ROOT, "dependencies/**/*.aar")]
|
123
|
+
aar_dir = File.join(GRADLE_ROOT, 'aar')
|
124
|
+
FileUtils.mkdir_p(aar_dir)
|
125
|
+
aars.each do |aar|
|
126
|
+
filename = File.basename(aar, '.aar')
|
127
|
+
system("unzip -o -qq #{aar} -d #{aar_dir}/#{filename}")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
63
131
|
def generate_gradle_build_file
|
64
132
|
template_path = File.expand_path("../gradle.erb", __FILE__)
|
65
133
|
template = ERB.new(File.new(template_path).read, nil, "%")
|
@@ -89,22 +157,20 @@ module Motion::Project
|
|
89
157
|
{
|
90
158
|
name: name,
|
91
159
|
version: options.fetch(:version, '+'),
|
92
|
-
artifact: options.fetch(:artifact, name)
|
160
|
+
artifact: options.fetch(:artifact, name),
|
161
|
+
extension: options.fetch(:extension, false),
|
93
162
|
}
|
94
163
|
end
|
95
|
-
|
96
|
-
def inspect
|
97
|
-
@dependencies.map do |dependency|
|
98
|
-
"#{dependency[:name]} - #{dependency[:artifact]} (#{dependency[:version]})"
|
99
|
-
end.inspect
|
100
|
-
end
|
101
164
|
end
|
102
165
|
end
|
103
166
|
|
104
167
|
namespace :gradle do
|
105
168
|
desc "Download and build dependencies"
|
106
169
|
task :install do
|
107
|
-
|
170
|
+
root = Motion::Project::Gradle::GRADLE_ROOT
|
171
|
+
FileUtils.mkdir_p(root)
|
172
|
+
rm_rf(File.join(root, 'dependencies'))
|
173
|
+
rm_rf(File.join(root, 'aar'))
|
108
174
|
dependencies = App.config.gradle
|
109
175
|
dependencies.install!(true)
|
110
176
|
end
|
@@ -112,10 +178,10 @@ end
|
|
112
178
|
|
113
179
|
namespace :clean do
|
114
180
|
task :all do
|
115
|
-
|
116
|
-
if File.exist?(
|
117
|
-
App.info('Delete',
|
118
|
-
rm_rf(
|
181
|
+
root = Motion::Project::Gradle::GRADLE_ROOT
|
182
|
+
if File.exist?(root)
|
183
|
+
App.info('Delete', root)
|
184
|
+
rm_rf(root)
|
119
185
|
end
|
120
186
|
end
|
121
187
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-gradle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joffrey Jaffeux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: motion-gradle allows RubyMotion Android projects to have access to the
|
14
14
|
Gradle dependency manager.
|