naether 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/core-0.10.0.jar +0 -0
- data/lib/naether.rb +33 -6
- data/lib/naether/bootstrap.rb +37 -6
- data/lib/naether/configuration.rb +5 -1
- data/lib/naether/java.rb +63 -12
- data/lib/naether/java/jruby.rb +39 -14
- data/lib/naether/java/ruby.rb +69 -16
- data/lib/naether/maven.rb +1 -1
- data/lib/naether/notation.rb +42 -0
- data/pom.xml +9 -114
- metadata +6 -118
- data/naether-0.9.2.jar +0 -0
data/README.md
CHANGED
@@ -11,7 +11,7 @@ that can be used by Ruby or Java.
|
|
11
11
|
|
12
12
|
### Ruby
|
13
13
|
|
14
|
-
JRuby 1.6.
|
14
|
+
JRuby 1.6.8 is natively supported. Ruby 1.8.7 and 1.9.3 use [Rjb](http://rjb.rubyforge.org) to proxy over JNI.
|
15
15
|
|
16
16
|
gem install naether
|
17
17
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
data/core-0.10.0.jar
ADDED
Binary file
|
data/lib/naether.rb
CHANGED
@@ -17,10 +17,11 @@ require "#{File.dirname(__FILE__)}/naether/configuration"
|
|
17
17
|
require "#{File.dirname(__FILE__)}/naether/bootstrap"
|
18
18
|
require "#{File.dirname(__FILE__)}/naether/java"
|
19
19
|
|
20
|
-
|
21
|
-
# Java dependency resolver
|
20
|
+
#
|
21
|
+
# Java dependency resolver
|
22
22
|
#
|
23
23
|
# @author Michael Guymon
|
24
|
+
# @see https://github.com/mguymon/naether/tree/master/core
|
24
25
|
#
|
25
26
|
class Naether
|
26
27
|
|
@@ -28,7 +29,7 @@ class Naether
|
|
28
29
|
|
29
30
|
class << self
|
30
31
|
|
31
|
-
#
|
32
|
+
# List of Java dependencies needed to bootstrap Naether
|
32
33
|
#
|
33
34
|
# @param [String] dep_file path
|
34
35
|
# @see {Naether::Bootstrap#dependencies}
|
@@ -57,7 +58,7 @@ class Naether
|
|
57
58
|
|
58
59
|
# Create new instance.
|
59
60
|
def initialize
|
60
|
-
@resolver = Naether::Java.create('com.tobedevoured.naether.
|
61
|
+
@resolver = Naether::Java.create('com.tobedevoured.naether.impl.NaetherImpl')
|
61
62
|
end
|
62
63
|
|
63
64
|
# Clear all remote repositories
|
@@ -250,7 +251,7 @@ class Naether
|
|
250
251
|
#
|
251
252
|
# @return [Array]
|
252
253
|
def dependencies
|
253
|
-
Naether::Java.convert_to_ruby_array( @resolver.
|
254
|
+
Naether::Java.convert_to_ruby_array( @resolver.currentDependencies() )
|
254
255
|
end
|
255
256
|
|
256
257
|
# Get array of dependencies as notation
|
@@ -271,11 +272,37 @@ class Naether
|
|
271
272
|
# Convert dependencies to Classpath friendly string
|
272
273
|
#
|
273
274
|
# @return [String]
|
274
|
-
def dependencies_classpath
|
275
|
+
def dependencies_classpath
|
275
276
|
@resolver.getResolvedClassPath()
|
276
277
|
end
|
277
278
|
|
279
|
+
# Dependencies as a Graph of nested Hashes
|
280
|
+
#
|
281
|
+
# @return [Hash]
|
282
|
+
def dependencies_graph(nodes=nil)
|
283
|
+
nodes = @resolver.getDependenciesGraph() unless nodes
|
284
|
+
|
285
|
+
graph = {}
|
286
|
+
if Naether.platform == 'java'
|
287
|
+
nodes.each do |k,v|
|
288
|
+
deps = dependencies_graph(v)
|
289
|
+
graph[k] = Naether::Java.convert_to_ruby_hash( deps )
|
290
|
+
end
|
291
|
+
else
|
292
|
+
iterator = nodes.entrySet().iterator();
|
293
|
+
while iterator.hasNext()
|
294
|
+
entry = iterator.next()
|
295
|
+
deps = dependencies_graph(entry.getValue())
|
296
|
+
graph[entry.getKey().toString()] = Naether::Java.convert_to_ruby_hash( deps )
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
graph
|
301
|
+
end
|
302
|
+
|
278
303
|
# Load dependencies to Classpath
|
304
|
+
#
|
305
|
+
# @return [Array] of loaded jars
|
279
306
|
def load_dependencies_to_classpath
|
280
307
|
jars = dependencies_classpath.split(":")
|
281
308
|
Naether::Java.load_jars(jars)
|
data/lib/naether/bootstrap.rb
CHANGED
@@ -5,12 +5,11 @@ require 'open-uri'
|
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
7
|
class Naether
|
8
|
-
|
8
|
+
|
9
9
|
#
|
10
10
|
# Helper for bootstrapping Naether
|
11
11
|
#
|
12
|
-
#
|
13
|
-
# Michael Guymon
|
12
|
+
# @author Michael Guymon
|
14
13
|
#
|
15
14
|
class Bootstrap
|
16
15
|
|
@@ -18,11 +17,14 @@ class Naether
|
|
18
17
|
|
19
18
|
class << self
|
20
19
|
|
20
|
+
# Default local repo of ENV['M2_REPO'] or ~/.m2/repository
|
21
|
+
#
|
22
|
+
# @return [String]
|
21
23
|
def default_local_repo
|
22
24
|
ENV['M2_REPO'] || File.expand_path('~/.m2/repository')
|
23
25
|
end
|
24
26
|
|
25
|
-
#
|
27
|
+
# Write bootstrap dependencies to yaml file
|
26
28
|
def write_dependencies( dest = 'jar_dependencies.yml' )
|
27
29
|
deps = {};
|
28
30
|
if Naether::Configuration.platform == 'java'
|
@@ -37,7 +39,11 @@ class Naether
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
# List of Java dependencies for Naether
|
42
|
+
# List of Java dependencies for Naether from yaml dependency file. Caches
|
43
|
+
# result after first run.
|
44
|
+
#
|
45
|
+
# @param [String] dep_file path, defaults to Naether::Configuration.dependencies_yml
|
46
|
+
# @return [List]
|
41
47
|
def dependencies( dep_file=nil )
|
42
48
|
|
43
49
|
if @@dependencies
|
@@ -53,6 +59,11 @@ class Naether
|
|
53
59
|
end
|
54
60
|
|
55
61
|
|
62
|
+
#
|
63
|
+
# Bootstrap the local repo by downloading Naether's dependencies
|
64
|
+
# @param [String] local_repo defaults to #default_local_repo
|
65
|
+
# @param [hash] opts
|
66
|
+
#
|
56
67
|
def bootstrap_local_repo(local_repo = nil, opts = {} )
|
57
68
|
local_repo = local_repo || default_local_repo
|
58
69
|
|
@@ -71,10 +82,16 @@ class Naether
|
|
71
82
|
install_dependencies_to_local_repo( deps[:downloaded], jars, opts )
|
72
83
|
end
|
73
84
|
|
74
|
-
#raise Naether::Java.
|
85
|
+
#raise Naether::Java.internal_loaded_paths.inspect
|
75
86
|
|
76
87
|
end
|
77
88
|
|
89
|
+
#
|
90
|
+
# Download Naether dependencies
|
91
|
+
#
|
92
|
+
# @param [String] dest to download dependencies t
|
93
|
+
# @param [Hash] opts
|
94
|
+
# @return [Hash] with status of missing, downloaded, exists dependencies
|
78
95
|
def download_dependencies( dest, opts = {} )
|
79
96
|
|
80
97
|
if !File.exists? dest
|
@@ -121,6 +138,12 @@ class Naether
|
|
121
138
|
deps
|
122
139
|
end
|
123
140
|
|
141
|
+
#
|
142
|
+
# Check local_repo for Naether dependencies
|
143
|
+
#
|
144
|
+
# @param [String] local_repo
|
145
|
+
# @param [Hash] opts
|
146
|
+
# @return [Hash] with status of missing, downloaded, exists dependencies
|
124
147
|
def check_local_repo_for_deps(local_repo = nil, opts = {} )
|
125
148
|
|
126
149
|
local_repo = local_repo || default_local_repo
|
@@ -151,6 +174,14 @@ class Naether
|
|
151
174
|
deps
|
152
175
|
end
|
153
176
|
|
177
|
+
#
|
178
|
+
# Install Naether Dependencies to local_repo
|
179
|
+
#
|
180
|
+
# @param [Array<String>] install_jars
|
181
|
+
# @param [Array<String>] naether_jars to bootstrap Naether. These may overlap with install_jars.
|
182
|
+
# @param [Hash] opts
|
183
|
+
# @return [Naether]
|
184
|
+
#
|
154
185
|
def install_dependencies_to_local_repo( install_jars, naether_jars, opts = {} )
|
155
186
|
|
156
187
|
require "#{File.dirname(__FILE__)}/../naether"
|
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
2
|
class Naether
|
3
|
+
|
4
|
+
#
|
5
|
+
# Naether runtime configuration
|
6
|
+
#
|
3
7
|
class Configurator
|
4
8
|
def initialize(data={})
|
5
9
|
gem_dir = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
@@ -19,7 +23,7 @@ class Naether
|
|
19
23
|
|
20
24
|
@data = {
|
21
25
|
:gem_dir => gem_dir,
|
22
|
-
:naether_jar => File.join( gem_dir, "
|
26
|
+
:naether_jar => File.join( gem_dir, "core-#{version}.jar"),
|
23
27
|
:platform => ($platform || RUBY_PLATFORM[/java/] || 'ruby'),
|
24
28
|
:version => version,
|
25
29
|
:dependencies_yml => File.expand_path("#{File.dirname( __FILE__ )}/../../jar_dependencies.yml")
|
data/lib/naether/java.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
require "#{File.dirname(__FILE__)}/configuration"
|
3
3
|
|
4
|
-
# :title:Naether::Java
|
5
4
|
#
|
6
|
-
# Handles loading jars
|
5
|
+
# Handles loading jars using the correct platform, Naether::Java::JRuby
|
7
6
|
# or Naether::Java::Ruby
|
8
7
|
#
|
9
|
-
#
|
10
|
-
# Michael Guymon
|
8
|
+
# @author Michael Guymon
|
11
9
|
#
|
12
10
|
class Naether
|
13
11
|
class Java
|
@@ -15,6 +13,10 @@ class Naether
|
|
15
13
|
|
16
14
|
attr_reader :java
|
17
15
|
|
16
|
+
#
|
17
|
+
# Creates new instance by loading the Naether jar to the parent ClassLoader
|
18
|
+
# and creating the internal Naether ClassLoader
|
19
|
+
#
|
18
20
|
def initialize()
|
19
21
|
naether_jar = Naether::Configuration.naether_jar
|
20
22
|
|
@@ -24,44 +26,93 @@ class Naether
|
|
24
26
|
|
25
27
|
if Naether::Configuration.platform == 'java'
|
26
28
|
require "#{File.dirname(__FILE__)}/java/jruby"
|
27
|
-
@java = Naether::Java::JRuby.
|
29
|
+
@java = Naether::Java::JRuby.new
|
28
30
|
else
|
29
31
|
require "#{File.dirname(__FILE__)}/java/ruby"
|
30
|
-
@java = Naether::Java::Ruby.
|
32
|
+
@java = Naether::Java::Ruby.new
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
#
|
34
37
|
# Paths loaded
|
38
|
+
#
|
39
|
+
# @return [Array] of String paths
|
40
|
+
#
|
35
41
|
def self.loaded_paths
|
36
42
|
instance.java.loaded_paths
|
37
43
|
end
|
38
44
|
|
39
|
-
#
|
45
|
+
#
|
46
|
+
# Load a path onto the parent ClassLoader
|
47
|
+
#
|
48
|
+
# @param [Array] paths as an Array of String paths or a String path
|
49
|
+
#
|
40
50
|
def self.load_paths(paths)
|
41
51
|
instance.java.load_paths(paths)
|
42
52
|
end
|
43
53
|
|
44
|
-
|
54
|
+
def self.internal_loaded_paths
|
55
|
+
convert_to_ruby_array( instance.java.class_loader.getLoadedPaths, true )
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Load a path into the internal Naether ClassLoader
|
60
|
+
#
|
61
|
+
# @param [Array] paths as an Array of String paths or a String path
|
62
|
+
#
|
45
63
|
def self.internal_load_paths(paths)
|
46
64
|
instance.java.internal_load_paths(paths)
|
47
65
|
end
|
48
|
-
|
66
|
+
|
67
|
+
#
|
68
|
+
# Create a Java Object from the Naether Class Loader
|
69
|
+
#
|
70
|
+
# @param [String] target_class to create
|
71
|
+
# @param [Array] args Array of constructor arguments
|
49
72
|
def self.create( target_class, *args )
|
50
73
|
instance.java.create( target_class, *args )
|
51
74
|
end
|
52
75
|
|
53
|
-
|
54
|
-
|
76
|
+
#
|
77
|
+
# Execute a Staic method on a Java class from the Naether Class Loader
|
78
|
+
#
|
79
|
+
# @param [String] target_class
|
80
|
+
# @param [String] target_method
|
81
|
+
# @param [Array] params Array of method parameters
|
82
|
+
# @param [Array] types if defined, a Array of String classes of params type that lines up with params one to one.
|
83
|
+
# @return [Object]
|
84
|
+
def self.exec_static_method( target_class, target_method, params, types = nil )
|
85
|
+
instance.java.exec_static_method( target_class, target_method, params, types )
|
55
86
|
end
|
56
87
|
|
88
|
+
#
|
89
|
+
# Convert a Ruby Array to a java.util.ArrayList
|
90
|
+
#
|
91
|
+
# @param [Array] ruby_array to convert to Java.util.ArrayList
|
92
|
+
# @return [java.util.ArrayList]
|
93
|
+
#
|
57
94
|
def self.convert_to_java_list( ruby_array )
|
58
95
|
instance.java.convert_to_java_list( ruby_array )
|
59
96
|
end
|
60
97
|
|
98
|
+
#
|
99
|
+
# Convert a java,util.List to a Ruby Array
|
100
|
+
#
|
101
|
+
# @param [java.util.ArrayList] java_array
|
102
|
+
# @param [Boolean] to_string platform dependent helper
|
103
|
+
# @return [Array]
|
104
|
+
#
|
61
105
|
def self.convert_to_ruby_array( java_array, to_string = false )
|
62
106
|
instance.java.convert_to_ruby_array( java_array, to_string )
|
63
107
|
end
|
64
|
-
|
108
|
+
|
109
|
+
#
|
110
|
+
# Convert a java.util.Map to a Ruby Hash
|
111
|
+
#
|
112
|
+
# @param [java.util.Map] java_hash
|
113
|
+
# @param [Boolean] to_string platform dependent helper
|
114
|
+
# @return [Hash]
|
115
|
+
#
|
65
116
|
def self.convert_to_ruby_hash( java_hash, to_string = false )
|
66
117
|
instance.java.convert_to_ruby_hash( java_hash, to_string )
|
67
118
|
end
|
data/lib/naether/java/jruby.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../configuration"
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
# Singletn that handles Java interactions for JRuby. Providers helpers for
|
3
|
+
|
4
|
+
# Handles Java interactions for JRuby. Providers helpers for
|
6
5
|
# nomalizing accesss.
|
7
6
|
|
8
|
-
#
|
9
|
-
# Michael Guymon
|
7
|
+
# @author Michael Guymon
|
10
8
|
#
|
11
9
|
class Naether
|
12
10
|
class Java
|
13
11
|
|
14
12
|
class JRuby
|
15
|
-
include Singleton
|
16
13
|
|
17
14
|
attr_reader :loaded_paths, :class_loader
|
18
15
|
|
19
16
|
#
|
20
|
-
# Creates new instance by loading the Naether jar to the
|
17
|
+
# Creates new instance by loading the Naether jar to the parent ClassLoader
|
21
18
|
# and creating the internal Naether ClassLoader
|
22
19
|
#
|
23
20
|
def initialize
|
@@ -33,15 +30,22 @@ class Naether
|
|
33
30
|
end
|
34
31
|
|
35
32
|
#
|
36
|
-
# Create a Java Object
|
33
|
+
# Create a Java Object from the Naether Class Loader
|
37
34
|
#
|
35
|
+
# @param [String] target_class to create
|
36
|
+
# @param [Array] args Array of constructor arguments
|
38
37
|
def create( target_class, *args )
|
39
38
|
@class_loader.newInstance(target_class, *args )
|
40
39
|
end
|
41
40
|
|
42
41
|
#
|
43
|
-
# Execute a Staic method on a Java class
|
42
|
+
# Execute a Staic method on a Java class from the Naether Class Loader
|
44
43
|
#
|
44
|
+
# @param [String] target_class
|
45
|
+
# @param [String] target_method
|
46
|
+
# @param [Array] params Array of method parameters
|
47
|
+
# @param [Array] types if defined, a Array of String classes of params type that lines up with params one to one.
|
48
|
+
# @return [Object]
|
45
49
|
def exec_static_method( target_class, target_method, params, types = nil )
|
46
50
|
unless params.is_a? Array
|
47
51
|
params = [params]
|
@@ -59,6 +63,8 @@ class Naether
|
|
59
63
|
#
|
60
64
|
# Load a path into the internal Naether ClassLoader
|
61
65
|
#
|
66
|
+
# @param [Array] paths as an Array of String paths or a String path
|
67
|
+
#
|
62
68
|
def internal_load_paths(paths)
|
63
69
|
load_paths = []
|
64
70
|
unless paths.is_a? Array
|
@@ -78,7 +84,9 @@ class Naether
|
|
78
84
|
end
|
79
85
|
|
80
86
|
#
|
81
|
-
# Load a path onto the
|
87
|
+
# Load a path onto the parent ClassLoader
|
88
|
+
#
|
89
|
+
# @param [Array] paths as an Array of String paths or a String path
|
82
90
|
#
|
83
91
|
def load_paths(paths)
|
84
92
|
load_paths = []
|
@@ -99,7 +107,10 @@ class Naether
|
|
99
107
|
end
|
100
108
|
|
101
109
|
#
|
102
|
-
# Convert a Ruby Array to a
|
110
|
+
# Convert a Ruby Array to a java.util.ArrayList
|
111
|
+
#
|
112
|
+
# @param [Array] ruby_array Array to convert to Java.util.ArrayList
|
113
|
+
# @return [java.util.ArrayList]
|
103
114
|
#
|
104
115
|
def convert_to_java_list( ruby_array )
|
105
116
|
list = java.util.ArrayList.new
|
@@ -111,17 +122,31 @@ class Naether
|
|
111
122
|
end
|
112
123
|
|
113
124
|
#
|
114
|
-
# Convert a
|
125
|
+
# Convert a java,util.List to a Ruby Array
|
126
|
+
#
|
127
|
+
# @param [java.util.ArrayList] java_array
|
128
|
+
# @param [Boolean] to_string has no affect on conversion.
|
129
|
+
# @return [Array]
|
115
130
|
#
|
116
131
|
def convert_to_ruby_array( java_array, to_string = false )
|
117
132
|
java_array.to_a
|
118
133
|
end
|
119
134
|
|
120
135
|
#
|
121
|
-
# Convert a
|
136
|
+
# Convert a java.util.Map to a Ruby Hash
|
137
|
+
#
|
138
|
+
# @param [java.util.Map] java_hash
|
139
|
+
# @param [Boolean] to_string has no affect on conversion
|
140
|
+
# @return [Hash]
|
122
141
|
#
|
123
142
|
def convert_to_ruby_hash( java_hash, to_string = false )
|
124
|
-
java_hash.to_hash
|
143
|
+
hash = java_hash.to_hash
|
144
|
+
|
145
|
+
hash.each do |k,v|
|
146
|
+
if v.is_a? java.util.Map
|
147
|
+
hash[k] = convert_to_ruby_hash(v, to_string )
|
148
|
+
end
|
149
|
+
end
|
125
150
|
end
|
126
151
|
|
127
152
|
end
|
data/lib/naether/java/ruby.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../configuration"
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# Sngleton that handles Java interactions for Ruby using RJB. Providers helpers for
|
3
|
+
# Handles Java interactions for Ruby using RJB. Providers helpers for
|
6
4
|
# nomalizing accesss.
|
7
5
|
#
|
8
|
-
#
|
9
|
-
# Michael Guymon
|
6
|
+
# @author Michael Guymon
|
10
7
|
#
|
11
8
|
class Naether
|
12
9
|
class Java
|
13
10
|
|
14
11
|
class Ruby
|
15
|
-
include Singleton
|
16
12
|
|
17
13
|
attr_reader :loaded_paths, :class_loader
|
18
14
|
|
15
|
+
#
|
16
|
+
# Creates new instance by loading the Naether jar to the parent ClassLoader
|
17
|
+
# and creating the internal Naether ClassLoader
|
18
|
+
#
|
19
19
|
def initialize
|
20
20
|
require 'rjb'
|
21
21
|
|
@@ -35,6 +35,11 @@ class Naether
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
+
#
|
39
|
+
# Create a Java Object from the Naether Class Loader
|
40
|
+
#
|
41
|
+
# @param [String] target_class to create
|
42
|
+
# @param [Array] args Array of constructor arguments
|
38
43
|
def create( target_class, *args )
|
39
44
|
#@class_loader.newInstance(target_class, *args )
|
40
45
|
if args.size > 0
|
@@ -44,6 +49,14 @@ class Naether
|
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
52
|
+
#
|
53
|
+
# Execute a Staic method on a Java class from the Naether Class Loader
|
54
|
+
#
|
55
|
+
# @param [String] target_class
|
56
|
+
# @param [String] target_method
|
57
|
+
# @param [Array] params Array of method parameters
|
58
|
+
# @param [Array] types if defined, a Array of String classes of params type that lines up with params one to one.
|
59
|
+
# @return [Object]
|
47
60
|
def exec_static_method( target_class, target_method, params, types = nil )
|
48
61
|
unless params.is_a? Array
|
49
62
|
params = [params]
|
@@ -72,7 +85,12 @@ class Naether
|
|
72
85
|
end
|
73
86
|
end
|
74
87
|
end
|
75
|
-
|
88
|
+
|
89
|
+
#
|
90
|
+
# Load a path into the internal Naether ClassLoader
|
91
|
+
#
|
92
|
+
# @param [Array] paths as an Array of String paths or a String path
|
93
|
+
#
|
76
94
|
def internal_load_paths(paths)
|
77
95
|
loadable_paths = []
|
78
96
|
unless paths.is_a? Array
|
@@ -90,6 +108,11 @@ class Naether
|
|
90
108
|
loadable_paths
|
91
109
|
end
|
92
110
|
|
111
|
+
#
|
112
|
+
# Load a path onto the parent ClassLoader
|
113
|
+
#
|
114
|
+
# @param [Array] paths as an Array of String paths or a String path
|
115
|
+
#
|
93
116
|
def load_paths(paths)
|
94
117
|
loadable_paths = []
|
95
118
|
unless paths.is_a? Array
|
@@ -108,6 +131,12 @@ class Naether
|
|
108
131
|
loadable_paths
|
109
132
|
end
|
110
133
|
|
134
|
+
#
|
135
|
+
# Convert a Ruby Array to a java.util.ArrayList
|
136
|
+
#
|
137
|
+
# @param [Array] ruby_array Array to convert to Java.util.ArrayList
|
138
|
+
# @return [java.util.ArrayList]
|
139
|
+
#
|
111
140
|
def convert_to_java_list( ruby_array )
|
112
141
|
list = Rjb::import("java.util.ArrayList").new
|
113
142
|
ruby_array.each do |item|
|
@@ -117,6 +146,13 @@ class Naether
|
|
117
146
|
list
|
118
147
|
end
|
119
148
|
|
149
|
+
#
|
150
|
+
# Convert a java,util.List to a Ruby Array
|
151
|
+
#
|
152
|
+
# @param [java.util.ArrayList] java_array
|
153
|
+
# @param [Boolean] to_string converts each element using toString
|
154
|
+
# @return [Array]
|
155
|
+
#
|
120
156
|
def convert_to_ruby_array( java_array, to_string = false )
|
121
157
|
ruby_array = java_array.toArray()
|
122
158
|
|
@@ -127,20 +163,37 @@ class Naether
|
|
127
163
|
ruby_array
|
128
164
|
end
|
129
165
|
|
166
|
+
#
|
167
|
+
# Convert a java.util.Map to a Ruby Hash
|
168
|
+
#
|
169
|
+
# @param [java.util.Map] java_hash
|
170
|
+
# @param [Boolean] to_string converts each element using toString
|
171
|
+
# @return [Hash]
|
172
|
+
#
|
130
173
|
def convert_to_ruby_hash( java_hash, to_string = false )
|
131
174
|
|
132
175
|
hash = {}
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
176
|
+
unless java_hash.is_a? Hash
|
177
|
+
keys = java_hash.keySet()
|
178
|
+
iterator = keys.iterator()
|
179
|
+
if to_string
|
180
|
+
while iterator.hasNext()
|
181
|
+
key = iterator.next().toString()
|
182
|
+
hash[key] = java_hash.get( key ).toString()
|
183
|
+
end
|
184
|
+
else
|
185
|
+
while iterator.hasNext()
|
186
|
+
key = iterator.next()
|
187
|
+
hash[key] = java_hash.get( key )
|
188
|
+
end
|
139
189
|
end
|
140
190
|
else
|
141
|
-
|
142
|
-
|
143
|
-
|
191
|
+
if to_string
|
192
|
+
java_hash.each do |k,v|
|
193
|
+
hash[k.toString()] = v.toString()
|
194
|
+
end
|
195
|
+
else
|
196
|
+
hash = java_hash
|
144
197
|
end
|
145
198
|
end
|
146
199
|
|
data/lib/naether/maven.rb
CHANGED
@@ -130,7 +130,7 @@ class Naether
|
|
130
130
|
|
131
131
|
# Load dependencies and remote repo from a {Naether} instance
|
132
132
|
def load_naether( naether )
|
133
|
-
self.dependencies= naether.resolver.
|
133
|
+
self.dependencies= naether.resolver.currentDependencies()
|
134
134
|
self.repositories= naether.resolver.getRemoteRepositoryUrls()
|
135
135
|
end
|
136
136
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Naether
|
2
|
+
|
3
|
+
#
|
4
|
+
# Helper for handling Maven notations, supports notations:
|
5
|
+
# * artifactId:groupId:version
|
6
|
+
# * artifactId:groupId:type:version
|
7
|
+
# * artifactId:groupId:type:classifier:version
|
8
|
+
#
|
9
|
+
class Notation
|
10
|
+
attr_reader :group, :artifact, :version, :classifier, :type
|
11
|
+
|
12
|
+
PATTERN = Regexp.compile( '^(.+?):(.+?):(.+?)(:(.+?)(:(.+))?)?$' )
|
13
|
+
|
14
|
+
def initialize(notation)
|
15
|
+
if notation =~ PATTERN
|
16
|
+
@group = Regexp.last_match(1)
|
17
|
+
@artifact = Regexp.last_match(2)
|
18
|
+
|
19
|
+
# artifactId:groupId:type:classifier:version
|
20
|
+
if Regexp.last_match(7)
|
21
|
+
@type = Regexp.last_match(3)
|
22
|
+
@classifier = Regexp.last_match(5)
|
23
|
+
@version = Regexp.last_match(7)
|
24
|
+
|
25
|
+
# artifactId:groupId:type:version
|
26
|
+
elsif Regexp.last_match(5)
|
27
|
+
@type = Regexp.last_match(3)
|
28
|
+
@version = Regexp.last_match(5)
|
29
|
+
# artifactId:groupId:version -
|
30
|
+
else
|
31
|
+
@type = 'jar'
|
32
|
+
@version = Regexp.last_match(3)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_notation
|
38
|
+
"#{group}:#{artifact}:#{type}#{":#{classifier}" if classifier}:#{version}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/pom.xml
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
2
2
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
3
|
+
<parent>
|
4
|
+
<groupId>com.tobedevoured.naether</groupId>
|
5
|
+
<artifactId>parent</artifactId>
|
6
|
+
<version>0.10.0</version>
|
7
|
+
</parent>
|
3
8
|
<modelVersion>4.0.0</modelVersion>
|
4
|
-
<
|
5
|
-
<artifactId>naether</artifactId>
|
9
|
+
<artifactId>core</artifactId>
|
6
10
|
<name>Naether</name>
|
7
11
|
<packaging>jar</packaging>
|
8
|
-
<
|
9
|
-
<url>https://github.com/mguymon/naether</url>
|
12
|
+
<url>https://github.com/mguymon/naether</url>
|
10
13
|
<description>
|
11
14
|
A Java Dependency Resolver using Maven’s Aether.
|
12
15
|
</description>
|
@@ -50,13 +53,9 @@
|
|
50
53
|
</properties>
|
51
54
|
|
52
55
|
<dependencies>
|
56
|
+
|
53
57
|
<!-- Logging -->
|
54
58
|
<dependency>
|
55
|
-
<groupId>ch.qos.logback</groupId>
|
56
|
-
<artifactId>logback-classic</artifactId>
|
57
|
-
<version>1.0.6</version>
|
58
|
-
</dependency>
|
59
|
-
<dependency>
|
60
59
|
<groupId>org.slf4j</groupId>
|
61
60
|
<artifactId>jcl-over-slf4j</artifactId>
|
62
61
|
<version>${org.slf4j.version}</version>
|
@@ -130,111 +129,7 @@
|
|
130
129
|
<artifactId>wagon-file</artifactId>
|
131
130
|
<version>${wagonVersion}</version>
|
132
131
|
</dependency>
|
133
|
-
|
134
|
-
<!-- Testing -->
|
135
|
-
<dependency>
|
136
|
-
<groupId>junit</groupId>
|
137
|
-
<artifactId>junit</artifactId>
|
138
|
-
<version>4.10</version>
|
139
|
-
<scope>test</scope>
|
140
|
-
</dependency>
|
132
|
+
|
141
133
|
</dependencies>
|
142
|
-
|
143
|
-
<build>
|
144
|
-
<plugins>
|
145
|
-
<plugin>
|
146
|
-
<groupId>org.codehaus.mojo</groupId>
|
147
|
-
<artifactId>sonar-maven-plugin</artifactId>
|
148
|
-
<version>2.0</version>
|
149
|
-
</plugin>
|
150
|
-
<plugin>
|
151
|
-
<groupId>com.github.github</groupId>
|
152
|
-
<artifactId>site-maven-plugin</artifactId>
|
153
|
-
<version>0.6</version>
|
154
|
-
<configuration>
|
155
|
-
<message>Creating site for ${project.version}</message>
|
156
|
-
</configuration>
|
157
|
-
<executions>
|
158
|
-
<execution>
|
159
|
-
<goals>
|
160
|
-
<goal>site</goal>
|
161
|
-
</goals>
|
162
|
-
<phase>site</phase>
|
163
|
-
</execution>
|
164
|
-
</executions>
|
165
|
-
</plugin>
|
166
|
-
<plugin>
|
167
|
-
<groupId>org.apache.maven.plugins</groupId>
|
168
|
-
<artifactId>maven-source-plugin</artifactId>
|
169
|
-
<executions>
|
170
|
-
<execution>
|
171
|
-
<id>attach-sources</id>
|
172
|
-
<goals>
|
173
|
-
<goal>jar</goal>
|
174
|
-
</goals>
|
175
|
-
</execution>
|
176
|
-
</executions>
|
177
|
-
</plugin>
|
178
|
-
<plugin>
|
179
|
-
<groupId>org.apache.maven.plugins</groupId>
|
180
|
-
<artifactId>maven-javadoc-plugin</artifactId>
|
181
|
-
<executions>
|
182
|
-
<execution>
|
183
|
-
<id>attach-javadocs</id>
|
184
|
-
<goals>
|
185
|
-
<goal>jar</goal>
|
186
|
-
</goals>
|
187
|
-
</execution>
|
188
|
-
</executions>
|
189
|
-
</plugin>
|
190
|
-
<plugin>
|
191
|
-
<groupId>org.apache.maven.plugins</groupId>
|
192
|
-
<artifactId>maven-gpg-plugin</artifactId>
|
193
|
-
<executions>
|
194
|
-
<execution>
|
195
|
-
<id>sign-artifacts</id>
|
196
|
-
<phase>verify</phase>
|
197
|
-
<goals>
|
198
|
-
<goal>sign</goal>
|
199
|
-
</goals>
|
200
|
-
</execution>
|
201
|
-
</executions>
|
202
|
-
</plugin>
|
203
|
-
</plugins>
|
204
|
-
</build>
|
205
|
-
|
206
|
-
<reporting>
|
207
|
-
<plugins>
|
208
|
-
<plugin>
|
209
|
-
<groupId>org.apache.maven.plugins</groupId>
|
210
|
-
<artifactId>maven-project-info-reports-plugin</artifactId>
|
211
|
-
<version>2.4</version>
|
212
|
-
<configuration>
|
213
|
-
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
|
214
|
-
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
|
215
|
-
</configuration>
|
216
|
-
<reportSets>
|
217
|
-
<reportSet>
|
218
|
-
<reports>
|
219
|
-
<report>dependencies</report>
|
220
|
-
<report>scm</report>
|
221
|
-
</reports>
|
222
|
-
</reportSet>
|
223
|
-
</reportSets>
|
224
|
-
</plugin>
|
225
|
-
<plugin>
|
226
|
-
<groupId>org.apache.maven.plugins</groupId>
|
227
|
-
<artifactId>maven-javadoc-plugin</artifactId>
|
228
|
-
<version>2.8.1</version>
|
229
|
-
<configuration>
|
230
|
-
</configuration>
|
231
|
-
</plugin>
|
232
|
-
<plugin>
|
233
|
-
<groupId>org.apache.maven.plugins</groupId>
|
234
|
-
<artifactId>maven-surefire-report-plugin</artifactId>
|
235
|
-
<version>2.12.3</version>
|
236
|
-
</plugin>
|
237
|
-
</plugins>
|
238
|
-
</reporting>
|
239
134
|
|
240
135
|
</project>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naether
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,133 +9,21 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: rjb
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>'
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.3.2
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>'
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.3.2
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rake
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.9.2
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.9.2
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>'
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.9.0
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>'
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.9.0
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: bundler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>'
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.0.0
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>'
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 1.0.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: jeweler
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>'
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 1.5.2
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>'
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 1.5.2
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: yard
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: kramdown
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
12
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
126
14
|
description: Java dependency resolver using Maven's Aether
|
127
15
|
email: michael@tobedevoured.com
|
128
16
|
executables: []
|
129
17
|
extensions:
|
130
18
|
- Rakefile
|
131
19
|
extra_rdoc_files:
|
132
|
-
- LICENSE
|
133
20
|
- README.md
|
134
21
|
files:
|
135
22
|
- LICENSE
|
136
23
|
- README.md
|
137
24
|
- Rakefile
|
138
25
|
- VERSION
|
26
|
+
- core-0.10.0.jar
|
139
27
|
- jar_dependencies.yml
|
140
28
|
- lib/naether.rb
|
141
29
|
- lib/naether/bootstrap.rb
|
@@ -144,7 +32,7 @@ files:
|
|
144
32
|
- lib/naether/java/jruby.rb
|
145
33
|
- lib/naether/java/ruby.rb
|
146
34
|
- lib/naether/maven.rb
|
147
|
-
- naether
|
35
|
+
- lib/naether/notation.rb
|
148
36
|
- pom.xml
|
149
37
|
homepage: http://github.com/mguymon/naether
|
150
38
|
licenses:
|
@@ -161,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
49
|
version: '0'
|
162
50
|
segments:
|
163
51
|
- 0
|
164
|
-
hash:
|
52
|
+
hash: 2182194397342159048
|
165
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
54
|
none: false
|
167
55
|
requirements:
|
data/naether-0.9.2.jar
DELETED
Binary file
|