Class: JBundler::AetherRuby

Inherits:
Object
  • Object
show all
Defined in:
lib/jbundler/aether.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = AetherConfig.new) ⇒ AetherRuby

Returns a new instance of AetherRuby.



87
88
89
90
91
92
# File 'lib/jbundler/aether.rb', line 87

def initialize(config = AetherConfig.new)
  unless defined? Aether
    self.class.setup_classloader
  end
  @aether = Aether.new(config.local_repository, config.verbose)
end

Class Method Details

.setup_classloaderObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/jbundler/aether.rb', line 66

def self.setup_classloader
  require 'java'

  maven_home = File.dirname(File.dirname(Gem.bin_path('ruby-maven', 
                                                       'rmvn')))
  # TODO reduce to the libs which are really needed
  Dir.glob(File.join(maven_home, 'lib', "*jar")).each {|path| require path }
  begin
    require 'jbundler.jar'
  rescue LoadError
    # allow the classes already be added to the classloader
    begin
      java_import 'jbundler.Aether'
    rescue NameError
      # assume this happens only when working on the git clone
      raise "jbundler.jar is missing - maybe you need to build it first ? try\n$ rmvn prepare-package -Dmaven.test.skip\n"
    end
  end
  java_import 'jbundler.Aether'
end

Instance Method Details

#add_artifact(coordinate, extension = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/jbundler/aether.rb', line 94

def add_artifact(coordinate, extension = nil)
  if extension
    coord = coordinate.split(/:/)
    coord.insert(2, extension)
    @aether.add_artifact(coord.join(":"))
  else
    @aether.add_artifact(coordinate)
  end
end

#add_repository(name, url) ⇒ Object



104
105
106
# File 'lib/jbundler/aether.rb', line 104

def add_repository(name, url)
  @aether.add_repository(name, url)
end

#artifactsObject



124
125
126
# File 'lib/jbundler/aether.rb', line 124

def artifacts
  @aether.artifacts
end

#classpathObject



112
113
114
115
116
117
118
# File 'lib/jbundler/aether.rb', line 112

def classpath 
  if artifacts.empty?
    ''
  else
    @aether.classpath
  end
end

#install(coordinate, file) ⇒ Object



136
137
138
# File 'lib/jbundler/aether.rb', line 136

def install(coordinate, file)
  @aether.install(coordinate, file)
end

#repositoriesObject



120
121
122
# File 'lib/jbundler/aether.rb', line 120

def repositories
  @aether.repositories
end

#resolveObject



108
109
110
# File 'lib/jbundler/aether.rb', line 108

def resolve
  @aether.resolve unless artifacts.empty?
end

#resolved_coordinatesObject



128
129
130
131
132
133
134
# File 'lib/jbundler/aether.rb', line 128

def resolved_coordinates
  if artifacts.empty?
    []
  else
    @aether.resolved_coordinates
  end
end