naether 0.4.6-java → 0.5.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/lib/naether.rb +19 -3
- data/lib/naether/bootstrap.rb +119 -1
- data/{naether-0.4.4.jar → naether-0.5.0.jar} +0 -0
- data/pom.xml +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -12,9 +12,9 @@ gem install naether
|
|
12
12
|
|
13
13
|
=== About
|
14
14
|
|
15
|
-
Built
|
15
|
+
Built to power the {Buildr Resolver}[https://github.com/mguymon/buildr-resolver] for {Buildr}[https://github.com/apache/buildr],
|
16
16
|
enabling dependency resolution to Buildr projects. The Java {Naether.java}[https://github.com/mguymon/naether/blob/master/src/main/java/com/slackworks/naether/Naether.java]
|
17
|
-
is a basic wrapper for {Aether}[https://github.com/sonatype/sonatype-aether], Maven
|
17
|
+
is a basic wrapper for {Aether}[https://github.com/sonatype/sonatype-aether], Maven dependency resolution framework.
|
18
18
|
The Ruby {naether.rb}[https://github.com/mguymon/naether/blob/master/src/main/ruby/naether.rb] provides access to Java
|
19
19
|
from Ruby. JRuby is natively supported, other Ruby vms will use {Rjb}[http://rjb.rubyforge.org] to proxy over JNI.
|
20
20
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/naether.rb
CHANGED
@@ -72,10 +72,12 @@ class Naether
|
|
72
72
|
Naether::Java.convert_to_ruby_array(@resolver.getRemoteRepositories())
|
73
73
|
end
|
74
74
|
|
75
|
+
# Path to local maven repo
|
75
76
|
def local_repo_path
|
76
77
|
@resolver.getLocalRepoPath()
|
77
78
|
end
|
78
79
|
|
80
|
+
# Set path to local maven repo
|
79
81
|
def local_repo_path=( path )
|
80
82
|
@resolver.setLocalRepoPath( path )
|
81
83
|
end
|
@@ -85,6 +87,7 @@ class Naether
|
|
85
87
|
@resolver.addDependency( notation, scope )
|
86
88
|
end
|
87
89
|
|
90
|
+
# Add dependencies from a Maven POM
|
88
91
|
def add_pom_dependencies( pom_path, scopes=['compile'] )
|
89
92
|
if Naether.platform == 'java'
|
90
93
|
@resolver.addDependencies( pom_path, scopes )
|
@@ -97,7 +100,7 @@ class Naether
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
100
|
-
# Add a dependency Java object
|
103
|
+
# Add a dependency of org.sonatype.aether.graph.Dependency Java object
|
101
104
|
def add_dependency( dependency )
|
102
105
|
#@resolver.addDependency( dependency )
|
103
106
|
if Naether.platform == 'java'
|
@@ -129,7 +132,7 @@ class Naether
|
|
129
132
|
scopes = [dependent[key]]
|
130
133
|
end
|
131
134
|
|
132
|
-
add_pom_dependencies( key,
|
135
|
+
add_pom_dependencies( key, scopes )
|
133
136
|
|
134
137
|
# Add a dependency notation with scopes
|
135
138
|
else
|
@@ -154,15 +157,27 @@ class Naether
|
|
154
157
|
end
|
155
158
|
end
|
156
159
|
|
157
|
-
# Get dependencies
|
160
|
+
# Get array of dependencies
|
158
161
|
def dependencies()
|
159
162
|
Naether::Java.convert_to_ruby_array( @resolver.getDependencies() )
|
160
163
|
end
|
161
164
|
|
165
|
+
# Get array of dependencies as notation
|
162
166
|
def dependenciesNotation()
|
163
167
|
Naether::Java.convert_to_ruby_array(@resolver.getDependenciesNotation(), true)
|
164
168
|
end
|
165
169
|
|
170
|
+
def dependencies_classpath()
|
171
|
+
@resolver.getResolvedClassPath()
|
172
|
+
end
|
173
|
+
|
174
|
+
def load_dependencies_to_classpath
|
175
|
+
jars = dependencies_classpath.split(":")
|
176
|
+
Naether::Java.load_jars(jars)
|
177
|
+
|
178
|
+
jars
|
179
|
+
end
|
180
|
+
|
166
181
|
# Resolve dependencies, finding related additional dependencies
|
167
182
|
def resolve_dependencies( download_artifacts = true )
|
168
183
|
@resolver.resolveDependencies( download_artifacts );
|
@@ -234,6 +249,7 @@ class Naether
|
|
234
249
|
Naether::Java.convert_to_ruby_array( deps, true )
|
235
250
|
end
|
236
251
|
|
252
|
+
# Get the POM version
|
237
253
|
def pom_version( file_path=nil )
|
238
254
|
if file_path
|
239
255
|
load_pom( file_path )
|
data/lib/naether/bootstrap.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/java"
|
2
2
|
require 'yaml'
|
3
|
-
|
3
|
+
require 'open-uri'
|
4
|
+
require 'fileutils'
|
5
|
+
|
4
6
|
class Naether
|
5
7
|
# :title:Naether::Bootstrap
|
6
8
|
#
|
@@ -50,6 +52,122 @@ class Naether
|
|
50
52
|
dep = YAML.load_file( dep_file )
|
51
53
|
@@dependencies = dep[:dependencies]
|
52
54
|
end
|
55
|
+
|
56
|
+
def download_dependencies( dest, opts = {} )
|
57
|
+
|
58
|
+
if !File.exists? dest
|
59
|
+
FileUtils.mkdir_p( dest )
|
60
|
+
end
|
61
|
+
|
62
|
+
deps = {}
|
63
|
+
|
64
|
+
if opts[:deps]
|
65
|
+
deps[:missing] = opts[:deps]
|
66
|
+
else
|
67
|
+
deps = check_local_repo_for_deps( opts[:local_repo] )
|
68
|
+
end
|
69
|
+
|
70
|
+
deps[:downloaded] = []
|
71
|
+
|
72
|
+
puts "Downloading jars for Naether"
|
73
|
+
|
74
|
+
deps[:missing].each do |dep|
|
75
|
+
notation = dep.split(":")
|
76
|
+
group = notation[0].gsub("\.", File::SEPARATOR)
|
77
|
+
artifact = notation[1]
|
78
|
+
type = notation[2]
|
79
|
+
version = notation[3]
|
80
|
+
|
81
|
+
jar = "#{artifact}-#{version}.#{type}"
|
82
|
+
|
83
|
+
maven_path = "#{dest}#{File::SEPARATOR}#{jar}"
|
84
|
+
|
85
|
+
if !File.exists? maven_path
|
86
|
+
maven_mirror = "http://repo1.maven.org/maven2/#{group}/#{artifact}/#{version}/#{jar}"
|
87
|
+
|
88
|
+
open(maven_path, 'wb') do |io|
|
89
|
+
io.print open(maven_mirror).read
|
90
|
+
end
|
91
|
+
|
92
|
+
deps[:downloaded] << { dep => maven_path }
|
93
|
+
else
|
94
|
+
deps[:exists] << maven_path
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
deps
|
99
|
+
end
|
100
|
+
|
101
|
+
def check_local_repo_for_deps(local_repo = nil)
|
102
|
+
|
103
|
+
local_repo = local_repo || ENV['M2_HOME'] || '~/.m2/repository'
|
104
|
+
local_repo = File.expand_path(local_repo)
|
105
|
+
|
106
|
+
puts "Checking #{local_repo} for jars to bootstrap Naether"
|
107
|
+
|
108
|
+
deps = {:exists => [], :missing => [] }
|
109
|
+
|
110
|
+
# /home/zinger/.m2/repository/com/jcraft/jsch/0.1.44-1/jsch-0.1.44-1.jar
|
111
|
+
dependencies.each do |dep|
|
112
|
+
notation = dep.split(":")
|
113
|
+
group = notation[0].gsub("\.", File::SEPARATOR)
|
114
|
+
artifact = notation[1].gsub("\.", File::SEPARATOR)
|
115
|
+
type = notation[2]
|
116
|
+
version = notation[3]
|
117
|
+
|
118
|
+
jar = "#{artifact}-#{version}.#{type}"
|
119
|
+
|
120
|
+
maven_path = "#{local_repo}#{File::SEPARATOR}#{group}#{File::SEPARATOR}#{artifact}#{File::SEPARATOR}#{version}#{File::SEPARATOR}#{jar}"
|
121
|
+
|
122
|
+
if File.exists? maven_path
|
123
|
+
deps[:exists] << dep
|
124
|
+
else
|
125
|
+
deps[:missing] << dep
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
deps
|
131
|
+
end
|
132
|
+
|
133
|
+
def install_dependencies_to_local_repo( jars_or_dir, opts = {} )
|
134
|
+
|
135
|
+
deps = check_local_repo_for_deps(opts[:local_repo])
|
136
|
+
|
137
|
+
@naether = nil
|
138
|
+
jars = []
|
139
|
+
unless jars_or_dir.is_a? Array
|
140
|
+
@naether = Naether.create_from_paths( jars_or_dir, opts[:naether_jar_dir] )
|
141
|
+
jars = Dir.glob( "#{jars_or_dir}#{File::SEPARATOR}*.jar" )
|
142
|
+
else
|
143
|
+
@naether = Naether.create_from_jars( jars_or_dir )
|
144
|
+
jars = jars_or_dir
|
145
|
+
end
|
146
|
+
|
147
|
+
if opts[:local_repo]
|
148
|
+
@naether.local_repo_path = opts[:local_repo]
|
149
|
+
end
|
150
|
+
|
151
|
+
dependencies.each do |dep|
|
152
|
+
notation = dep.split(":")
|
153
|
+
group = notation[0].gsub("\.", File::SEPARATOR)
|
154
|
+
artifact = notation[1].gsub("\.", File::SEPARATOR)
|
155
|
+
type = notation[2]
|
156
|
+
version = notation[3]
|
157
|
+
|
158
|
+
name = "#{artifact}-#{version}.#{type}"
|
159
|
+
|
160
|
+
jar = jars.select { |x| x =~ /#{name}/ }
|
161
|
+
if jar.size > 0
|
162
|
+
jar = jar[0]
|
163
|
+
@naether.install_artifact( dep, jar )
|
164
|
+
else
|
165
|
+
puts "Could not find jar for #{dep}"
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
53
171
|
end
|
54
172
|
end
|
55
173
|
end
|
Binary file
|
data/pom.xml
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: naether
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.5.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Michael Guymon
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-11-20 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -74,7 +74,7 @@ files:
|
|
74
74
|
- lib/naether.rb
|
75
75
|
- lib/naether/bootstrap.rb
|
76
76
|
- lib/naether/java.rb
|
77
|
-
- naether-0.
|
77
|
+
- naether-0.5.0.jar
|
78
78
|
- pom.xml
|
79
79
|
has_rdoc: true
|
80
80
|
homepage: http://github.com/mguymon/naether
|