Sha256: 652e2364594ecfe8435be2b115790ccc647a925b3d942a74da2c8cebe3d784af

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

require 'rubygems'
require 'jbundler/pom'

module JBundler

  class GemfileLock

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

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

    def populate_depedencies(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 @mavenfile.locked?(pom.coordinate)
              aether.add_artifact(pom.coordinate)
            end
          end
        end
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jbundler-0.0.1 lib/jbundler/gemfile_lock.rb