Module: LockJar

Defined in:
lib/lock_jar.rb,
lib/lock_jar/cli.rb,
lib/lock_jar/maven.rb,
lib/lock_jar/bundler.rb,
lib/lock_jar/runtime.rb,
lib/lock_jar/version.rb,
lib/lock_jar/resolver.rb,
lib/lock_jar/domain/dsl.rb,
lib/lock_jar/class_loader.rb,
lib/lock_jar/domain/gem_dsl.rb,
lib/lock_jar/domain/artifact.rb,
lib/lock_jar/domain/lockfile.rb,
lib/lock_jar/domain/dsl_helper.rb,
lib/lock_jar/domain/jarfile_dsl.rb

Overview

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Domain Classes: Bundler, CLI, ClassLoader, Maven, Registry, Resolver, Runtime

Constant Summary collapse

VERSION =
'0.10.0'

Class Method Summary collapse

Class Method Details

.config(opts) ⇒ Object

Override LockJar configuration



34
35
36
# File 'lib/lock_jar.rb', line 34

def self.config( opts )
  Runtime.instance.resolver( opts )
end

.install(*args, &blk) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/lock_jar.rb', line 38

def self.install( *args, &blk )
  lockfile = nil
  opts = {}
  groups = ['default']
    
  args.each do |arg|
    if arg.is_a?(Hash)
      opts.merge!( arg )
    elsif arg.is_a?( String )
      lockfile = arg
    elsif arg.is_a?( Array )
      groups = arg
    end
  end
  
  # default to Jarfile.lock

  if blk.nil? && lockfile.nil?
    lockfile = 'Jarfile.lock'
  end
  
  Runtime.instance.install( lockfile, groups, opts, &blk )
end

.list(*args, &blk) ⇒ Array

Lists all dependencies as notations for groups from the Jarfile.lock. Depending on the type of arg, a different configuration is set.

  • An arg of a String will set the Jarfile.lock, e.g. ‘Better.lock’. Default lock file is Jarfile.lock.

  • An arg of an Array will set the groups, e.g. [‘development’,‘test’]. Defaults group is default

  • An arg of a Hash will set the options, e.g. { :local_repo => ‘path’ }

    • :local_repo [String] sets the local repo path

    • :local_paths [Boolean] to true converts the notations to paths to jars in the local repo path

    • :resolve [Boolean] to true will make transitive dependences resolve before loading to classpath

A block can be passed in, overriding values from a Jarfile.lock.

Returns:

  • (Array)

    of jar and mapped path



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/lock_jar.rb', line 74

def self.list( *args, &blk )
    lockfile = nil
    opts = {}
    groups = ['default']
      
    args.each do |arg|
      if arg.is_a?(Hash)
        opts.merge!( arg )
      elsif arg.is_a?( String )
        lockfile = arg
      elsif arg.is_a?( Array )
        groups = arg
      elsif arg.is_a?( LockJar::Domain::Lockfile )
        lockfile = arg
      end
    end
    
    # default to Jarfile.lock

    if blk.nil? && lockfile.nil?
      lockfile = 'Jarfile.lock'
    end
    
    Runtime.instance.list( lockfile, groups, opts, &blk )
end

.load(*args, &blk) ⇒ Array

LockJar.load(*args): Loads all dependencies to the classpath for groups from the Jarfile.lock. Depending on the type of arg, a different configuration is set.

  • An arg of a String will set the Jarfile.lock, e.g. ‘Better.lock’. Default lock file is Jarfile.lock.

  • An arg of an Array will set the groups, e.g. [‘development’,‘test’].Defaults group is default.

  • An arg of a Hash will set the options, e.g. { :local_repo => ‘path’ }

    * :local_repo sets the local repo path
    * :resolve to true will make transitive dependences resolve before loading to classpath
    

A block can be passed in, overriding values from a Jarfile.lock.

Returns:

  • (Array)

    of absolute paths of jars and mapped paths loaded into claspath



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/lock_jar.rb', line 109

def self.load( *args, &blk )
    lockfile = nil
    opts = {}
    groups = ['default']
      
    args.each do |arg|
      if arg.is_a?(Hash)
        opts.merge!( arg )
      elsif arg.is_a?( String )
        lockfile = arg
      elsif arg.is_a?( Array )
        groups = arg
      elsif arg.is_a?( LockJar::Domain::Lockfile )
        lockfile = arg
      end
    end
    
    # default to Jarfile.lock

    if blk.nil? && lockfile.nil?
      lockfile = 'Jarfile.lock'
    end
    
    Runtime.instance.load( lockfile, groups, opts, &blk )
end

.lock(*args, &blk) ⇒ Hash

Lock a Jarfile and generate a Jarfile.lock.

LockJar.lock accepts an Array for parameters. Depending on the type of arg, a different configuration is set.

  • An arg of a String will set the Jarfile, e.g. ‘Jarfile.different’. Default Jarfile is Jarfile.

  • An arg of a Hash will set the options, e.g. { :local_repo => ‘path’ }

    • :download_artifacts if true, will download jars to local repo. Defaults to true.

    • :local_repo sets the local repo path

    • :lockfile sets the Jarfile.lock path. Default lockfile is Jarfile.lock.

A block can be passed in, overriding values from a Jarfile.

Returns:

  • (Hash)

    Lock data



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/lock_jar.rb', line 147

def self.lock( *args, &blk )
  jarfile = nil
  opts = {}
    
  args.each do |arg|
    if arg.is_a?(Hash)
      opts.merge!( arg )
    elsif arg.is_a?( String ) || arg.is_a?( LockJar::Domain::Dsl )
      jarfile = arg
    end
  end
  
  # default to Jarfile

  if blk.nil? && jarfile.nil?
    jarfile = 'Jarfile'
  end
  
  Runtime.instance.lock( jarfile, opts, &blk )
end

.read(lockfile) ⇒ Hash

Read a Jafile.lock and convert it to a LockJar::Domain::Lockfile

Parameters:

  • lockfile (String)

    path to lockfile

Returns:

  • (Hash)

    Lock Data



172
173
174
# File 'lib/lock_jar.rb', line 172

def self.read( lockfile )
  LockJar::Domain::Lockfile.read( lockfile )
end