Class: Doubleshot::Resolver::JarResolver

Inherits:
Doubleshot::Resolver show all
Defined in:
lib/doubleshot/resolver/jar_resolver.rb

Constant Summary collapse

DEFAULT_REPOSITORY =
"http://repo1.maven.org/maven2"

Instance Method Summary collapse

Methods inherited from Doubleshot::Resolver

#fetch, #repositories

Constructor Details

#initialize(*repositories) ⇒ JarResolver

Returns a new instance of JarResolver.



6
7
8
9
10
11
12
13
# File 'lib/doubleshot/resolver/jar_resolver.rb', line 6

def initialize(*repositories)
  super
  # Change the second argument to "true" to get verbose output.
  @aether = org.sam.doubleshot.Aether.new(Pathname("~/.m2").expand_path.to_s, false, false)
  @repositories.each do |repository|
    @aether.add_repository repository.host, repository.to_s
  end
end

Instance Method Details

#resolve!(dependencies) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/doubleshot/resolver/jar_resolver.rb', line 15

def resolve!(dependencies)
  dependencies.each do |dependency|
    @aether.add_artifact dependency.to_s
  end

  @aether.resolve
  classpath_map = @aether.classpath_map

  @aether.resolved_coordinates.each do |coordinate|
    dependencies.add Dependencies::JarDependency.new coordinate
  end

  dependencies.each do |dependency|
    dependency.path = classpath_map[dependency.to_s]
  end
  dependencies
end