Module: PomPomPom::Rake

Defined in:
lib/pompompom/rake.rb

Defined Under Namespace

Classes: NullLogger, SimpleLogger

Instance Method Summary collapse

Instance Method Details

#pompompom(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pompompom/rake.rb', line 19

def pompompom(*args)
  options = (Hash === args.last) ? args.pop : { }
  dependencies = args.flatten

  logger = NullLogger.new

  if options[:logger]
    if options[:logger].respond_to?(:info)
      logger = options[:logger]
    elsif options[:logger].respond_to?(:puts)
      logger = SimpleLogger.new(options[:logger])
    end
  end

  config = Config.new(options)
  config.load!

  downloader   = options[:downloader]
  downloader ||= CachingDownloader.new(config.cache_dir, Downloader.new)

  resolver     = Resolver.new(config.repositories, :downloader => downloader)
  dependencies = dependencies.map { |d| Dependency.parse(d) }
  dependencies = resolver.find_transitive_dependencies(*dependencies)
  dependencies = dependencies.reject { |d| File.exists?(File.join(config.target_dir, d.jar_file_name)) }
  
  unless dependencies.empty?
    dependencies.each do |dependency|
      logger.info("Loading #{dependency.jar_file_name}")
      resolver.download!(config.target_dir, false, dependency)
    end
  end
end