Module: JBundler::Lazy

Includes:
Maven::Tools::Coordinate
Defined in:
lib/jbundler/lazy.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(clazz) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jbundler/lazy.rb', line 28

def self.included(clazz)
  begin
    require 'java'
    warn ''
    warn 'lazy jar loading does NOT garantee the consistency of the classloader.'
    warn 'duplicated jars with different version and other dependency conflicts can easily occur.'
    warn ''
    warn 'add new jars with:'
    warn ''
    warn "\tjar 'org.yaml:snakeyaml'"
    warn "\tjar 'org.slf4j:slf4j-simple', '>1.1'"
    warn ''
    warn 'show loaded jars with:'
    warn "\tjars"
    warn ''
  rescue LoadError
    warn 'no jar support possible without JRuby - just launching an IRB session'
  end
end

Instance Method Details

#jar(name, *version) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/jbundler/lazy.rb', line 59

def jar(name, *version)
  unless defined? JRUBY_VERSION
    warn 'no jar support possible without JRuby'
    return
  end
  aether.add_artifact("#{name}:#{to_version(*version)}")
  aether.resolve
  result = false
  aether.classpath_array.each do |path|
    if result ||= (require path)
      warn "added #{path} to classloader"
      jb_classpath << path
    else
      warn "already loaded: #{path}"
    end
  end
  result
end

#jarsObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/jbundler/lazy.rb', line 48

def jars
  if jb_classpath.empty?
    puts "\tno jars loaded via jbundler"
  else
    jb_classpath.each do |path|
      puts "\t#{path}"
    end
  end
  nil
end