naether 0.10.1 → 0.11.0

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.
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.8.2.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+
36
+
37
+ <span class="title">Top Level Namespace</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Top Level Namespace
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+ <h2>Defined Under Namespace</h2>
85
+ <p class="children">
86
+
87
+
88
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Naether.html" title="Naether (module)">Naether</a></span>
89
+
90
+
91
+
92
+
93
+ </p>
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ </div>
104
+
105
+ <div id="footer">
106
+ Generated on Fri Sep 27 17:49:16 2013 by
107
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
+ 0.8.2.1 (ruby-1.9.3).
109
+ </div>
110
+
111
+ </body>
112
+ </html>
data/jar_dependencies.yml CHANGED
@@ -1,33 +1,33 @@
1
- ---
2
- :dependencies:
3
- - ch.qos.logback:logback-classic:jar:1.0.6
4
- - ch.qos.logback:logback-core:jar:1.0.6
5
- - com.jcraft:jsch:jar:0.1.44-1
6
- - com.ning:async-http-client:jar:1.6.5
7
- - commons-io:commons-io:jar:2.0.1
8
- - org.apache.maven:maven-aether-provider:jar:3.0.3
9
- - org.apache.maven:maven-model:jar:3.0.3
10
- - org.apache.maven:maven-model-builder:jar:3.0.3
11
- - org.apache.maven:maven-repository-metadata:jar:3.0.3
12
- - org.apache.maven.wagon:wagon-file:jar:1.0
13
- - org.apache.maven.wagon:wagon-http-lightweight:jar:1.0
14
- - org.apache.maven.wagon:wagon-http-shared:jar:1.0
15
- - org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6
16
- - org.apache.maven.wagon:wagon-ssh:jar:1.0
17
- - org.apache.maven.wagon:wagon-ssh-common:jar:1.0
18
- - org.codehaus.plexus:plexus-classworlds:jar:2.4
19
- - org.codehaus.plexus:plexus-component-annotations:jar:1.5.5
20
- - org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-6
21
- - org.codehaus.plexus:plexus-interpolation:jar:1.14
22
- - org.codehaus.plexus:plexus-utils:jar:2.0.7
23
- - org.jsoup:jsoup:jar:1.6.1
24
- - org.slf4j:slf4j-api:jar:1.6.6
25
- - org.slf4j:jcl-over-slf4j:jar:1.6.6
26
- - org.slf4j:log4j-over-slf4j:jar:1.6.6
27
- - org.sonatype.aether:aether-api:jar:1.13.1
28
- - org.sonatype.aether:aether-util:jar:1.13.1
29
- - org.sonatype.aether:aether-impl:jar:1.13.1
30
- - org.sonatype.aether:aether-spi:jar:1.13.1
31
- - org.sonatype.aether:aether-connector-file:jar:1.13.1
32
- - org.sonatype.aether:aether-connector-asynchttpclient:jar:1.13.1
33
- - org.sonatype.aether:aether-connector-wagon:jar:1.13.1
1
+ ---
2
+ :dependencies:
3
+ - ch.qos.logback:logback-classic:jar:1.0.6
4
+ - ch.qos.logback:logback-core:jar:1.0.6
5
+ - com.jcraft:jsch:jar:0.1.44-1
6
+ - com.ning:async-http-client:jar:1.6.5
7
+ - commons-io:commons-io:jar:2.0.1
8
+ - org.apache.maven:maven-aether-provider:jar:3.0.3
9
+ - org.apache.maven:maven-model:jar:3.0.3
10
+ - org.apache.maven:maven-model-builder:jar:3.0.3
11
+ - org.apache.maven:maven-repository-metadata:jar:3.0.3
12
+ - org.apache.maven.wagon:wagon-file:jar:1.0
13
+ - org.apache.maven.wagon:wagon-http-lightweight:jar:1.0
14
+ - org.apache.maven.wagon:wagon-http-shared:jar:1.0
15
+ - org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6
16
+ - org.apache.maven.wagon:wagon-ssh:jar:1.0
17
+ - org.apache.maven.wagon:wagon-ssh-common:jar:1.0
18
+ - org.codehaus.plexus:plexus-classworlds:jar:2.4
19
+ - org.codehaus.plexus:plexus-component-annotations:jar:1.5.5
20
+ - org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-6
21
+ - org.codehaus.plexus:plexus-interpolation:jar:1.14
22
+ - org.codehaus.plexus:plexus-utils:jar:2.0.7
23
+ - org.jsoup:jsoup:jar:1.6.1
24
+ - org.slf4j:slf4j-api:jar:1.6.6
25
+ - org.slf4j:jcl-over-slf4j:jar:1.6.6
26
+ - org.slf4j:log4j-over-slf4j:jar:1.6.6
27
+ - org.sonatype.aether:aether-api:jar:1.13.1
28
+ - org.sonatype.aether:aether-util:jar:1.13.1
29
+ - org.sonatype.aether:aether-impl:jar:1.13.1
30
+ - org.sonatype.aether:aether-spi:jar:1.13.1
31
+ - org.sonatype.aether:aether-connector-file:jar:1.13.1
32
+ - org.sonatype.aether:aether-connector-asynchttpclient:jar:1.13.1
33
+ - org.sonatype.aether:aether-connector-wagon:jar:1.13.1
data/lib/naether.rb CHANGED
@@ -13,9 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require "#{File.dirname(__FILE__)}/naether/configuration"
17
- require "#{File.dirname(__FILE__)}/naether/bootstrap"
18
- require "#{File.dirname(__FILE__)}/naether/java"
19
16
 
