Class: JBundler::AetherRuby
- Inherits:
-
Object
- Object
- JBundler::AetherRuby
- Defined in:
- lib/jbundler/aether.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_artifact(coordinate, extension = nil) ⇒ Object
- #add_repository(name, url) ⇒ Object
- #artifacts ⇒ Object
- #classpath ⇒ Object
- #classpath_array ⇒ Object
-
#initialize(config = Config.new) ⇒ AetherRuby
constructor
A new instance of AetherRuby.
- #install(coordinate, file) ⇒ Object
- #repositories ⇒ Object
- #resolve ⇒ Object
- #resolved_coordinates ⇒ Object
Constructor Details
#initialize(config = Config.new) ⇒ AetherRuby
Returns a new instance of AetherRuby.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/jbundler/aether.rb', line 49 def initialize( config = Config.new ) unless defined? Aether self.class.setup_classloader end @aether = Aether.new( config.verbose ) @aether.add_proxy( config.proxy ) if config.proxy @aether.add_mirror( config.mirror ) if config.mirror @aether.offline = config.offline @aether.user_settings = config.settings if config.settings @aether.local_repository = java.io.File.new(config.local_repository) if config.local_repository rescue NativeException => e e.cause.print_stack_trace raise e end |
Class Method Details
.setup_classloader ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jbundler/aether.rb', line 28 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 ? use\n$ rmvn prepare-package -Dmaven.test.skip\n" end end java_import 'jbundler.Aether' end |
Instance Method Details
#add_artifact(coordinate, extension = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/jbundler/aether.rb', line 64 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
74 75 76 |
# File 'lib/jbundler/aether.rb', line 74 def add_repository(name, url) @aether.add_repository(name, url) end |
#artifacts ⇒ Object
101 102 103 |
# File 'lib/jbundler/aether.rb', line 101 def artifacts @aether.artifacts end |
#classpath ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/jbundler/aether.rb', line 85 def classpath if artifacts.empty? '' else @aether.classpath end end |
#classpath_array ⇒ Object
93 94 95 |
# File 'lib/jbundler/aether.rb', line 93 def classpath_array classpath.split(/#{File::PATH_SEPARATOR}/) end |
#install(coordinate, file) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/jbundler/aether.rb', line 113 def install(coordinate, file) @aether.install(coordinate, file) rescue NativeException => e e.cause.print_stack_trace raise e end |
#repositories ⇒ Object
97 98 99 |
# File 'lib/jbundler/aether.rb', line 97 def repositories @aether.repositories end |
#resolve ⇒ Object
78 79 80 81 82 83 |
# File 'lib/jbundler/aether.rb', line 78 def resolve @aether.resolve unless artifacts.empty? rescue NativeException => e e.cause.print_stack_trace raise e end |
#resolved_coordinates ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/jbundler/aether.rb', line 105 def resolved_coordinates if artifacts.empty? [] else @aether.resolved_coordinates end end |