lock_jar 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +16 -0
- data/.rubocop.yml +28 -0
- data/.travis.yml +12 -1
- data/Gemfile +6 -3
- data/Guardfile +2 -3
- data/README.md +17 -16
- data/Rakefile +11 -7
- data/lib/lock_jar/buildr.rb +95 -89
- data/lib/lock_jar/bundler.rb +85 -84
- data/lib/lock_jar/class_loader.rb +19 -21
- data/lib/lock_jar/cli.rb +32 -25
- data/lib/lock_jar/domain/artifact.rb +39 -45
- data/lib/lock_jar/domain/dsl.rb +50 -79
- data/lib/lock_jar/domain/dsl_merger.rb +76 -0
- data/lib/lock_jar/domain/gem_dsl.rb +10 -12
- data/lib/lock_jar/domain/jarfile_dsl.rb +6 -18
- data/lib/lock_jar/domain/lockfile.rb +17 -24
- data/lib/lock_jar/logging.rb +4 -3
- data/lib/lock_jar/maven.rb +29 -29
- data/lib/lock_jar/registry.rb +52 -60
- data/lib/lock_jar/resolver.rb +17 -20
- data/lib/lock_jar/runtime/install.rb +28 -0
- data/lib/lock_jar/runtime/list.rb +55 -0
- data/lib/lock_jar/runtime/load.rb +54 -0
- data/lib/lock_jar/runtime/lock.rb +152 -0
- data/lib/lock_jar/runtime.rb +30 -302
- data/lib/lock_jar/version.rb +2 -1
- data/lib/lock_jar.rb +137 -105
- data/lock_jar.gemspec +7 -4
- data/spec/fixtures/jarfile_gem/Gemfile +4 -0
- data/spec/fixtures/jarfile_gem/Jarfile +1 -0
- data/spec/fixtures/jarfile_gem/jarfile_gem.gemspec +23 -0
- data/spec/fixtures/jarfile_gem/lib/jarfile_gem/version.rb +3 -0
- data/spec/fixtures/jarfile_gem/lib/jarfile_gem.rb +5 -0
- data/spec/lock_jar/bundler_spec.rb +27 -0
- data/spec/lock_jar/class_loader_spec.rb +34 -36
- data/spec/lock_jar/cli_spec.rb +39 -46
- data/spec/lock_jar/domain/dsl_merger_spec.rb +49 -0
- data/spec/lock_jar/domain/dsl_spec.rb +35 -37
- data/spec/lock_jar/domain/gem_dsl_spec.rb +18 -0
- data/spec/lock_jar/maven_spec.rb +9 -11
- data/spec/lock_jar/resolver_spec.rb +16 -17
- data/spec/lock_jar/runtime_spec.rb +17 -13
- data/spec/lock_jar_spec.rb +255 -195
- data/spec/spec_helper.rb +13 -8
- data/spec/support/helper.rb +13 -5
- data/spec/support/shared_examples/lockfile.rb +4 -6
- metadata +43 -19
- data/bundler/Gemfile +0 -21
- data/bundler/LICENSE.txt +0 -22
- data/bundler/README.md +0 -29
- data/bundler/Rakefile +0 -2
- data/bundler/lib/lock_jar_bundler/bundler.rb +0 -35
- data/bundler/lib/lock_jar_bundler/piggy_back.rb +0 -98
- data/bundler/lib/lock_jar_bundler/version.rb +0 -5
- data/bundler/lib/lock_jar_bundler.rb +0 -5
- data/bundler/lock_jar_bundler.gemspec +0 -24
- data/bundler/spec/Jarfile +0 -3
- data/bundler/spec/dummy_gem/Jarfile +0 -1
- data/bundler/spec/dummy_gem/dummy_gem.gemspec +0 -19
- data/bundler/spec/lock_jar_bundler_spec.rb +0 -49
- data/bundler/spec/spec_helper.rb +0 -88
- data/lib/lock_jar/domain/dsl_helper.rb +0 -84
- data/spec/lock_jar/domain/dsl_helper_spec.rb +0 -52
data/lib/lock_jar/domain/dsl.rb
CHANGED
@@ -14,13 +14,13 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
require 'lock_jar/maven'
|
17
|
-
require 'lock_jar/domain/
|
17
|
+
require 'lock_jar/domain/dsl_merger'
|
18
18
|
require 'lock_jar/domain/artifact'
|
19
19
|
|
20
20
|
module LockJar
|
21
21
|
module Domain
|
22
|
+
#
|
22
23
|
class Dsl
|
23
|
-
|
24
24
|
DEFAULT_GROUP = ['default']
|
25
25
|
|
26
26
|
attr_accessor :artifacts, :remote_repositories, :local_repository, :groups,
|
@@ -29,46 +29,31 @@ module LockJar
|
|
29
29
|
attr_reader :file_path
|
30
30
|
|
31
31
|
class << self
|
32
|
-
|
33
32
|
def create(jarfile = nil, &blk)
|
34
33
|
builder = new
|
35
34
|
evaluate(builder, jarfile, &blk)
|
36
35
|
end
|
37
36
|
|
38
37
|
def evaluate(builder, jarfile = nil, &blk)
|
39
|
-
if jarfile.nil? && blk.nil?
|
40
|
-
raise "jarfile or block must be set"
|
41
|
-
end
|
38
|
+
fail 'jarfile or block must be set' if jarfile.nil? && blk.nil?
|
42
39
|
|
43
|
-
if jarfile
|
44
|
-
builder.instance_eval(DslHelper.read_file(jarfile.to_s), jarfile.to_s, 1)
|
45
|
-
end
|
40
|
+
builder.instance_eval(IO.read(jarfile.to_s), jarfile.to_s, 1) if jarfile
|
46
41
|
|
47
|
-
if blk
|
48
|
-
builder.instance_eval(&blk)
|
49
|
-
end
|
42
|
+
builder.instance_eval(&blk) if blk
|
50
43
|
|
51
44
|
builder
|
52
45
|
end
|
53
|
-
|
54
46
|
end
|
55
47
|
|
56
48
|
def initialize
|
57
|
-
|
58
49
|
@remote_repositories = []
|
59
50
|
@artifacts = { 'default' => [] }
|
60
|
-
|
61
51
|
@group_changed = false
|
62
|
-
|
63
52
|
@present_group = 'default'
|
64
|
-
|
65
53
|
@local_repository = nil
|
66
54
|
@maps = {}
|
67
|
-
|
68
55
|
@excludes = []
|
69
|
-
|
70
56
|
@merged = []
|
71
|
-
|
72
57
|
@clear_repositories = false
|
73
58
|
end
|
74
59
|
|
@@ -78,83 +63,78 @@ module LockJar
|
|
78
63
|
|
79
64
|
def jar(notation, *args)
|
80
65
|
opts = {}
|
81
|
-
if args.last.is_a? Hash
|
82
|
-
opts.merge!( args.last )
|
83
|
-
end
|
84
66
|
|
85
|
-
|
67
|
+
opts.merge!(args.last) if args.last.is_a? Hash
|
68
|
+
|
69
|
+
artifact = Jar.new(notation)
|
86
70
|
|
87
|
-
assign_groups(
|
71
|
+
assign_groups(artifact, opts[:group])
|
88
72
|
end
|
89
73
|
|
90
|
-
def local(
|
91
|
-
|
92
|
-
if File.directory?( File.expand_path( args.first ) )
|
93
|
-
warn "[DEPRECATION] `local` to set local_repository is deprecated. Please use `local_repo` instead."
|
94
|
-
local_repo(args.first)
|
95
|
-
else
|
96
|
-
path = args.shift
|
74
|
+
def local(*args)
|
75
|
+
return if args.empty?
|
97
76
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
77
|
+
if File.directory?(File.expand_path(args.first))
|
78
|
+
warn(
|
79
|
+
'[DEPRECATED] `local` to set local_repository is deprecated. '\
|
80
|
+
'Please use `local_repo` instead'
|
81
|
+
)
|
82
|
+
local_repo(args.first)
|
83
|
+
else
|
84
|
+
path = args.shift
|
102
85
|
|
103
|
-
|
86
|
+
opts = {}
|
104
87
|
|
105
|
-
|
106
|
-
|
88
|
+
opts.merge!(args.last) if args.last.is_a? Hash
|
89
|
+
|
90
|
+
artifact = Local.new(path)
|
91
|
+
|
92
|
+
assign_groups(artifact, opts[:group])
|
107
93
|
end
|
108
94
|
end
|
109
95
|
|
110
|
-
def local_repo(
|
96
|
+
def local_repo(path)
|
111
97
|
@local_repository = path
|
112
98
|
end
|
113
99
|
|
114
100
|
alias_method :name, :local_repository
|
115
101
|
|
116
102
|
# Map a dependency to another dependency or local directory.
|
117
|
-
def map(
|
103
|
+
def map(notation, *args)
|
118
104
|
@maps[notation] = args
|
119
105
|
end
|
120
106
|
|
121
107
|
#
|
122
108
|
def pom(path, *args)
|
123
|
-
unless path =~ /\.xml$/i
|
124
|
-
raise "#{path} is an invalid pom path"
|
125
|
-
end
|
109
|
+
fail "#{path} is an invalid pom path" unless path =~ /\.xml$/i
|
126
110
|
|
127
|
-
opts = { :
|
111
|
+
opts = { scopes: %w(runtime compile) }
|
128
112
|
|
129
|
-
if args.last.is_a? Hash
|
130
|
-
opts.merge! args.last
|
131
|
-
end
|
132
|
-
|
133
|
-
artifact = Pom.new( path, opts[:scopes] )
|
113
|
+
opts.merge!(args.last) if args.last.is_a? Hash
|
134
114
|
|
135
|
-
assign_groups(
|
115
|
+
assign_groups(Pom.new(path, opts[:scopes]), opts[:groups])
|
136
116
|
end
|
137
117
|
|
138
|
-
def remote_repo(
|
118
|
+
def remote_repo(url, _opts = {})
|
139
119
|
@remote_repositories << url
|
140
120
|
end
|
141
121
|
alias_method :remote_repository, :remote_repo
|
142
122
|
alias_method :repository, :remote_repo
|
143
123
|
|
144
|
-
def group(*groups, &
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
124
|
+
def group(*groups, &_blk)
|
125
|
+
@group_changed = true
|
126
|
+
groups.each do |group|
|
127
|
+
@present_group = group.to_s
|
128
|
+
yield
|
129
|
+
end
|
130
|
+
@group_changed = false
|
131
|
+
@present_group = 'default'
|
152
132
|
end
|
153
133
|
|
154
134
|
# @deprecated Please use {#group} instead
|
155
135
|
def scope(*scopes, &blk)
|
156
|
-
warn
|
157
|
-
group(*scopes
|
136
|
+
warn '[DEPRECATED] `scope` is deprecated. Please use `group` instead.'
|
137
|
+
group(*scopes, &blk)
|
158
138
|
end
|
159
139
|
|
160
140
|
def without_default_maven_repo
|
@@ -162,33 +142,24 @@ module LockJar
|
|
162
142
|
end
|
163
143
|
|
164
144
|
private
|
165
|
-
def assign_groups(artifact, groups=nil)
|
166
145
|
|
146
|
+
def assign_groups(artifact, groups = nil)
|
167
147
|
if groups
|
168
|
-
|
169
|
-
unless groups.is_a? Array
|
170
|
-
groups = [groups]
|
171
|
-
end
|
148
|
+
groups = Array(groups)
|
172
149
|
|
173
150
|
# include present group if within a group block
|
174
|
-
if @group_changed
|
175
|
-
groups << @present_group
|
176
|
-
end
|
151
|
+
groups << @present_group if @group_changed
|
177
152
|
|
178
153
|
else
|
179
154
|
groups = [@present_group]
|
180
155
|
end
|
181
156
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
157
|
+
groups.uniq.each do |group|
|
158
|
+
group_key = group.to_s
|
159
|
+
@artifacts[group_key] = [] unless @artifacts[group_key]
|
160
|
+
@artifacts[group_key] << artifact
|
161
|
+
end if artifact
|
190
162
|
end
|
191
|
-
|
192
163
|
end
|
193
164
|
end
|
194
165
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module LockJar
|
17
|
+
module Domain
|
18
|
+
# Merge DSLs
|
19
|
+
class DslMerger
|
20
|
+
attr_reader :into_dsl, :from_dsl, :into_groups
|
21
|
+
|
22
|
+
# @param [LockJar::Domain::Dsl] into_dsl dsl that is merged into
|
23
|
+
# @param [LockJar::Domain::Dsl] from_dsl dsl that is merged from
|
24
|
+
# @param [String] into_group force only runtime and default groups to be
|
25
|
+
# loaded into this group
|
26
|
+
def initialize(into_dsl, from_dsl, into_groups = nil)
|
27
|
+
@into_dsl = into_dsl
|
28
|
+
@from_dsl = from_dsl
|
29
|
+
@into_groups = into_groups
|
30
|
+
end
|
31
|
+
|
32
|
+
# Merge LockJar::Domain::Dsl
|
33
|
+
# @return [LockJar::Domain::Dsl]
|
34
|
+
def merge
|
35
|
+
merged_dsl = into_dsl.dup
|
36
|
+
|
37
|
+
merged_dsl.remote_repositories = remote_repositories
|
38
|
+
|
39
|
+
merged_dsl.artifacts = artifact_groups(into_groups)
|
40
|
+
|
41
|
+
from_dsl.maps.each do |artifact, paths|
|
42
|
+
maps = into_dsl.maps[artifact] || []
|
43
|
+
merged_dsl.maps[artifact] = (maps + paths).uniq
|
44
|
+
end
|
45
|
+
|
46
|
+
from_dsl.excludes.each do |exclude|
|
47
|
+
merged_dsl.excludes << exclude unless into_dsl.excludes.include? exclude
|
48
|
+
end
|
49
|
+
|
50
|
+
merged_dsl.merged << from_dsl.file_path if from_dsl.file_path
|
51
|
+
|
52
|
+
merged_dsl
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def remote_repositories
|
58
|
+
(into_dsl.remote_repositories + from_dsl.remote_repositories).uniq
|
59
|
+
end
|
60
|
+
|
61
|
+
def artifact_groups(restrict = nil)
|
62
|
+
artifacts = Hash.new { |hash, key| hash[key] = [] }
|
63
|
+
|
64
|
+
from_dsl.artifacts.each do |group, group_artifacts|
|
65
|
+
next if restrict && !restrict.include?(group)
|
66
|
+
artifacts[group] += into_dsl.artifacts[group] || []
|
67
|
+
group_artifacts.each do |art|
|
68
|
+
artifacts[group] << art unless artifacts[group].include? art
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
artifacts
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -15,31 +15,29 @@
|
|
15
15
|
|
16
16
|
require 'lock_jar/maven'
|
17
17
|
require 'lock_jar/domain/jarfile_dsl'
|
18
|
-
require 'lock_jar/domain/
|
18
|
+
require 'lock_jar/domain/dsl_merger'
|
19
19
|
|
20
20
|
module LockJar
|
21
21
|
module Domain
|
22
|
+
# Jarfile found in a Gem
|
22
23
|
class GemDsl < JarfileDsl
|
23
|
-
|
24
24
|
attr_accessor :gem_dir
|
25
|
-
|
25
|
+
|
26
26
|
class << self
|
27
|
-
alias :overriden_create :create
|
28
27
|
def create(spec, jarfile)
|
29
28
|
builder = new
|
30
29
|
builder.gem_dir = spec.gem_dir
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
|
31
|
+
builder.file_path = "gem:#{spec.name}:Jarfile.lock"
|
32
|
+
|
35
33
|
evaluate(builder, jarfile)
|
36
34
|
end
|
37
35
|
end
|
38
|
-
|
39
|
-
|
36
|
+
|
37
|
+
alias_method :overriden_pom, :pom
|
40
38
|
def pom(path, *args)
|
41
|
-
overriden_pom(
|
39
|
+
overriden_pom(File.join(gem_dir, path), *args)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
45
|
-
end
|
43
|
+
end
|
@@ -14,34 +14,22 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
require 'lock_jar/maven'
|
17
|
-
require 'lock_jar/domain/
|
17
|
+
require 'lock_jar/domain/dsl_merger'
|
18
18
|
|
19
19
|
module LockJar
|
20
20
|
module Domain
|
21
|
+
# Jarfile DSL
|
21
22
|
class JarfileDsl < Dsl
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
attr_accessor :file_path
|
24
|
+
|
25
25
|
class << self
|
26
|
-
alias :overriden_create :create
|
27
26
|
def create(jarfile)
|
28
27
|
builder = new
|
29
28
|
builder.file_path = jarfile
|
30
|
-
|
31
|
-
evaluate(builder, jarfile)
|
32
|
-
end
|
33
|
-
end
|
34
29
|
|
35
|
-
|
36
|
-
if groups.nil?
|
37
|
-
groups = [:default]
|
38
|
-
else
|
39
|
-
groups = groups.map(&:to_sym)
|
30
|
+
evaluate(builder, jarfile)
|
40
31
|
end
|
41
|
-
|
42
|
-
@bundler_enabled = groups
|
43
32
|
end
|
44
|
-
|
45
33
|
end
|
46
34
|
end
|
47
|
-
end
|
35
|
+
end
|
@@ -13,21 +13,22 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
-
require
|
17
|
-
require 'lock_jar/version'
|
16
|
+
require 'yaml'
|
18
17
|
require 'set'
|
18
|
+
require 'lock_jar/version'
|
19
19
|
|
20
20
|
module LockJar
|
21
21
|
module Domain
|
22
|
+
# Class representation of the lock file
|
22
23
|
class Lockfile
|
23
|
-
|
24
24
|
attr_accessor :local_repository, :maps, :excludes, :remote_repositories,
|
25
25
|
:version, :groups, :gems, :merged
|
26
26
|
|
27
|
-
|
27
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
28
|
+
def self.read(path)
|
28
29
|
lockfile = Lockfile.new
|
29
30
|
|
30
|
-
lock_data = YAML.load_file(
|
31
|
+
lock_data = YAML.load_file(path)
|
31
32
|
|
32
33
|
lockfile.version = lock_data['version'] || LockJar::VERSION
|
33
34
|
lockfile.merged = lock_data['merged']
|
@@ -36,10 +37,12 @@ module LockJar
|
|
36
37
|
lockfile.maps = lock_data['maps'] || []
|
37
38
|
lockfile.excludes = lock_data['excludes'] || []
|
38
39
|
lockfile.groups = lock_data['groups'] || lock_data['scopes'] || {}
|
39
|
-
lockfile.remote_repositories =
|
40
|
+
lockfile.remote_repositories =
|
41
|
+
Set.new(Array(lock_data['remote_repositories'] || lock_data['repositories']))
|
40
42
|
lockfile.gems = lock_data['gems'] || []
|
41
43
|
lockfile
|
42
44
|
end
|
45
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
43
46
|
|
44
47
|
def initialize
|
45
48
|
@groups = { 'default' => {} }
|
@@ -55,25 +58,15 @@ module LockJar
|
|
55
58
|
def to_hash
|
56
59
|
lock_data = { 'version' => @version }
|
57
60
|
|
58
|
-
unless local_repository.nil?
|
59
|
-
lock_data['local_repository'] = local_repository
|
60
|
-
end
|
61
|
+
lock_data['local_repository'] = local_repository unless local_repository.nil?
|
61
62
|
|
62
|
-
unless merged.empty?
|
63
|
-
lock_data['merged'] = merged
|
64
|
-
end
|
63
|
+
lock_data['merged'] = merged unless merged.empty?
|
65
64
|
|
66
|
-
if maps.size > 0
|
67
|
-
lock_data['maps'] = maps
|
68
|
-
end
|
65
|
+
lock_data['maps'] = maps if maps.size > 0
|
69
66
|
|
70
|
-
if excludes.size > 0
|
71
|
-
lock_data['excludes'] = excludes
|
72
|
-
end
|
67
|
+
lock_data['excludes'] = excludes if excludes.size > 0
|
73
68
|
|
74
|
-
unless gems.empty?
|
75
|
-
lock_data['gems'] = gems
|
76
|
-
end
|
69
|
+
lock_data['gems'] = gems unless gems.empty?
|
77
70
|
|
78
71
|
lock_data['groups'] = groups
|
79
72
|
|
@@ -89,9 +82,9 @@ module LockJar
|
|
89
82
|
to_hash.to_yaml
|
90
83
|
end
|
91
84
|
|
92
|
-
def write(
|
93
|
-
File.open(
|
94
|
-
f.write(
|
85
|
+
def write(path)
|
86
|
+
File.open(path, 'w') do |f|
|
87
|
+
f.write(to_yaml)
|
95
88
|
end
|
96
89
|
end
|
97
90
|
end
|
data/lib/lock_jar/logging.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'naether/java'
|
2
2
|
|
3
3
|
module LockJar
|
4
|
+
#
|
4
5
|
class Logging
|
5
6
|
def self.verbose!
|
6
7
|
Naether::Java.exec_static_method(
|
7
|
-
|
8
|
-
|
9
|
-
[
|
8
|
+
'com.tobedevoured.naether.LogUtil',
|
9
|
+
'setDefaultLogLevel',
|
10
|
+
['info']
|
10
11
|
)
|
11
12
|
end
|
12
13
|
end
|
data/lib/lock_jar/maven.rb
CHANGED
@@ -16,15 +16,12 @@
|
|
16
16
|
require 'naether/maven'
|
17
17
|
|
18
18
|
module LockJar
|
19
|
-
|
20
19
|
# Helper for providing Maven specific operations
|
21
20
|
#
|
22
21
|
# @author Michael Guymon
|
23
|
-
#
|
22
|
+
#
|
24
23
|
class Maven
|
25
|
-
|
26
24
|
class << self
|
27
|
-
|
28
25
|
#
|
29
26
|
# Get the version of a POM
|
30
27
|
#
|
@@ -32,11 +29,11 @@ module LockJar
|
|
32
29
|
#
|
33
30
|
# @return [String] version of POM
|
34
31
|
#
|
35
|
-
def pom_version(
|
36
|
-
maven = Naether::Maven.create_from_pom(
|
37
|
-
maven.version
|
32
|
+
def pom_version(pom_path)
|
33
|
+
maven = Naether::Maven.create_from_pom(pom_path)
|
34
|
+
maven.version
|
38
35
|
end
|
39
|
-
|
36
|
+
|
40
37
|
#
|
41
38
|
# Get dependencies of a Pom
|
42
39
|
#
|
@@ -45,32 +42,33 @@ module LockJar
|
|
45
42
|
#
|
46
43
|
# @return [String] version of POM
|
47
44
|
#
|
48
|
-
def dependencies(
|
49
|
-
maven = Naether::Maven.create_from_pom(
|
45
|
+
def dependencies(pom_path, scopes = %w(compile runtime))
|
46
|
+
maven = Naether::Maven.create_from_pom(pom_path)
|
50
47
|
maven.dependencies(scopes)
|
51
48
|
end
|
52
|
-
|
49
|
+
|
53
50
|
#
|
54
51
|
# Write a POM from list of notations
|
55
52
|
#
|
56
53
|
# @param [String] pom notation
|
57
54
|
# @param [String] file_path path of new pom
|
58
55
|
# @param [Hash] opts
|
59
|
-
# @option opts [Boolean] :include_resolved to add dependencies of resolve
|
56
|
+
# @option opts [Boolean] :include_resolved to add dependencies of resolve
|
57
|
+
# dependencies from Jarfile.lock. Default is true.
|
60
58
|
# @option opts [Array] :dependencies Array of of mixed dependencies:
|
61
|
-
# * [String] Artifact notation, such as groupId:artifactId:version, e.g. 'junit:junit:4.7'
|
59
|
+
# * [String] Artifact notation, such as groupId:artifactId:version, e.g. 'junit:junit:4.7'
|
62
60
|
# * [Hash] of a single artifaction notation => scope - { 'junit:junit:4.7' => 'test' }
|
63
61
|
#
|
64
|
-
def write_pom(
|
65
|
-
opts = {:
|
66
|
-
|
67
|
-
maven = Naether::Maven.create_from_notataion(
|
68
|
-
|
62
|
+
def write_pom(notation, file_path, opts = {})
|
63
|
+
opts = { include_resolved: true }.merge(opts)
|
64
|
+
|
65
|
+
maven = Naether::Maven.create_from_notataion(notation)
|
66
|
+
|
69
67
|
if opts[:include_resolved]
|
70
68
|
# Passes in nil to the resolver to get the cache
|
71
|
-
maven.load_naether(
|
69
|
+
maven.load_naether(Runtime.instance.resolver.naether)
|
72
70
|
end
|
73
|
-
|
71
|
+
|
74
72
|
if opts[:dependencies]
|
75
73
|
opts[:dependencies].each do |dep|
|
76
74
|
if dep.is_a? Array
|
@@ -80,22 +78,24 @@ module LockJar
|
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end
|
83
|
-
|
81
|
+
|
82
|
+
maven.write_pom(file_path)
|
84
83
|
end
|
85
|
-
|
84
|
+
|
86
85
|
#
|
87
86
|
# Deploy an artifact to a Maven repository
|
88
87
|
#
|
89
88
|
# @param [String] notation of artifact
|
90
89
|
# @param [String] file_path path to the Jar
|
91
90
|
# @param [String] url Maven repository deploying to
|
92
|
-
# @param [Hash] deploy_opts options for deploying
|
91
|
+
# @param [Hash] deploy_opts options for deploying
|
93
92
|
# @param [Hash] lockjar_opts options for initializing LockJar
|
94
93
|
#
|
95
|
-
def deploy_artifact(
|
96
|
-
Runtime.instance.resolver(lockjar_opts).naether.deploy_artifact(
|
94
|
+
def deploy_artifact(notation, file_path, url, deploy_opts = {}, lockjar_opts = {})
|
95
|
+
Runtime.instance.resolver(lockjar_opts).naether.deploy_artifact(
|
96
|
+
notation, file_path, url, deploy_opts)
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
#
|
100
100
|
# Install an artifact to a local repository
|
101
101
|
#
|
@@ -104,9 +104,9 @@ module LockJar
|
|
104
104
|
# @param [String] jar_path path to the jar
|
105
105
|
# @param [Hash] opts options
|
106
106
|
#
|
107
|
-
def install(
|
108
|
-
Runtime.instance.resolver(opts).naether.install(
|
107
|
+
def install(notation, pom_path, jar_path, opts = {})
|
108
|
+
Runtime.instance.resolver(opts).naether.install(notation, pom_path, jar_path)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
-
end
|
112
|
+
end
|