20
17
  #
21
18
  # Java dependency resolver
@@ -23,405 +20,43 @@ require "#{File.dirname(__FILE__)}/naether/java"
23
20
  # @author Michael Guymon
24
21
  # @see https://github.com/mguymon/naether/tree/master/core
25
22
  #
26
- class Naether
27
-
28
- attr_reader :resolver
29
-
23
+ require "#{File.dirname(__FILE__)}/naether/configuration"
24
+
25
+ module Naether
26
+
27
+
30
28
  class << self
31
-
29
+
32
30
  # List of Java dependencies needed to bootstrap Naether
33
- #
31
+ #
34
32
  # @param [String] dep_file path
35
33
  # @see {Naether::Bootstrap#dependencies}
36
34
  def bootstrap_dependencies( dep_file=nil )
35
+ require "#{File.dirname(__FILE__)}/naether/bootstrap"
37
36
  Naether::Bootstrap.dependencies( dep_file )
38
37
  end
39
-
38
+
40
39
  #
41
40
  # Helper for platform detection
42
41
  #
43
42
  def platform
44
43
  Naether::Configuration.platform
45
44
  end
46
-
45
+
47
46
  #
48
47
  # Loads all jars creates a new instance of Naether
49
48
  #
50
49
  # @param [Array<String>] jars of paths
51
50
  # @return [Naether]
52
51
  def create_from_jars( jars )
52
+ require "#{File.dirname(__FILE__)}/naether/java"
53
53
  Naether::Java.internal_load_paths( jars )
