Module: Rake::Ivy

Defined in:
lib/rake/ivy_extension.rb

Defined Under Namespace

Classes: IvyConfig, Tasks

Instance Method Summary collapse

Instance Method Details

#filter(*confs) ⇒ Object

Filter artifacts for given configuration with provided filter values, this is a post resolve task like #deps. project.ivy.filter('server', 'client', :include => /b.*.jar/, :exclude => [/a\.jar/, /other.*\.jar/])



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/rake/ivy_extension.rb', line 272

def filter(*confs)
  filter = confs.last.kind_of?(Hash) ? confs.pop : {}
  unless (filter.keys - (TYPES - [:conf])).empty?
    raise ArgumentError, "Invalid filter use :include and/or :exclude only: given #{filter.keys.inspect}"
  end
  includes, excludes, types = filter[:include] || [], filter[:exclude] || [], filter[:type] || []
  
  artifacts = deps(confs.flatten, types.flatten)
  if artifacts
    artifacts = artifacts.find_all do |lib|
      lib = File.basename(lib)
      includes = includes.reject {|i| i.nil? || (i.respond_to?(:empty?) && i.empty?) || (i.respond_to?(:source) && i.source.empty?) }
      should_include = includes.empty? || includes.any? {|include| include === lib }
      should_include && !excludes.any? {|exclude| exclude === lib}
    end
  end
  
  artifacts
end

#post_resolve(&block) ⇒ Object

Adds given block as post resolve action that is executed directly after #resolve has been called. Yields this ivy config object into block. project.ivy.post_resolve { |ivy| p "all deps:" + ivy.deps('all').join(", ") }



265
266
267
# File 'lib/rake/ivy_extension.rb', line 265

def post_resolve(&block)
  post_resolve_tasks << block if block
end