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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b7d1e21e00dcb477190eb7a6e0de2f36ee3b4e8
4
- data.tar.gz: b4e3be98c7c4387a6881efd07cc9c4a8274ec83e
3
+ metadata.gz: ab7bf0fb48a2a11c7185f459e73eb4c29a8cd5ed
4
+ data.tar.gz: ec1558bda34ca51e8685eff54ff71162b26c2975
5
5
  SHA512:
6
- metadata.gz: 77aff100b7a615b29353630e7a7581760ea669375ea3d5b7baed6a0c0d77af6f251846c424c591fd07475222a14afd8cc728fffc1e4e2ff13026abb460f6078e
7
- data.tar.gz: fac3b97a797b514fa2d5660dec7023a22fb5cbff17aa1912a67142c5180d74c873684cdffeaf4f8e36afd3e3f145e6b0bcbed1d24ecb21ea171750d695a07516
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 'com.mcxiaoke.volley', :artifact => 'library', :version => '1.0.10'
49
- dependency 'commons-cli'
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: Jar) {
5
- exclude 'META-INF/LICENSE'
6
- exclude 'META-INF/LICENSE.txt'
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
- def androidHome = System.getenv("RUBYMOTION_ANDROID_SDK")
17
- maven {
18
- url "$androidHome/extras/android/m2repository/"
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
- compile '<%= dependency[:name] %>:<%= dependency[:artifact] %>:<%= dependency[:version] %>'
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
- @config.vendor_project(:jar => "#{GRADLE_ROOT}/build/libs/dependencies.jar")
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
- @dependencies << normalized_dependency(name, options)
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, options = {})
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
- support_repository = File.join(ENV['RUBYMOTION_ANDROID_SDK'], 'extras', 'android', 'm2repository')
58
+ system("#{gradle_command} --build-file #{gradle_build_file} generateDependencies")
52
59
 
53
- unless File.exist?(support_repository)
54
- gui_path = File.join(ENV['RUBYMOTION_ANDROID_SDK'], 'tools', 'android')
55
- $stderr.puts("[!] To use motion-gradle you need to install `Extras/Android Support Repository`. Open the gui to install it : #{gui_path}")
56
- exit(1)
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
- system("#{gradle_command} --build-file #{gradle_build_file} generateDependencies")
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
- FileUtils.mkdir_p(Motion::Project::Gradle::GRADLE_ROOT)
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
- dir = Motion::Project::Gradle::GRADLE_ROOT
116
- if File.exist?(dir)
117
- App.info('Delete', dir)
118
- rm_rf(dir)
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
@@ -1,5 +1,5 @@
1
1
  module Motion::Project
2
2
  class Gradle
3
- VERSION = '1.0.5'
3
+ VERSION = '1.1.1'
4
4
  end
5
5
  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.0.5
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-04-16 00:00:00.000000000 Z
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.