motion-maven 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +86 -0
- data/lib/motion-maven.rb +2 -0
- data/lib/motion/project/maven.rb +169 -0
- data/lib/motion/project/version.rb +5 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 140346936cae80384ecfb1e7a7f4bc3d48fac9d1
|
4
|
+
data.tar.gz: 8681fcae9e4c5de403fb7ece4a274a35f7a21706
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bdd8f95c1adcc828b336a3a8d585c7691603200a2a3b274aed53a10ff4984b0b4f49a8d4f4f2927de112b67f5113eedd1acdf0c7680fd2df97d185b35f60d67
|
7
|
+
data.tar.gz: 47a09c105a72b255e867c78617b1918b60883bac2885177714a0219efa7f9cc448acb5967813f2b0cc3dc027742420aa0323ef6e0b4e32617178c094e4831859
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Joffrey Jaffeux
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# motion-maven
|
2
|
+
|
3
|
+
motion-maven allows RubyMotion projects to integrate with the
|
4
|
+
[Maven](http://maven.apache.org/) dependency manager.
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
You need to have maven installed :
|
10
|
+
|
11
|
+
```
|
12
|
+
$ brew install maven
|
13
|
+
```
|
14
|
+
|
15
|
+
And the gem installed :
|
16
|
+
|
17
|
+
```
|
18
|
+
$ [sudo] gem install motion-maven
|
19
|
+
```
|
20
|
+
|
21
|
+
Or if you use Bundler:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'motion-maven'
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Setup
|
29
|
+
|
30
|
+
1. Edit the `Rakefile` of your RubyMotion project and add the following require
|
31
|
+
lines:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'rubygems'
|
35
|
+
require 'motion-maven'
|
36
|
+
```
|
37
|
+
|
38
|
+
2. Still in the `Rakefile`, set your dependencies
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Motion::Project::App.setup do |app|
|
42
|
+
# ...
|
43
|
+
app.maven do
|
44
|
+
dependency 'com.mcxiaoke.volley', :artifact => 'library', :version => '1.0.10'
|
45
|
+
dependency 'commons-cli'
|
46
|
+
dependency 'ehcache', :version => '1.2.3'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
* Other options are : :scope, :type
|
52
|
+
|
53
|
+
* :version will default to : LATEST
|
54
|
+
|
55
|
+
* :artifact will default to dependency name
|
56
|
+
|
57
|
+
|
58
|
+
## Configuration
|
59
|
+
|
60
|
+
If the `mvn` command is not in your path, you can configure it :
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
Motion::Project::App.setup do |app|
|
64
|
+
# ...
|
65
|
+
app.maven.path = '/some/path/mvn'
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
## Tasks
|
70
|
+
|
71
|
+
To tell motion-maven to download your dependencies, run the following rake
|
72
|
+
task:
|
73
|
+
|
74
|
+
```
|
75
|
+
$ [bundle exec] rake maven:install
|
76
|
+
```
|
77
|
+
|
78
|
+
After a `rake:clean:all` you will need to run the install task agin.
|
79
|
+
|
80
|
+
That’s all.
|
81
|
+
|
82
|
+
|
83
|
+
## Todo
|
84
|
+
|
85
|
+
* Improve the pom.xml generated file, if you are a fine Maven connoisseur, feel free to help us.
|
86
|
+
* Improve edge cases.
|
data/lib/motion-maven.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
if Motion::Project::App.template != :android
|
6
|
+
raise "This file must be required within a RubyMotion Android project."
|
7
|
+
end
|
8
|
+
|
9
|
+
module Motion::Project
|
10
|
+
class Config
|
11
|
+
variable :maven
|
12
|
+
|
13
|
+
def maven(&block)
|
14
|
+
@maven ||= Motion::Project::Maven.new(self)
|
15
|
+
if block
|
16
|
+
@maven.instance_eval(&block)
|
17
|
+
end
|
18
|
+
@maven
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Maven
|
23
|
+
MAVEN_ROOT = 'vendor/Maven'
|
24
|
+
|
25
|
+
def initialize(config)
|
26
|
+
@maven_path = 'mvn'
|
27
|
+
@config = config
|
28
|
+
@dependencies = []
|
29
|
+
configure_project
|
30
|
+
end
|
31
|
+
|
32
|
+
def configure_project
|
33
|
+
@config.vendor_project(:jar => "#{MAVEN_ROOT}/target/dependencies.jar")
|
34
|
+
end
|
35
|
+
|
36
|
+
def path=(path)
|
37
|
+
@maven_path = path
|
38
|
+
end
|
39
|
+
|
40
|
+
def dependency(name, options = {})
|
41
|
+
@dependencies << normalized_dependency(name, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def install!(update)
|
45
|
+
generate_pom
|
46
|
+
system "#{maven_command} -f #{pom_path} clean install"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Helpers
|
50
|
+
def generate_pom
|
51
|
+
File.open(pom_path, 'w') do |io|
|
52
|
+
xml ||= <<EOS
|
53
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
54
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
55
|
+
<modelVersion>4.0.0</modelVersion>
|
56
|
+
<groupId>com.maventest</groupId>
|
57
|
+
<artifactId>dependencies</artifactId>
|
58
|
+
<packaging>jar</packaging>
|
59
|
+
<version>1.0</version>
|
60
|
+
<name>dependencies</name>
|
61
|
+
<url>http://maven.apache.org</url>
|
62
|
+
<dependencies>
|
63
|
+
EOS
|
64
|
+
|
65
|
+
@dependencies.each do |dependency|
|
66
|
+
xml << <<EOS
|
67
|
+
<dependency>
|
68
|
+
<groupId>#{dependency[:name]}</groupId>
|
69
|
+
<artifactId>#{dependency[:artifact]}</artifactId>
|
70
|
+
<version>#{dependency[:version]}</version>
|
71
|
+
EOS
|
72
|
+
|
73
|
+
if dependency[:scope]
|
74
|
+
xml << "<scope>#{dependency[:scope]}</scope>"
|
75
|
+
end
|
76
|
+
|
77
|
+
if dependency[:type]
|
78
|
+
xml << "<type>#{dependency[:type]}</type>"
|
79
|
+
end
|
80
|
+
|
81
|
+
xml << <<EOS
|
82
|
+
</dependency>
|
83
|
+
EOS
|
84
|
+
end
|
85
|
+
|
86
|
+
xml << <<EOS
|
87
|
+
</dependencies>
|
88
|
+
<build>
|
89
|
+
<plugins>
|
90
|
+
<plugin>
|
91
|
+
<groupId>org.apache.maven.plugins</groupId>
|
92
|
+
<artifactId>maven-shade-plugin</artifactId>
|
93
|
+
<executions>
|
94
|
+
<execution>
|
95
|
+
<phase>package</phase>
|
96
|
+
<goals>
|
97
|
+
<goal>shade</goal>
|
98
|
+
</goals>
|
99
|
+
</execution>
|
100
|
+
</executions>
|
101
|
+
<configuration>
|
102
|
+
<finalName>${project.artifactId}</finalName>
|
103
|
+
</configuration>
|
104
|
+
</plugin>
|
105
|
+
</plugins>
|
106
|
+
</build>
|
107
|
+
</project>
|
108
|
+
EOS
|
109
|
+
|
110
|
+
io.puts xml
|
111
|
+
end
|
112
|
+
|
113
|
+
system "xmllint --output #{pom_path} --format #{pom_path}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def pom_path
|
117
|
+
"#{MAVEN_ROOT}/pom.xml"
|
118
|
+
end
|
119
|
+
|
120
|
+
def maven_command
|
121
|
+
unless system("command -v #{@maven_path} >/dev/null")
|
122
|
+
$stderr.puts "[!] #{@maven_path} command doesn’t exist. Verify your maven installation."
|
123
|
+
exit 1
|
124
|
+
end
|
125
|
+
|
126
|
+
if ENV['MAVEN_DEBUG']
|
127
|
+
"#{@maven_path} -X"
|
128
|
+
else
|
129
|
+
"#{@maven_path}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def normalized_dependency(name, options)
|
134
|
+
{
|
135
|
+
name: name,
|
136
|
+
version: options.fetch(:version, 'LATEST'),
|
137
|
+
artifact: options.fetch(:artifact, name),
|
138
|
+
scope: options.fetch(:scope, false),
|
139
|
+
type: options.fetch(:type, false)
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
def inspect
|
144
|
+
@dependencies.map do |dependency|
|
145
|
+
"#{dependency[:name]} - #{dependency[:artifact]} (#{dependency[:version]})"
|
146
|
+
end.inspect
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
namespace :maven do
|
152
|
+
desc "Download and build dependencies"
|
153
|
+
task :install do
|
154
|
+
FileUtils.mkdir_p Motion::Project::Maven::MAVEN_ROOT
|
155
|
+
dependencies = App.config.maven
|
156
|
+
dependencies.install!(true)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
namespace :clean do
|
161
|
+
# This gets appended to the already existing clean:all task.
|
162
|
+
task :all do
|
163
|
+
dir = Motion::Project::Maven::MAVEN_ROOT
|
164
|
+
if File.exist?(dir)
|
165
|
+
App.info 'Delete', dir
|
166
|
+
rm_rf dir
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-maven
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joffrey Jaffeux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: motion-maven allows RubyMotion Android projects to have access to the
|
14
|
+
Maven dependency manager.
|
15
|
+
email: j.jaffeux@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- LICENSE
|
21
|
+
- README.md
|
22
|
+
- lib/motion-maven.rb
|
23
|
+
- lib/motion/project/maven.rb
|
24
|
+
- lib/motion/project/version.rb
|
25
|
+
homepage: http://www.rubymotion.com
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.2.2
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Maven integration for RubyMotion Android projects
|
49
|
+
test_files: []
|