Sha256: d1e70591170c45d47099f335613274568d277904ccda25a56e81e6b4330f0f1c

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 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 exists?
      !@lockfile.nil?
    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.3.2 lib/jbundler/gemfile_lock.rb
jbundler-0.3.1 lib/jbundler/gemfile_lock.rb
jbundler-0.3.0 lib/jbundler/gemfile_lock.rb