Module: Jars::MavenFactory::AttachJars

Defined in:
lib/jars/maven_factory.rb

Instance Method Summary collapse

Instance Method Details

#attach_jars(spec, all_dependencies: false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jars/maven_factory.rb', line 9

def attach_jars(spec, all_dependencies: false)
  @index ||= 0
  @done ||= []

  deps = GemspecArtifacts.new(spec)
  deps.artifacts.each do |a|
    # for this gemspec we want to include all artifacts but
    # for all others we want to exclude provided and test artifacts
    next unless !@done.include?(a.key) && (all_dependencies || ((a.scope != 'provided') && (a.scope != 'test')))

    # ruby dsl is not working reliably for classifier
    self["jars.#{@index}"] = a.to_coord_no_classifier
    if a.exclusions
      jndex = 0
      a.exclusions.each do |ex|
        self["jars.#{@index}.exclusions.#{jndex}"] = ex.to_s
        jndex += 1
      end
    end
    self["jars.#{@index}.scope"] = a.scope if a.scope
    self["jars.#{@index}.classifier"] = a.classifier if a.classifier
    @index += 1
    @done << a.key
  end
end