54
- Naether.new
55
- end
56
-
57
- end
58
-
59
- # Create new instance.
60
- def initialize
61
- @resolver = Naether::Java.create('com.tobedevoured.naether.impl.NaetherImpl')
62
- end
63
-
64
- # Clear all remote repositories
65
- def clear_remote_repositories
66
- @resolver.clearRemoteRepositories()
67
- end
68
-
69
- # Add remote repository
70
- #
71
- # @param [String] url of remote repo
72
- # @param [String] username optional
73
- # @param [String] password optioanl
74
- def add_remote_repository( url, username = nil, password = nil )
75
- if username
76
- @resolver.addRemoteRepositoryByUrl( url, username, password )
77
- else
78
- @resolver.addRemoteRepositoryByUrl( url )
79
- end
80
- end
81
-
82
- # Get remote repositories
83
- #
84
- # @return [Array] of remote repos
85
- def remote_repositories
86
- Naether::Java.convert_to_ruby_array(@resolver.getRemoteRepositories())
87
- end
88
-
89
- # Get remote repositories as urls
90
- #
91
- # @return [Array<String>] of String urls
92
- def remote_repository_urls
93
- Naether::Java.convert_to_ruby_array(@resolver.getRemoteRepositoryUrls(), true)
94
- end
95
-
96
- # Path to local maven repo
97
- #
98
- # @return [String] path to local repo
99
- def local_repo_path
100
- @resolver.getLocalRepoPath()
101
- end
102
-
103
- # Set path to local maven repo
104
- #
105
- # @param [String] path local repo
106
- def local_repo_path=( path )
107
- @resolver.setLocalRepoPath( path )
108
- end
109
-
110
- #
111
- # Add a local Build Artifact, that will be used in the Dependency Resolution
112
- #
113
- # @param [String] notation
114
- # @param [String] path to artifact
115
- # @param [String] pom optional path to pom.xml
116
- #
117
- def add_build_artifact( notation, path, pom = nil )
118
- @resolver.addBuildArtifact(notation, path, pom )
119
- end
120
-
121
- #
122
- # Set local Build Artifacts, that will be used in the Dependency Resolution
123
- #
124
- # @param [Array<Hash>] artifacts of Hashs with { notation => path } or { notation => { :path => path, :pom => pom_path }
125
- #
126
- def build_artifacts=( artifacts )
127
- @resolver.clearBuildArtifacts()
128
-
129
- unless artifacts.is_a? Array
130
- artifacts = [artifacts]
131
- end
132
-
133
- artifacts.each do |artifact|
134
- # Hash of notation => path or notation => { :path =>, :pom => }
135
- if artifact.is_a? Hash
136
-
137
- notation, opts = artifact.shift
138
-
139
- if opts.is_a? Hash
140
- @resolver.add_build_artifact( notation, opts[:path], opts[:pom] )
141
- else
142
- @resolver.add_build_artifact( notation, opts )
143
- end
144
-
145
- else
146
- raise "invalid build_artifacts format"
147
- end
148
- end
149
- end
150
-
151
- #
152
- # Get Build Artifacts
153
- #
154
- # @return [Array] of build artifacts
155
- #
156
- def build_artifacts
157
- Naether::Java.convert_to_ruby_array( @resolver.getBuildArtifacts() )
158
- end
159
-
160
- # Add a dependency
161
- #
162
- # @param [String] notation in the format of groupId:artifactId:version
163
- # @param [String] scope valid options are compile,test,runtime
164
- # @see https://github.com/mguymon/naether/wiki/Notations
165
- def add_notation_dependency( notation, scope='compile' )
166
- @resolver.addDependency( notation, scope )
167
- end
168
-
169
- # Add dependencies from a Maven POM
170
- #
171
- # @param [String] pom_path
172
- # @param [Array<String>] scopes valid options are compile,test,runtime
173
- def add_pom_dependencies( pom_path, scopes=['compile'] )
174
- if Naether.platform == 'java'
175
- @resolver.addDependencies( pom_path, scopes )
176
- else
177
- list = Naether::Java.convert_to_java_list( scopes )
178
- @resolver._invoke( 'addDependencies', 'Ljava.lang.String;Ljava.util.List;', pom_path, list )
54
+ create
179
55
  end
