Sha256: 7ef7812f42230df8130fb42b1d3c82a43ae8391bb3f7cd58e05bd64a8e9f25d7

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

require 'java'
module JBundler

  class AetherRuby

    def self.setup_classloader
      unless defined? Aether
        @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 }
        require 'jbundler.jar'
        java_import 'jbundler.Aether'
      end
    end

    def initialize(local_repo = File.join( ENV['HOME'], 
                                           ".m2", 
                                           "repository"), 
                   verbose = false)
      self.class.setup_classloader
      @aether = AetherRuby.new(local_repo, verbose)
    end

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

    def add_repository(url, name = "repo_#{repos.size}")
      @aether.add_repository(name, url)
    end

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

    def resolve
      @aether.resolve
    end

    def classpath
      @aether.classpath
    end
    
    def dependency_map
      @aether.dependency_map
    end
    
    def repositories
      @aether.repositories
    end

    def dependency_coordinates
      @aether.dependency_coordinates
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jbundler-0.3.0 lib/jbundler/aether.rb~
jbundler-0.2.2 lib/jbundler/aether.rb~
jbundler-0.2.1 lib/jbundler/aether.rb~
jbundler-0.2.0 lib/jbundler/aether.rb~