naether 0.5.5-java → 0.5.6-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.6
data/lib/naether.rb CHANGED
@@ -12,7 +12,7 @@ class Naether
12
12
 
13
13
  # Naether jar path will default to packaged in the gem
14
14
  JAR_LIB = "#{File.dirname(__FILE__)}/.."
15
- JAR_PATH = "#{JAR_LIB}/naether-0.5.5.jar" #XXX: hardcoded, should be based on VERSION file
15
+ JAR_PATH = "#{JAR_LIB}/naether-0.5.6.jar" #XXX: hardcoded, should be based on VERSION file
16
16
 
17
17
  class << self
18
18
 
@@ -185,32 +185,36 @@ class Naether
185
185
  end
186
186
 
187
187
  # Resolve dependencies, finding related additional dependencies
188
- def resolve_dependencies( download_artifacts = true )
189
- @resolver.resolveDependencies( download_artifacts );
188
+ def resolve_dependencies( download_artifacts = true, properties = nil )
189
+
190
+ if properties
191
+ # Convert to HashMap
192
+ map = Naether::Java.create( "java.util.HashMap" )
193
+ properties.each do |k,v|
194
+ map.put( k, v )
195
+ end
196
+ end
197
+
198
+ @resolver.resolveDependencies( download_artifacts, map );
190
199
  dependenciesNotation
191
200
  end
192
201
 
193
202
  # Deploy artifact to remote repo url
194
203
  def deploy_artifact( notation, file_path, url, opts = {} )
195
- if Naether.platform == 'java'
196
- @instance = com.slackworks.naether.deploy.DeployArtifact.new
197
- else
198
- deployArtifactClass = Rjb::import('com.slackworks.naether.deploy.DeployArtifact')
199
- @instance = deployArtifactClass.new
200
- end
204
+ artifact = Naether::Java.create( "com.slackworks.naether.deploy.DeployArtifact" )
201
205
 
202
- @instance.setRemoteRepo( url )
203
- @instance.setNotation( notation )
204
- @instance.setFilePath( file_path )
206
+ artifact.setRemoteRepo( url )
207
+ artifact.setNotation( notation )
208
+ artifact.setFilePath( file_path )
205
209
  if opts[:pom_path]
206
- @instance.setPomPath( opts[:pom_path] )
210
+ artifact.setPomPath( opts[:pom_path] )
207
211
  end
208
212
 
209
213
  if opts[:username] || opts[:pub_key]
210
- @instance.setAuth(opts[:username], opts[:password], opts[:pub_key], opts[:pub_key_passphrase] )
214
+ artifact.setAuth(opts[:username], opts[:password], opts[:pub_key], opts[:pub_key_passphrase] )
211
215
  end
212
216
 
213
- @resolver.deployArtifact(@instance)
217
+ @resolver.deployArtifact(artifact)
214
218
  end
215
219
 
216
220
  # Install artifact or pom to local repo, must specify pom_path and/or jar_path
@@ -230,6 +234,7 @@ class Naether
230
234
  if Naether.platform == 'java'
231
235
  deps = @project_instance.getDependenciesNotation( scopes, true )
232
236
  else
237
+ list = nil
233
238
  if scopes
234
239
  list = Rjb::import("java.util.ArrayList").new
235
240
  scopes.each do |scope|
data/lib/naether/java.rb CHANGED
@@ -10,16 +10,23 @@ require 'singleton'
10
10
  #
11
11
  class Naether
12
12
  class Java
13
+ include Singleton
13
14
 
14
- # Jars loaded
15
- def self.loaded_jars
15
+ attr_reader :java
16
+
17
+ def initialize
16
18
  if Naether.platform == 'java'
17
- Naether::Java::JRuby.instance.loaded_jars
19
+ @java = Naether::Java::JRuby.instance
18
20
  else
19
- Naether::Java::Ruby.instance.loaded_jars
21
+ @java = Naether::Java::Ruby.instance
20
22
  end
21
23
  end
22
24
 
25
+ # Jars loaded
26
+ def self.loaded_jars
27
+ instance.java.loaded_jars
28
+ end
29
+
23
30
 
24
31
  # Loads all jars from the array of paths
25
32
  def self.load_jars_dir(paths)
@@ -38,58 +45,23 @@ class Naether
38
45
 
39
46
  # Load jars for the runtime platform
40
47
  def self.load_jars(jars)
41
- if Naether.platform == 'java'
42
- Naether::Java::JRuby.instance.load_jars(jars)
43
- else
44
- Naether::Java::Ruby.instance.load_jars(jars)
45
- end
48
+ instance.java.load_jars(jars)
49
+ end
50
+
51
+ def self.set_log_level( level )
52
+ instance.java.set_log_level( level )
46
53
  end
47
54
 
