Module: MiniAether
- Defined in:
- lib/mini_aether.rb,
lib/mini_aether/spec.rb,
lib/mini_aether/helper.rb,
lib/mini_aether/resolver.rb,
lib/mini_aether/bootstrap.rb,
lib/mini_aether/xml_parser.rb
Defined Under Namespace
Modules: Bootstrap, Helper Classes: LoggerConfig, Resolver, Spec, XmlParser
Constant Summary collapse
- MAVEN_CENTRAL_REPO =
'http://repo1.maven.org/maven2'.freeze
- M2_SETTINGS =
File.join(ENV['HOME'], '.m2', 'settings.xml').freeze
Class Method Summary collapse
- .logger ⇒ Object
-
.resolve(dependencies, sources) ⇒ Array<String>
Resolve
dependencies
, downloading fromsources
. - .setup(&block) ⇒ Object
-
.with_ruby_container ⇒ Object
Create a new ScriptingContainer (Java object interface to a JRuby runtime) in SINGLETHREAD mode, and yield it to the block.
Class Method Details
.logger ⇒ Object
45 46 47 |
# File 'lib/mini_aether.rb', line 45 def logger @logger ||= LoggerConfig.new end |
.resolve(dependencies, sources) ⇒ Array<String>
Resolve dependencies
, downloading from sources
.
Uses a separate JRuby runtime to avoid polluting the classpath with Aether and SLF4J classes.
(likely jar files) satisfying the dependencies
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mini_aether.rb', line 81 def resolve(dependencies, sources) with_ruby_container do |c| c.put 'path', File.dirname(__FILE__).to_java c.put 'deps', Marshal.dump(dependencies).to_java c.put 'repos', Marshal.dump(sources).to_java files = c.runScriptlet <<-EOF $LOAD_PATH.push path require 'mini_aether/resolver' MiniAether::Resolver.new.resolve_foreign(deps, repos) EOF files.map { |f| f.to_s } end end |
.setup(&block) ⇒ Object
95 96 97 |
# File 'lib/mini_aether.rb', line 95 def setup(&block) MiniAether::Spec.new(&block).require end |
.with_ruby_container ⇒ Object
Create a new ScriptingContainer (Java object interface to a JRuby runtime) in SINGLETHREAD mode, and yield it to the block. Ensure the runtime is terminated after the block returns.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mini_aether.rb', line 52 def with_ruby_container scope = Java::OrgJrubyEmbed::LocalContextScope::SINGLETHREAD c = Java::OrgJrubyEmbed::ScriptingContainer.new(scope) begin # short-lived container of mostly java calls may be a bit # faster without spending time to JIT c.setCompileMode Java::OrgJruby::RubyInstanceConfig::CompileMode::OFF yield c ensure c.terminate end end |