Class: JavaGems::ClasspathBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/javagems/classpath_builder.rb

Defined Under Namespace

Classes: ClasspathError

Instance Method Summary collapse

Instance Method Details

#classpath_for(gemfile) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/javagems/classpath_builder.rb', line 7

def classpath_for(gemfile)
  with_hijacked_bundler_logging do
    bundler_env = Bundler::Environment.load(gemfile)
    deps = bundler_env.dependencies.map {|dep| dep.to_gem_dependency }
    cp = Bundler::Resolver.resolve(deps, sources).collect do |spec|
      spec.require_paths.collect do |req_path|
        (Pathname(spec.full_gem_path) + req_path).expand_path.to_s
      end
    end.flatten.join(File::PATH_SEPARATOR)
  end

rescue => e
  raise ClasspathError, "#{e.message} - #{@hijacked_out.read}"  
end