Module: MiniAether
- Extended by:
- Bootstrap
- Defined in:
- lib/mini_aether.rb,
lib/mini_aether/spec.rb,
lib/mini_aether/resolver.rb,
lib/mini_aether/bootstrap.rb,
lib/mini_aether/xml_parser.rb
Defined Under Namespace
Modules: Bootstrap Classes: 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
Constants included from Bootstrap
Class Method Summary collapse
-
.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.
Methods included from Bootstrap
bootstrap!, dependencies, ensure_dependency, install, interpolate, jar_path, local_repository_path
Class Method Details
.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
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mini_aether.rb', line 39 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
53 54 55 |
# File 'lib/mini_aether.rb', line 53 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.
13 14 15 16 17 18 19 20 21 |
# File 'lib/mini_aether.rb', line 13 def with_ruby_container scope = Java::OrgJrubyEmbed::LocalContextScope::SINGLETHREAD c = Java::OrgJrubyEmbed::ScriptingContainer.new(scope) begin yield c ensure c.terminate end end |