48
55
  def self.create( java_class, *args )
49
- if Naether.platform == 'java'
50
- java_class = eval(java_class)
51
- else
52
- java_class = Rjb::import(java_class)
53
- end
54
-
55
- java_class.new( *args )
56
+ instance.java.create( java_class, *args )
56
57
  end
57
58
 
58
59
  def self.convert_to_ruby_array( java_array, to_string = false )
59
- if Naether.platform == 'java'
60
- return java_array.to_a
61
- else
62
- ruby_array = java_array.toArray()
63
-
64
- if to_string
65
- ruby_array = ruby_array.map { |x| x.toString()}
66
- end
67
-
68
- return ruby_array
69
- end
60
+ instance.java.convert_to_ruby_array( java_array, to_string )
70
61
  end
71
62
 
72
63
  def self.convert_to_ruby_hash( java_hash, to_string = false )
73
- if Naether.platform == 'java'
74
- return java_hash.to_hash
75
- else
76
- hash = {}
77
- keys = java_hash.keySet()
78
- iterator = keys.iterator()
79
- if to_string
80
- while iterator.hasNext()
81
- key = iterator.next().toString()
82
- hash[key] = java_hash.get( key ).toString()
83
- end
84
- else
85
- while iterator.hasNext()
86
- key = iterator.next()
87
- hash[key] = java_hash.get( key )
88
- end
89
- end
90
-
91
- return hash
92
- end
64
+ instance.java.convert_to_ruby_hash( java_hash, to_string )
93
65
  end
94
66
 
95
67
  #
@@ -106,6 +78,15 @@ class Naether
106
78
  @loaded_jars = []
107
79
  end
108
80
 
81
+ def create( java_class, *args )
82
+ java_class = eval(java_class)
83
+ java_class.new( *args )
84
+ end
85
+
86
+ def set_log_level( level )
87
+ com.slackworks.naether.LogUtil.changeLevel( 'com.slackworks', level )
88
+ end
89
+
109
90
  def load_jars(jars)
110
91
  loaded_jars = []
111
92
  unless jars.is_a? Array
@@ -123,6 +104,15 @@ class Naether
123
104
 
124
105
  loaded_jars
125
106
  end
107
+
108
+ def convert_to_ruby_array( java_array, to_string = false )
109
+ java_array.to_a
110
+ end
111
+
112
+ def convert_to_ruby_hash( java_hash, to_string = false )
113
+ java_hash.to_hash
114
+ end
115
+
126
116
  end
127
117
 
128
118
  #
@@ -143,6 +133,15 @@ class Naether
143
133
  @loaded_jars = []
144
134
  end
145
135
 
136
+ def create( java_class, *args )
137
+ java_class = Rjb::import(java_class)
138
+ java_class.new( *args )
139
+ end
140
+
141
+ def set_log_level( level )
142
+ Rjb::import('com.slackworks.naether.LogUtil').changeLevel( 'com.slackworks', level )
143
+ end
144
+
146
145
  def load_jars(jars)
147
146
  loadable_jars = []
148
147
  unless jars.is_a?( Array )
@@ -163,6 +162,37 @@ class Naether
163
162
 
164
163
  loadable_jars
165
164
  end
165
+
166
+ def convert_to_ruby_array( java_array, to_string = false )
167
+ ruby_array = java_array.toArray()
168
+
169
+ if to_string
170
+ ruby_array = ruby_array.map { |x| x.toString()}
171
+ end
172
+
173
+ ruby_array
174
+ end
175
+
176
+ def convert_to_ruby_hash( java_hash, to_string = false )
177
+
178
+ hash = {}
179
+ keys = java_hash.keySet()
180
+ iterator = keys.iterator()
181
+ if to_string
182
+ while iterator.hasNext()
183
+ key = iterator.next().toString()
184
+ hash[key] = java_hash.get( key ).toString()
185
+ end
186
+ else
187
+ while iterator.hasNext()
188
+ key = iterator.next()
189
+ hash[key] = java_hash.get( key )
190
+ end
191
+ end
192
+
193
+ hash
194
+
195
+ end
166
196
  end
167
197
  end
168
198
  end
data/pom.xml CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <groupId>com.slackworks</groupId>
6
6
  <artifactId>naether</artifactId>
7
- <version>0.5.5</version>
7
+ <version>0.5.6</version>
8
8
  <packaging>jar</packaging>
9
9
  <name>naether</name>
10
10
  <url>https://github.com/mguymon/naether</url>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: naether
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.5
5
+ version: 0.5.6
6
6
  platform: java
7
7
  authors:
8
8
  - Michael Guymon
@@ -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.5.5.jar
77
+ - naether-0.5.6.jar
78
78
  - pom.xml
79
79
  has_rdoc: true
80
80
  homepage: http://github.com/mguymon/naether