motion-gradle 1.4.0 → 1.5.0

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: 2bfa047d9cd237d1a2b521e4b87ecedaf35641b3
4
- data.tar.gz: 17377bd105d6a6866313db0586e85d73648dc15d
3
+ metadata.gz: 50c2e48c77d0f368ee44667ae5d574c85ceb2c25
4
+ data.tar.gz: 577d8d409dd2fd063f9ca2d1e224561353279bfd
5
5
  SHA512:
6
- metadata.gz: 323045101d3e05a096e71ff0d6f5fbcccc4ae70ee42a54e496de34c14ff15a12faea2722300312efbd3c08888e5404e7b223c23e3c9abf4a0af792c0da0d80b6
7
- data.tar.gz: 08a1e6033cff5945ac5b3cad685b898fbbba1398e5513b59576a96a64b30df3452125613e3a2dc7cc9ce5d22879b4cbb4fa15500b67a4e5867b54ea8404a5904
6
+ metadata.gz: 98c82bdc75995ee8bfbe97bf5dda498089bf64b25350751aed15768ba5f8cb94727c698d1861dd7291b212ff6c3c66a822902618b71b0fe76081aa2f0646d600
7
+ data.tar.gz: 1492d7d43990043f70e0613af41ee12218a4a4be77308672902ac8ee9683d3ed36f39f40ee57366daaf840e7428c35ad3ec1fa7e10bb663c7ccff0bf221b69cc
data/README.md CHANGED
@@ -31,15 +31,14 @@ You also need to install `Extras/Android Support Repository` and `Extras/Google
31
31
 
32
32
  ## Setup
33
33
 
34
- 1. Edit the `Rakefile` of your RubyMotion project and add the following require
35
- lines:
34
+ Edit the `Rakefile` of your RubyMotion project and add the following require lines:
36
35
 
37
- ```ruby
38
- require 'rubygems'
39
- require 'motion-gradle'
40
- ```
36
+ ```ruby
37
+ require 'rubygems'
38
+ require 'motion-gradle'
39
+ ```
41
40
 
42
- 2. Still in the `Rakefile`, set your dependencies
41
+ ### Dependencies
43
42
 
44
43
  From version 1.1.0 you can use the same gradle dependency string that Java users use.
45
44
 
@@ -53,7 +52,7 @@ From version 1.1.0 you can use the same gradle dependency string that Java users
53
52
  end
54
53
  ```
55
54
 
56
- ## Configuration
55
+ ### Configuration
57
56
 
58
57
  If the `gradle` command is not found in your PATH, you can configure it:
59
58
 
@@ -64,7 +63,7 @@ Motion::Project::App.setup do |app|
64
63
  end
65
64
  ```
66
65
 
67
- You can also add other repositories :
66
+ ### Repositories :
68
67
 
69
68
  ```ruby
70
69
  Motion::Project::App.setup do |app|
@@ -76,7 +75,7 @@ Motion::Project::App.setup do |app|
76
75
  end
77
76
  ```
78
77
 
79
- ## Support for local libraries
78
+ ### Java libraries
80
79
 
81
80
  ```ruby
82
81
  Motion::Project::App.setup do |app|
@@ -89,6 +88,39 @@ end
89
88
 
90
89
  If relative path is used it's relative to your Rakefile, if you don't specify a path it will search in your_app/my_lib.
91
90
 
91
+ ### Plugins
92
+
93
+ ```ruby
94
+ Motion::Project::App.setup do |app|
95
+ # ...
96
+ app.gradle do
97
+ plugin 'com.google.gms.google-services'
98
+ end
99
+ end
100
+ ```
101
+
102
+ ### Classpaths
103
+
104
+ ```ruby
105
+ Motion::Project::App.setup do |app|
106
+ # ...
107
+ app.gradle do
108
+ classpath 'com.google.gms:google-services:1.3.0-beta1'
109
+ end
110
+ end
111
+ ```
112
+
113
+ ### Aidl
114
+
115
+ ```ruby
116
+ Motion::Project::App.setup do |app|
117
+ # ...
118
+ app.gradle do
119
+ aidl 'com.android.vending.billing', './vendor/IInAppBillingService.aidl'
120
+ end
121
+ end
122
+ ```
123
+
92
124
 
