Sha256: 94b1c56b15a511d7f91987c5369a63424c15be06b79fdcd907a7c52daec58b26

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 Bytes

Contents

require 'rubygems'
require 'jbundler/pom'

module JBundler

  class GemfileLock

    def initialize(jarfile, lockfile = 'Gemfile.lock')
      @jarfile = jarfile
      @lockfile = lockfile if File.exists?(lockfile)
    end

    def mtime
      File.mtime(@lockfile) if @lockfile
    end

    def populate_dependencies(aether)
      if @lockfile
        # assuming we run in Bundler context here 
        # at we have a Gemfile.lock :)
        Bundler.load.specs.each do |spec|
          jars = []
          spec.requirements.each do |rr|
            rr.split(/\n/).each do |r|
              jars << r if r =~ /^jar\s/
            end
          end
          unless jars.empty?
            pom = Pom.new(spec.name, spec.version, jars, "pom")
            aether.install(pom.coordinate, pom.file)
            unless @jarfile.locked?(pom.coordinate)
              aether.add_artifact(pom.coordinate)
            end
          end
        end
      end
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jbundler-0.2.2 lib/jbundler/gemfile_lock.rb
jbundler-0.2.1 lib/jbundler/gemfile_lock.rb
jbundler-0.2.0 lib/jbundler/gemfile_lock.rb