180
- end
181
-
182
- # Add a dependency of org.sonatype.aether.graph.Dependency
183
- #
184
- # @param [org.sonatype.aether.graph.Dependency] dependency
185
- def add_dependency( dependency )
186
- #@resolver.addDependency( dependency )
187
- if Naether.platform == 'java'
188
- @resolver.addDependency( dependency )
189
- else
190
- @resolver._invoke('addDependency', 'Lorg.sonatype.aether.graph.Dependency;', dependency)
191
- end
192
- end
193
-
194
- # Set the dependencies
195
- #
196
- # The dependencies param takes an [Array] of mixed dependencies:
197
- # * [String] Artifact notation, such as groupId:artifactId:version, e.g. 'junit:junit:4.7'
198
- # * [Hash] of a single artifaction notation => scope - { 'junit:junit:4.7' => 'test' }
199
- # * [String] path to a local pom - 'lib/pom.xml'
200
- # * [Hash] of a single path to a local pom => scope - { 'lib/pom.xml' => ['compile','test'] }
201
- #
202
- # @param [Array] dependencies
203
- # @see https://github.com/mguymon/naether/wiki/Notations
204
- def dependencies=(dependencies)
205
- @resolver.clearDependencies()
206
-
207
- unless dependencies.is_a? Array
208
- dependencies = [dependencies]
209
- end
210
-
211
- dependencies.each do |dependent|
212
- # Hash of notation => scope
213
- if dependent.is_a? Hash
214
- key = dependent.keys.first
215
-
216
- # Add pom dependencies with scopes
217
- if key =~ /\.xml$/i
218
- scopes = nil
219
- if dependent[key].is_a? Array
220
- scopes = dependent[key]
221
- else
222
- scopes = [dependent[key]]
223
- end
224
-
225
- add_pom_dependencies( key, scopes )
226
-
227
- # Add a dependency notation with scopes
228
- else
229
- add_notation_dependency( key, dependent[key] )
230
- end
231
-
232
- elsif dependent.is_a? String
233
-
234
- # Add pom dependencies with default scopes
235
- if dependent =~ /\.xml$/i
236
- add_pom_dependencies( dependent )
237
-
238
- # Add a dependency notation with compile scope
239
- else
240
- add_notation_dependency( dependent, 'compile' )
241
- end
242
-
243
- # Add an Aether dependency
244
- else
245
- add_dependency( dependent )
246
- end
247
- end
248
- end
249
-
250
- # Get array of dependencies
251
- #
252
- # @return [Array]
253
- def dependencies
254
- Naether::Java.convert_to_ruby_array( @resolver.currentDependencies() )
255
- end
256
-
257
- # Get array of dependencies as notation
258
- #
259
- # @return [Array<String>] of notations
260
- # @see https://github.com/mguymon/naether/wiki/Notations
261
- def dependencies_notation
262
- Naether::Java.convert_to_ruby_array(@resolver.getDependenciesNotation(), true)
263
- end
264
-
265
- # Hash of dependency paths
266
- #
267
- # @return [Array<Hash>] of { notation => path }
268
- def dependencies_path
269
- Naether::Java.convert_to_ruby_hash( @resolver.getDependenciesPath(), true )
270
- end
271
-
272
- # Convert dependencies to Classpath friendly string
273
- #
274
- # @return [String]
275
- def dependencies_classpath
276
- @resolver.getResolvedClassPath()
277
- end
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
-
303
- # Load dependencies to Classpath
304
- #
305
- # @return [Array] of loaded jars
306
- def load_dependencies_to_classpath
307
- jars = dependencies_classpath.split(":")
308
- Naether::Java.load_jars(jars)
309
-
310
- jars
311
- end
312
-
313
- # Resolve dependencies
314
- #
315
- # @return [Array<String>] of notations
316
- # @see https://github.com/mguymon/naether/wiki/Notations
317
- def resolve_dependencies( download_artifacts = true, properties = nil )
318
-
319
- if properties
320
- # Convert to HashMap
321
- map = Naether::Java.create( "java.util.HashMap" )
322
- properties.each do |k,v|
323
- map.put( k, v )
324
- end
325
- end
326
-
327
- @resolver.resolveDependencies( download_artifacts, map );
328
- dependencies_notation
329
- end
330
56
 
