Class: Jars::Classpath

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

Constant Summary collapse

DEPENDENCY_LIST =
'dependencies.list'

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Classpath.



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

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

Instance Method Details

#classpath(scope = nil) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/jars/classpath.rb', line 56

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

#classpath_string(scope = nil) ⇒ Object



72
73
74
# File 'lib/jars/classpath.rb', line 72

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

#mvnObject



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

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

#require(scope = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/jars/classpath.rb', line 41

def require( scope = nil )
  process( scope ) do |jar|
    if jar.scope == :system
      Kernel.require jar.path
    else
      require_jar( *jar.gacv )
    end
  end
  if scope == nil || scope == :runtime
    process( :provided ) do |jar|
      Jars.mark_as_required( *jar.gacv )
    end
  end
end

#workdir(dirname) ⇒ Object



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

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