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
34
35
36
# 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
    if !@done.include?( a.key ) and (all_dependencies or (a.scope != 'provided' and 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
      if a.classifier
        self[ "jars.#{@index}.classifier" ] = a.classifier
      end
      @index += 1
      @done << a.key
    end
  end
end