Sha256: 9aeb82dede67cb90a6538c84a21ebf5ed0c9589c5031434e93e848b04bef64ac

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

require 'rubygems'
require 'naether'
require "#{File.dirname(__FILE__)}/resolver/java"

module Buildr
  module Resolver
    class << self
      
      def naether
        Buildr::Resolver::Java.instance.naether
      end
      
      # Resolve dependencies for an array of dependencies
      #
      # excludes is an array of dependencies to exclude
      # repos is an array of {:url => '', :username => '', :password => '' } of additional remote repos
      # with authentication
      def resolve( dependencies, excludes=[], repos = [] )
        if Buildr.repositories.remote.size > 0
          naether.clear_remote_repositories
          Buildr.repositories.remote.each do |repo|
            naether.add_remote_repository( repo )
          end
          
          unless repos.nil?
            unless repos.is_a? Array
              repos = [repos]
            end
            
            repos.each do |repo|
              naether.add_remote_repository( repo[:url], repo[:username], repo[:password] )
            end
          end
        end
        
        naether.local_repo_path = Repositories.instance.local
        
        naether.dependencies = dependencies
        naether.resolve_dependencies( false )
        
        dependences = naether.dependencies
        
        unless excludes.nil?
          unless excludes.is_a? Array
            excludes = [excludes]
          end
          
          dependences.delete_if do |dep|
            excludes.select { |exclude| dep.to_s =~ /^#{exclude}/ }.size > 0
          end
        end
      end
      
      def deploy_artifact( notation, file_path, url, opts = {} )
        naether.deploy_artifact( notation, file_path, url, opts )
      end
      
      def write_pom( notation, file_path )
        naether.write_pom( notation, file_path )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildr-resolver-0.3.3 lib/buildr/resolver.rb