Class: PomPomPom::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/pompompom/resolver.rb

Defined Under Namespace

Classes: DependencyNotFoundError, JarDownloader, JarNotFoundError, NullLogger, PomResolver

Instance Method Summary collapse

Constructor Details

#initialize(repositories, options = {}) ⇒ Resolver

Returns a new instance of Resolver.

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/pompompom/resolver.rb', line 6

def initialize(repositories, options={})
  @repositories, @logger, @downloader = repositories, (options[:logger] || NullLogger.new), (options[:downloader] || Downloader.new)
  raise ArgumentError, 'No repositories given!' if repositories.nil? || repositories.empty?
end

Instance Method Details

#download!(target_dir, transitive, *dependencies) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/pompompom/resolver.rb', line 11

def download!(target_dir, transitive, *dependencies)
  create_target_directory(target_dir)
  all_dependencies = if transitive then find_transitive_dependencies(*dependencies) else dependencies end
  all_dependencies.each do |pom|
    destination = File.join(target_dir, "#{pom.artifact_id}-#{pom.version}.jar")
    JarDownloader.new(pom, destination, @repositories, @downloader, @logger).download!
  end
end

#find_transitive_dependencies(*dependencies) ⇒ Object



20
21
22
23
# File 'lib/pompompom/resolver.rb', line 20

def find_transitive_dependencies(*dependencies)
  resolver = PomResolver.new(dependencies, @repositories, @downloader, @logger)
  filter_newest(group_by_artifact(resolver.all_poms))
end