Sha256: 453f383cf2db28b889830aee6cf0ab6e3be3d4bcab0435a5a1690136f9b91290

Contents?: true

Size: 1.55 KB

Versions: 42

Compression:

Stored size: 1.55 KB

Contents

require 'jars/maven_exec'

module Jars
  class JarDetails < Array

    def scope
      self[ -2 ].to_sym
    end

    def file
      file = self[ -1 ].strip
      file.empty? ? path : file
    end

    def group_id
      self[ 0 ]
    end

    def artifact_id
      self[ 1 ]
    end

    def version
      self[ -3 ]
    end

    def classifier
      size == 5 ? nil : self[ 2 ]
    end

    def gacv
      classifier ? self[ 0..3 ] : self[ 0..2 ]
    end

    def path
      if scope == :system
        # replace maven like system properties embedded into the string
        self[ -1 ].gsub( /\$\{[a-zA-Z.]+\}/ ) do |a|
          ENV_JAVA[ a[2..-2] ] || a
        end
      else
        File.join( Jars.home, group_id.gsub(/[.]/, '/'), artifact_id, version, gacv[ 1..-1 ].join( '-' ) + '.jar' )
      end
    end
  end

  class Lock

    def initialize( file )
      @file = file
    end

    def process( scope )
      scope ||= :runtime
      File.read( @file ).each_line do |line|
        next if not line =~ /:.+:/
        jar = JarDetails.new( line.strip.sub( /:jar:/, ':' ).sub( /:$/, ': ' ).split( /:/ ) )
        case scope
        when :all
          yield jar
        when :compile
          # jar.scope is maven scope
          yield jar if jar.scope != :test
        when :provided
          # jar.scope is maven scope
          yield jar if jar.scope == :provided
        when :runtime
          # jar.scope is maven scope
          yield jar if jar.scope != :test and jar.scope != :provided
        when :test
          yield jar
        end
      end
    end
  end
end

Version data entries

42 entries across 41 versions & 10 rubygems

Version Path
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-filter-htmlentities-0.1.0 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/jar-dependencies-0.3.11/lib/jars/lock.rb
jar-dependencies-0.3.11 lib/jars/lock.rb
logstash-input-fifo-0.9.1 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.10/lib/jars/lock.rb
logstash-input-fifo-0.9.0 vendor/bundle/jruby/1.9/gems/jar-dependencies-0.3.10/lib/jars/lock.rb
jar-dependencies-0.3.10 lib/jars/lock.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/jar-dependencies-0.3.9/lib/jars/lock.rb
jar-dependencies-0.3.9 lib/jars/lock.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/jar-dependencies-0.3.8/lib/jars/lock.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/jar-dependencies-0.3.8/lib/jars/lock.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/jar-dependencies-0.3.8/lib/jars/lock.rb