module Jars::MavenFactory::AttachJars

def attach_jars(spec, all_dependencies: false)

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