Module: Buildr::Resolver

Defined in:
lib/buildr/resolver.rb,
lib/buildr/resolver/java.rb

Defined Under Namespace

Classes: Java

Class Method Summary collapse

Class Method Details

.deploy_artifact(notation, file_path, url, opts = {}) ⇒ Object



87
88
89
# File 'lib/buildr/resolver.rb', line 87

def deploy_artifact( notation, file_path, url, opts = {} )
  naether.deploy_artifact( notation, file_path, url, opts )
end

.deps_from_pom(pom_path, scope = nil) ⇒ Object



75
76
77
# File 'lib/buildr/resolver.rb', line 75

def deps_from_pom( pom_path, scope=nil  )
  naether.pom_dependencies( pom_path, scope )
end

.install(notation, pom_path, jar_path) ⇒ Object



91
92
93
# File 'lib/buildr/resolver.rb', line 91

def install( notation, pom_path, jar_path )
  naether.install( notation, pom_path, jar_path )
end

.naetherObject



15
16
17
# File 'lib/buildr/resolver.rb', line 15

def naether
  Buildr::Resolver::Java.instance.naether
end

.pom_version(pom_path) ⇒ Object



79
80
81
# File 'lib/buildr/resolver.rb', line 79

def pom_version( pom_path )
  naether.pom_version( pom_path )
end

.resolve(dependencies, opts = {}) ⇒ Object

Resolve dependencies for an array of dependencies in the format of path to a pom.xml, a hash for a pom.xml and scopes to use ‘lib/pom.xml’ => [‘compile’,‘system’], dependency notation ‘groupId:artifactId:type:version’ or as a hash to define the scope, or ‘groupId:artifactId:type:version’ => ‘compile’. Example:

‘lib/pom.xml’, ‘ch.qos.logback:logback-classic:jar:0.9.24’, => ‘test’

Options

* :excludes - an array of dependencies to regex exclude
* :download - have Buildr::Resolver download artifacts instead of Buildr


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/buildr/resolver.rb', line 29

def resolve( dependencies, opts = {} )
  
  options = opts
  
  if Buildr.repositories.remote.size > 0
    naether.clear_remote_repositories
    
    # ensure repos have been converted to RepostoryArray
    Buildr.repositories.remote = Buildr.repositories.remote
    
    Buildr.repositories.remote.each do |repo|
      begin
        naether.add_remote_repository( repo[:url].to_s, repo[:username], repo[:password] ) 
      rescue
        
      end
    end          
  end
  
  naether.local_repo_path = Repositories.instance.local
  
  naether.dependencies = dependencies
  naether.resolve_dependencies( opts[:download] == true )
  
  unless options[:excludes].nil?
    
    excludes = options[:excludes]
    
    unless excludes.is_a? Array
      excludes = [excludes]
    end
    
    dependencies = naether.dependencies
    dependencies.delete_if do |dep|
      excludes.select do |exclude| 
        dep.toString() =~ /^#{exclude}/
      end.size > 0
    end
    
    naether.dependencies = dependencies
    
  end
  
  naether.dependenciesNotation
end

.write_pom(notation, file_path) ⇒ Object



83
84
85
# File 'lib/buildr/resolver.rb', line 83

def write_pom( notation, file_path )
  naether.write_pom( notation, file_path )
end