Class: LockJar::Resolver
- Inherits:
-
Object
- Object
- LockJar::Resolver
- Defined in:
- lib/lock_jar/resolver.rb
Instance Attribute Summary collapse
-
#naether ⇒ Object
readonly
Returns the value of attribute naether.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #add_remote_repository(repo) ⇒ Object
- #dependencies_graph ⇒ Object
- #download(dependencies) ⇒ Object
-
#initialize(opts = {}) ⇒ Resolver
constructor
A new instance of Resolver.
- #load_to_classpath(artifacts) ⇒ Object
- #remote_repositories ⇒ Object
- #resolve(dependencies, download_artifacts = true) ⇒ Object
- #to_local_paths(notations) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Resolver
Returns a new instance of Resolver.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/lock_jar/resolver.rb', line 27 def initialize( opts = {} ) @opts = opts local_repo = opts[:local_repo] || Naether::Bootstrap.default_local_repo # Bootstrap Naether Naether::Bootstrap.bootstrap_local_repo( local_repo, opts ) # Bootstrapping naether will create an instance from downloaded jars. # If jars exist locally already, create manually @naether = Naether.create @naether.local_repo_path = local_repo if local_repo @naether.clear_remote_repositories if opts[:offline] end |
Instance Attribute Details
#naether ⇒ Object (readonly)
Returns the value of attribute naether.
25 26 27 |
# File 'lib/lock_jar/resolver.rb', line 25 def naether @naether end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
24 25 26 |
# File 'lib/lock_jar/resolver.rb', line 24 def opts @opts end |
Instance Method Details
#add_remote_repository(repo) ⇒ Object
46 47 48 |
# File 'lib/lock_jar/resolver.rb', line 46 def add_remote_repository( repo ) @naether.add_remote_repository( repo ) end |
#dependencies_graph ⇒ Object
57 58 59 |
# File 'lib/lock_jar/resolver.rb', line 57 def dependencies_graph @naether.dependencies_graph end |
#download(dependencies) ⇒ Object
61 62 63 |
# File 'lib/lock_jar/resolver.rb', line 61 def download( dependencies ) @naether.download_artifacts( dependencies ) end |
#load_to_classpath(artifacts) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/lock_jar/resolver.rb', line 78 def load_to_classpath( artifacts ) paths = [] notations = [] artifacts.each do |art| if File.exists?(art) paths << art else notations << art end end paths += @naether.to_local_paths( notations ) Naether::Java.load_paths( paths ) paths end |
#remote_repositories ⇒ Object
42 43 44 |
# File 'lib/lock_jar/resolver.rb', line 42 def remote_repositories @naether.remote_repository_urls end |
#resolve(dependencies, download_artifacts = true) ⇒ Object
51 52 53 54 55 |
# File 'lib/lock_jar/resolver.rb', line 51 def resolve( dependencies, download_artifacts = true ) @naether.dependencies = dependencies @naether.resolve_dependencies( download_artifacts ) @naether.dependencies_notation end |
#to_local_paths(notations) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/lock_jar/resolver.rb', line 65 def to_local_paths( notations ) paths = [] notations.each do |notation| if File.exists?(notation) paths << notation else paths = paths + @naether.to_local_paths( [notation] ) end end paths end |