Class: Jars::Classpath

Inherits:
Object
  • Object
show all
Defined in:
lib/jars/classpath.rb

Constant Summary collapse

DEPENDENCY_LIST =
'dependencies.list'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec = nil, deps = nil) ⇒ Classpath

Returns a new instance of Classpath.



24
25
26
27
# File 'lib/jars/classpath.rb', line 24

def initialize(spec = nil, deps = nil)
  @spec = spec
  @deps = deps
end

Class Method Details

.classpath(scope = nil) ⇒ Object

convenient method



15
16
17
# File 'lib/jars/classpath.rb', line 15

def self.classpath(scope = nil)
  new.classpath(scope)
end

.classpath_string(scope = nil) ⇒ Object

convenient method



20
21
22
# File 'lib/jars/classpath.rb', line 20

def self.classpath_string(scope = nil)
  new.classpath_string(scope)
end

.require(scope = nil) ⇒ Object

convenient method



10
11
12
# File 'lib/jars/classpath.rb', line 10

def self.require(scope = nil)
  new.require(scope)
end

Instance Method Details

#classpath(scope = nil) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/jars/classpath.rb', line 71

def classpath(scope = nil)
  classpath = []
  process(scope) do |jar|
    classpath << jar.file
  end
  classpath
end

#classpath_string(scope = nil) ⇒ Object



88
89
90
# File 'lib/jars/classpath.rb', line 88

def classpath_string(scope = nil)
  classpath(scope).join(File::PATH_SEPARATOR)
end

#mvnObject



29
30
31
# File 'lib/jars/classpath.rb', line 29

def mvn
  @mvn ||= MavenExec.new(@spec)
end

#require(scope = nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/jars/classpath.rb', line 56

def require(scope = nil)
  process(scope) do |jar|
    if jar.scope == :system
      Kernel.require jar.path
    else
      require_jar(*jar.gacv)
    end
  end
  return unless scope.nil? || scope == :runtime

  process(:provided) do |jar|
    Jars.mark_as_required(*jar.gacv)
  end
end

#workdir(dirname) ⇒ Object



33
34
35
36
# File 'lib/jars/classpath.rb', line 33

def workdir(dirname)
  dir = File.join(mvn.basedir, dirname)
  dir if File.directory?(dir)
end