93
125
  ## Tasks
94
126
 
data/lib/motion-gradle.rb CHANGED
@@ -2,4 +2,5 @@ require 'pathname'
2
2
  require 'shellwords'
3
3
  require 'motion/project/legacy_dependency'
4
4
  require 'motion/project/gradle'
5
+ require 'motion/project/aidl'
5
6
  require 'motion/project/version'
@@ -0,0 +1,54 @@
1
+ class Aidl
2
+ def initialize(package, aidl_file_path)
3
+ @package = package
4
+ @aidl_file_path = File.expand_path(aidl_file_path)
5
+ end
6
+
7
+ def create_lib
8
+ create_lib_structure
9
+ create_gradle_build_file
10
+ create_manifest
11
+ end
12
+
13
+ def name
14
+ @name ||= File.basename(@aidl_file_path, '.aidl').downcase
15
+ end
16
+
17
+ def path
18
+ @path ||= File.join(Motion::Project::Gradle::GRADLE_ROOT, name)
19
+ end
20
+
21
+ protected
22
+
23
+ def create_manifest
24
+ io = File.new(File.join(path, 'src', 'main', 'AndroidManifest.xml'), "w")
25
+ io.puts("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"#{@package}\"></manifest>")
26
+ io.close
27
+ end
28
+
29
+ def create_gradle_build_file
30
+ locals = {last_build_tools_version: last_build_tools_version}
31
+ erb_template = generate_erb_template(File.expand_path("../aidl_build_gradle.erb", __FILE__), locals)
32
+ io = File.new(File.join(path, 'build.gradle',), "w")
33
+ io.puts(erb_template)
34
+ io.close
35
+ end
36
+
37
+ def create_lib_structure
38
+ aidl_file_dir = File.join(path, 'src', 'main', 'aidl', *@package.split('.'))
39
+ FileUtils.mkdir_p(aidl_file_dir)
40
+ FileUtils.cp(@aidl_file_path, aidl_file_dir)
41
+ end
42
+
43
+ def generate_erb_template(path, locals)
44
+ template_path = File.expand_path(path, __FILE__)
45
+ template = File.new(template_path).read
46
+ ERB.new(template).result(OpenStruct.new(locals).instance_eval { binding })
47
+ end
48
+
49
+ def last_build_tools_version
50
+ build_tools = File.join(ENV['RUBYMOTION_ANDROID_SDK'], 'build-tools')
51
+ builds_tools_directories = Dir.glob(File.join(build_tools, '*')).select {|f| File.directory? f}
52
+ File.basename(builds_tools_directories.last)
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ apply plugin: 'com.android.library'
2
+
3
+ buildscript {
4
+ repositories {
5
+ mavenCentral()
6
+ }
7
+ dependencies {
8
+ classpath 'com.android.tools.build:gradle:1.0.+'
9
+ }
10
+ }
11
+
12
+ android {
13
+ compileSdkVersion <%= App.config.api_version %>
14
+ buildToolsVersion "<%= last_build_tools_version %>"
15
+
16
+ defaultConfig {
17
+ minSdkVersion <%= App.config.api_version %>
18
+ targetSdkVersion <%= App.config.api_version %>
19
+ versionCode 1
20
+ versionName "1.0"
21
+ }
22
+ buildTypes {
23
+ release {
24
+ minifyEnabled false
25
+ }
26
+ }
27
+ }
@@ -1,5 +1,27 @@
1
+ buildscript {
2
+ repositories {
3
+ jcenter()
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ <% @classpaths.each do |classpath| %>
8
+ classpath '<%= classpath %>'
9
+ <% end %>
10
+ }
11
+ }
12
+
13
+ allprojects {
14
+ repositories {
15
+ jcenter()
16
+ mavenCentral()
17
+ }
18
+ }
19
+
1
20
  apply plugin: 'java'
2
21
  apply plugin: 'eclipse'
22
+ <% @plugins.each do |plugin| %>
23
+ apply plugin: '<%= plugin %>'
24
+ <% end %>
3
25
 
4
26
  task generateDependencies(type: Copy) {
5
27
  from sourceSets.main.runtimeClasspath
@@ -22,7 +44,6 @@ repositories {
22
44
  url "<%= url %>"
23
45
  }
24
46
  <% end %>
25
- mavenCentral()
26
47
  }
27
48
 
28
49
  dependencies {
@@ -23,12 +23,16 @@ module Motion::Project
23
23
  GRADLE_ROOT = 'vendor/Gradle'
24
24
  attr_reader :dependencies
25
25
  attr_reader :libraries
26
+ attr_reader :aidls
26
27
 
27
28
  def initialize(config)
28
29
  @gradle_path = '/usr/bin/env gradle'
29
30
  @config = config
31
+ @classpaths = []
32
+ @plugins = []
30
33
  @dependencies = []
31
34
  @repositories = []
35
+ @aidl_files = []
32
36
  @libraries = []
33
37
  configure_project
34
38
  end
@@ -62,11 +66,24 @@ module Motion::Project
62
66
  }
63
67
  end
64
68
 
69
+ def aidl(package, aidl_file_path)
70
+ @aidl_files << Aidl.new(package, aidl_file_path)
71
+ end
72
+
73
+ def classpath(classpath)
74
+ @classpaths << classpath
75
+ end
76
+
77
+ def plugin(plugin)
78
+ @plugins << plugin
79
+ end
80
+
65
81
  def repository(url)
66
82
  @repositories << url
67
83
  end
68
84
 
69
85
  def install!(update)
86
+ vendor_aidl_files
70
87
  generate_gradle_settings_file
71
88
  generate_gradle_build_file
72
89
  system("#{gradle_command} --build-file #{gradle_build_file} generateDependencies")
@@ -93,12 +110,21 @@ module Motion::Project
93
110
  end
94
111
 
95
112
  # Helpers
113
+ def vendor_aidl_files
114
+ @aidl_files.each do |aidl_file|
115
+ aidl_file.create_lib
116
+ library(aidl_file.name, path: aidl_file.path)
117
+ end
118
+ end
119
+
96
120
  def vendor_aars
97
121
  aars_dependendies = Dir[File.join(GRADLE_ROOT, 'aar/*')]
98
122
  aars_dependendies.each do |dependency|
99
123
  main_jar = File.join(dependency, 'classes.jar')
100
124
  if File.exist?(main_jar)
101
- vendor_options = {:jar => main_jar}
125
+ jar_path = File.join(dependency, "#{File.basename(dependency)}.jar")
126
+ FileUtils.mv(main_jar, jar_path)
127
+ vendor_options = {:jar => jar_path}
102
128
  else
103
129
  next
104
130
  end
@@ -148,7 +174,7 @@ module Motion::Project
148
174
  FileUtils.mkdir_p(aar_dir)
149
175
  aars.each do |aar|
150
176
  filename = File.basename(aar, '.aar')
151
- system("unzip -o -qq #{aar} -d #{aar_dir}/#{filename}")
177
+ system("/usr/bin/unzip -o -qq #{aar} -d #{ File.join(aar_dir, filename)}")
152
178
  end
153
179
  end
154
180
 
@@ -1,5 +1,5 @@
1
1
  module Motion::Project
2
2
  class Gradle
3
- VERSION = '1.4.0'
3
+ VERSION = '1.5.0'
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.4.0
4
+ version: 1.5.0
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-08-24 00:00:00.000000000 Z
11
+ date: 2015-09-24 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.
@@ -20,6 +20,8 @@ files:
20
20
  - LICENSE
21
21
  - README.md
22
22
  - lib/motion-gradle.rb
23
+ - lib/motion/project/aidl.rb
24
+ - lib/motion/project/aidl_build_gradle.erb
23
25
  - lib/motion/project/gradle.erb
24
26
  - lib/motion/project/gradle.rb
25
27
  - lib/motion/project/legacy_dependency.rb
@@ -45,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
47
  version: '0'
46
48
  requirements: []
47
49
  rubyforge_project:
48
- rubygems_version: 2.2.2
50
+ rubygems_version: 2.4.5
49
51
  signing_key:
50
52
  specification_version: 4
51
53
  summary: Gradle integration for RubyMotion Android projects