331
- # Convert notations to local paths of artifacts
332
- #
333
- # @param [Array<String>] notations
334
- # @return [Array<String>] of paths to artifacts
335
- # @see https://github.com/mguymon/naether/wiki/Notations
336
- def to_local_paths( notations )
337
- if Naether.platform == 'java'
338
- Naether::Java.convert_to_ruby_array(
339
- Naether::Java.exec_static_method(
340
- 'com.tobedevoured.naether.util.Notation',
341
- 'getLocalPaths',
342
- [local_repo_path, notations ],
343
- ['java.lang.String', 'java.util.List'] ) )
344
- else
345
- paths = Naether::Java.exec_static_method(
346
- 'com.tobedevoured.naether.util.Notation',
347
- 'getLocalPaths',
348
- [local_repo_path, Naether::Java.convert_to_java_list(notations) ],
349
- ['java.lang.String', 'java.util.List'] )
350
- Naether::Java.convert_to_ruby_array( paths, true )
351
- end
352
-
353
- end
354
-
355
- # Download artifacts
356
- #
357
- # @param [Array<String>] notations
358
- # @return [Array<String>] of paths of downloaded artifacts
359
- def download_artifacts( notations )
360
- if( notations.is_a? String )
361
- notations = [notations]
362
- end
363
-
364
- files = nil
365
- if Naether.platform == 'java'
366
- files = @resolver.downloadArtifacts( notations )
367
- else
368
- list = Naether::Java.convert_to_java_list( notations )
369
- files = @resolver._invoke('downloadArtifacts', 'Ljava.util.List;', list)
370
- end
371
-
372
- paths = []
373
- Naether::Java.convert_to_ruby_array(files).each do |file|
374
- paths << file.getAbsolutePath();
57
+ def create
58
+ require "#{File.dirname(__FILE__)}/naether/runtime"
59
+ Naether::Runtime.new
375
60
  end
376
-
377
- paths
378
- end
379
-
380
-
381
- # Deploy artifact to remote repo url
382
- #
383
- # @param [String] notation
384
- # @param [String] file_path to artifact to deploy
385
- # @param [String] url to deploy to
386
- # @param [Hash] opts
387
- # @option opts [String] :pom_path path to pom.xml
388
- # @option opts [String] :username for optional auth
389
- # @option opts [String] :password for optional auth
390
- # @option opts [String] :pub_key for optional auth
391
- # @option opts [String] :pub_key_passphrase for optional auth
392
- def deploy_artifact( notation, file_path, url, opts = {} )
393
- artifact = Naether::Java.create( "com.tobedevoured.naether.deploy.DeployArtifact" )
394
-
395
- artifact.setRemoteRepo( url )
396
- artifact.setNotation( notation )
397
- artifact.setFilePath( file_path )
398
- if opts[:pom_path]
399
- artifact.setPomPath( opts[:pom_path] )
400
- end
401
-
402
- if opts[:username] || opts[:pub_key]
403
- artifact.setAuth(opts[:username], opts[:password], opts[:pub_key], opts[:pub_key_passphrase] )
404
- end
405
- if Naether.platform == 'java'
406
- @resolver.deployArtifact(artifact)
407
- else
408
- @resolver._invoke( 'deployArtifact', 'Lcom.tobedevoured.naether.deploy.DeployArtifact;', artifact )
409
- end
410
- end
411
-
412
- # Install artifact or pom to local repo, must specify pom_path and/or jar_path
413
- #
414
- # @param [String] notation
415
- # @param [String] pom_path
416
- # @param [String] jar_path
417
- def install( notation, pom_path =nil, jar_path = nil )
418
- @resolver.install(notation, pom_path, jar_path)
419
- end
420
-
421
- # Set Log level for Naether Java logging
422
- #
423
- # @param [String] level to debug, info, warn, or error
424
- def set_log_level( level )
425
- Naether::Java.exec_static_method('com.tobedevoured.naether.util.LogUtil', 'changeLevel', ['com.tobedevoured', level] )
426
61
  end
427
62
  end