lock_jar 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +59 -59
- data/.travis.yml +8 -8
- data/CHANGELOG.md +30 -21
- data/Gemfile +13 -13
- data/Guardfile +9 -9
- data/README.md +375 -375
- data/Rakefile +24 -24
- data/bundler/Gemfile +21 -21
- data/bundler/LICENSE.txt +22 -22
- data/bundler/README.md +29 -29
- data/bundler/Rakefile +2 -2
- data/bundler/lib/lock_jar_bundler/bundler.rb +35 -35
- data/bundler/lib/lock_jar_bundler/piggy_back.rb +97 -97
- data/bundler/lib/lock_jar_bundler/version.rb +5 -5
- data/bundler/lib/lock_jar_bundler.rb +4 -4
- data/bundler/lock_jar_bundler.gemspec +24 -24
- data/bundler/spec/Jarfile +2 -2
- data/bundler/spec/dummy_gem/dummy_gem.gemspec +19 -19
- data/bundler/spec/lock_jar_bundler_spec.rb +48 -48
- data/bundler/spec/spec_helper.rb +88 -88
- data/lib/lock_jar/buildr.rb +144 -144
- data/lib/lock_jar/bundler.rb +154 -154
- data/lib/lock_jar/cli.rb +64 -64
- data/lib/lock_jar/domain/artifact.rb +123 -123
- data/lib/lock_jar/domain/dsl.rb +187 -187
- data/lib/lock_jar/domain/dsl_helper.rb +83 -83
- data/lib/lock_jar/domain/gem_dsl.rb +44 -44
- data/lib/lock_jar/domain/jarfile_dsl.rb +46 -46
- data/lib/lock_jar/domain/lockfile.rb +113 -113
- data/lib/lock_jar/maven.rb +111 -111
- data/lib/lock_jar/registry.rb +92 -92
- data/lib/lock_jar/resolver.rb +95 -95
- data/lib/lock_jar/runtime.rb +359 -355
- data/lib/lock_jar/version.rb +3 -3
- data/lib/lock_jar.rb +172 -177
- data/lock_jar.gemspec +27 -27
- data/spec/fixtures/Jarfile +13 -13
- data/spec/fixtures/Jarfile2 +1 -0
- data/spec/lock_jar/class_loader_spec.rb +57 -57
- data/spec/lock_jar/cli_spec.rb +100 -100
- data/spec/lock_jar/domain/dsl_helper_spec.rb +52 -52
- data/spec/lock_jar/domain/dsl_spec.rb +57 -57
- data/spec/lock_jar/maven_spec.rb +23 -23
- data/spec/lock_jar/resolver_spec.rb +26 -26
- data/spec/lock_jar/runtime_spec.rb +26 -26
- data/spec/lock_jar_spec.rb +372 -295
- data/spec/pom.xml +34 -34
- data/spec/spec_helper.rb +38 -38
- data/spec/support/helper.rb +44 -44
- metadata +3 -1
data/lib/lock_jar/runtime.rb
CHANGED
@@ -1,355 +1,359 @@
|
|
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
|
-
require 'rubygems'
|
17
|
-
require 'yaml'
|
18
|
-
require 'singleton'
|
19
|
-
require 'lock_jar/resolver'
|
20
|
-
require 'lock_jar/registry'
|
21
|
-
require 'lock_jar/domain/dsl'
|
22
|
-
require 'lock_jar/domain/jarfile_dsl'
|
23
|
-
require 'lock_jar/domain/lockfile'
|
24
|
-
|
25
|
-
module LockJar
|
26
|
-
|
27
|
-
class Runtime
|
28
|
-
include Singleton
|
29
|
-
|
30
|
-
attr_reader :current_resolver
|
31
|
-
|
32
|
-
def initialize
|
33
|
-
@current_resolver = nil
|
34
|
-
end
|
35
|
-
|
36
|
-
def resolver( opts = {} )
|
37
|
-
|
38
|
-
# XXX: Caches the resolver by the options. Passing in nil opts will replay
|
39
|
-
# from the cache. This need to change.
|
40
|
-
|
41
|
-
unless opts.nil?
|
42
|
-
if opts[:local_repo]
|
43
|
-
opts[:local_repo] = File.expand_path(opts[:local_repo])
|
44
|
-
end
|
45
|
-
else
|
46
|
-
if @current_resolver
|
47
|
-
opts = @current_resolver.opts
|
48
|
-
else
|
49
|
-
opts = {}
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
if @current_resolver.nil? || opts != @current_resolver.opts
|
54
|
-
@current_resolver = LockJar::Resolver.new( opts )
|
55
|
-
end
|
56
|
-
|
57
|
-
@current_resolver
|
58
|
-
end
|
59
|
-
|
60
|
-
def install( jarfile_lock, groups = ['default'], opts = {}, &blk )
|
61
|
-
deps = list( jarfile_lock, groups, {:with_locals => false}.merge( opts ), &blk )
|
62
|
-
|
63
|
-
lockfile = LockJar::Domain::Lockfile.read( jarfile_lock )
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
lockfile.
|
122
|
-
end
|
123
|
-
|
124
|
-
if jarfile.
|
125
|
-
lockfile.
|
126
|
-
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
if !
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
artifact.
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
deps
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
group['
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
dependencies =
|
255
|
-
end
|
256
|
-
|
257
|
-
if opts[:
|
258
|
-
opts.
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
#
|
271
|
-
#
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
#
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
#
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
end
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
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
|
+
require 'rubygems'
|
17
|
+
require 'yaml'
|
18
|
+
require 'singleton'
|
19
|
+
require 'lock_jar/resolver'
|
20
|
+
require 'lock_jar/registry'
|
21
|
+
require 'lock_jar/domain/dsl'
|
22
|
+
require 'lock_jar/domain/jarfile_dsl'
|
23
|
+
require 'lock_jar/domain/lockfile'
|
24
|
+
|
25
|
+
module LockJar
|
26
|
+
|
27
|
+
class Runtime
|
28
|
+
include Singleton
|
29
|
+
|
30
|
+
attr_reader :current_resolver
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
@current_resolver = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def resolver( opts = {} )
|
37
|
+
|
38
|
+
# XXX: Caches the resolver by the options. Passing in nil opts will replay
|
39
|
+
# from the cache. This need to change.
|
40
|
+
|
41
|
+
unless opts.nil?
|
42
|
+
if opts[:local_repo]
|
43
|
+
opts[:local_repo] = File.expand_path(opts[:local_repo])
|
44
|
+
end
|
45
|
+
else
|
46
|
+
if @current_resolver
|
47
|
+
opts = @current_resolver.opts
|
48
|
+
else
|
49
|
+
opts = {}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if @current_resolver.nil? || opts != @current_resolver.opts
|
54
|
+
@current_resolver = LockJar::Resolver.new( opts )
|
55
|
+
end
|
56
|
+
|
57
|
+
@current_resolver
|
58
|
+
end
|
59
|
+
|
60
|
+
def install( jarfile_lock, groups = ['default'], opts = {}, &blk )
|
61
|
+
deps = list( jarfile_lock, groups, {:with_locals => false}.merge( opts ), &blk )
|
62
|
+
|
63
|
+
lockfile = LockJar::Domain::Lockfile.read( jarfile_lock )
|
64
|
+
if opts[:local_repo].nil? && lockfile.local_repository
|
65
|
+
opts[:local_repo] = lockfile.local_repository
|
66
|
+
end
|
67
|
+
|
68
|
+
lockfile.remote_repositories.each do |repo|
|
69
|
+
resolver(opts).add_remote_repository( repo )
|
70
|
+
end
|
71
|
+
|
72
|
+
files = resolver(opts).download( deps )
|
73
|
+
|
74
|
+
files
|
75
|
+
end
|
76
|
+
|
77
|
+
def lock( jarfile_or_dsl, opts = {}, &blk )
|
78
|
+
|
79
|
+
opts = {:download => true }.merge( opts )
|
80
|
+
|
81
|
+
jarfile = nil
|
82
|
+
|
83
|
+
if jarfile_or_dsl
|
84
|
+
if jarfile_or_dsl.is_a? LockJar::Domain::Dsl
|
85
|
+
jarfile = jarfile_or_dsl
|
86
|
+
else
|
87
|
+
jarfile = LockJar::Domain::JarfileDsl.create( jarfile_or_dsl )
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
unless blk.nil?
|
92
|
+
dsl = LockJar::Domain::Dsl.create(&blk)
|
93
|
+
if jarfile.nil?
|
94
|
+
jarfile = dsl
|
95
|
+
else
|
96
|
+
jarfile = LockJar::Domain::DslHelper.merge( jarfile, dsl )
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
if jarfile.respond_to?(:bundler_enabled ) && jarfile.bundler_enabled
|
101
|
+
require 'lock_jar_bundler/bundler'
|
102
|
+
|
103
|
+
LockJar::Bundler.bundled_jarfiles(jarfile.bundler_enabled).each do |bundled_jarfile|
|
104
|
+
jarfile = LockJar::Domain::DslHelper.merge( jarfile, LockJar::Domain::JarfileDsl.create(bundled_jarfile) )
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# If not set in opts, and is set in dsl
|
110
|
+
if opts[:local_repo].nil? && jarfile.local_repository
|
111
|
+
opts[:local_repo] = jarfile.local_repository
|
112
|
+
end
|
113
|
+
|
114
|
+
lockfile = LockJar::Domain::Lockfile.new
|
115
|
+
|
116
|
+
jarfile.remote_repositories.each do |repo|
|
117
|
+
resolver(opts).add_remote_repository( repo )
|
118
|
+
end
|
119
|
+
|
120
|
+
unless jarfile.local_repository.nil?
|
121
|
+
lockfile.local_repository = jarfile.local_repository
|
122
|
+
end
|
123
|
+
|
124
|
+
if jarfile.maps.size > 0
|
125
|
+
lockfile.maps = jarfile.maps
|
126
|
+
end
|
127
|
+
|
128
|
+
if jarfile.excludes.size > 0
|
129
|
+
lockfile.excludes = jarfile.excludes
|
130
|
+
end
|
131
|
+
|
132
|
+
artifacts = []
|
133
|
+
jarfile.artifacts.each do |group, group_artifacts|
|
134
|
+
group_artifacts.each do |artifact|
|
135
|
+
artifacts += group_artifacts
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
if !jarfile.merged.empty?
|
140
|
+
lockfile.merged = jarfile.merged
|
141
|
+
end
|
142
|
+
|
143
|
+
if !artifacts.empty?
|
144
|
+
resolved_notations = resolver(opts).resolve( artifacts.select{ |artifact| artifact.resolvable? }.map(&:to_dep), opts[:download] == true )
|
145
|
+
|
146
|
+
lockfile.remote_repositories = resolver(opts).remote_repositories - ['http://repo1.maven.org/maven2/']
|
147
|
+
|
148
|
+
jarfile.artifacts.each do |group_name, group_artifacts|
|
149
|
+
group = {'locals' => [], 'dependencies' => [], 'artifacts' => []}
|
150
|
+
|
151
|
+
group_artifacts.each do |artifact|
|
152
|
+
|
153
|
+
artifact_data = {}
|
154
|
+
|
155
|
+
if artifact.is_a? LockJar::Domain::Jar
|
156
|
+
group['dependencies'] << artifact.notation
|
157
|
+
artifact_data["transitive"] = resolver(opts).dependencies_graph[artifact.notation].to_hash
|
158
|
+
|
159
|
+
elsif artifact.is_a? LockJar::Domain::Pom
|
160
|
+
artifact_data['scopes'] = artifact.scopes
|
161
|
+
|
162
|
+
# iterate each dependency in Pom to map transitive dependencies
|
163
|
+
transitive = {}
|
164
|
+
artifact.notations.each do |notation|
|
165
|
+
transitive.merge!( notation => resolver(opts).dependencies_graph[notation] )
|
166
|
+
end
|
167
|
+
artifact_data["transitive"] = transitive
|
168
|
+
|
169
|
+
elsif artifact.is_a? LockJar::Domain::Local
|
170
|
+
group['locals'] << artifact.path
|
171
|
+
else
|
172
|
+
# XXX: handle unsupported artifact
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
# flatten the graph of nested hashes
|
177
|
+
dep_merge = lambda do |graph|
|
178
|
+
deps = graph.keys
|
179
|
+
graph.values.each do |next_step|
|
180
|
+
deps += dep_merge.call(next_step)
|
181
|
+
end
|
182
|
+
deps
|
183
|
+
end
|
184
|
+
|
185
|
+
if artifact_data["transitive"]
|
186
|
+
group['dependencies'] += dep_merge.call( artifact_data["transitive"] )
|
187
|
+
|
188
|
+
# xxX: set required_by ?
|
189
|
+
|
190
|
+
group['artifacts'] << { artifact.to_urn => artifact_data }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
if lockfile.excludes
|
195
|
+
lockfile.excludes.each do |exclude|
|
196
|
+
group['dependencies'].delete_if { |dep| dep =~ /#{exclude}/ }
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
group['dependencies'].sort!
|
201
|
+
if group['locals'].empty?
|
202
|
+
group.delete 'locals'
|
203
|
+
end
|
204
|
+
|
205
|
+
lockfile.groups[group_name] = group
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
lockfile.write( opts[:lockfile] || "Jarfile.lock" )
|
210
|
+
|
211
|
+
lockfile
|
212
|
+
end
|
213
|
+
|
214
|
+
def list( lockfile_or_path, groups = ['default'], opts = {}, &blk )
|
215
|
+
|
216
|
+
lockfile = nil
|
217
|
+
dependencies = []
|
218
|
+
maps = []
|
219
|
+
with_locals = {:with_locals => true }.merge(opts).delete :with_locals
|
220
|
+
|
221
|
+
if lockfile_or_path
|
222
|
+
if lockfile_or_path.is_a? LockJar::Domain::Lockfile
|
223
|
+
lockfile = lockfile_or_path
|
224
|
+
elsif lockfile_or_path
|
225
|
+
lockfile = LockJar::Domain::Lockfile.read( lockfile_or_path )
|
226
|
+
end
|
227
|
+
|
228
|
+
dependencies = lockfile_dependencies( lockfile, groups, with_locals )
|
229
|
+
maps = lockfile.maps
|
230
|
+
end
|
231
|
+
|
232
|
+
# Support limited DSL from block
|
233
|
+
unless blk.nil?
|
234
|
+
dsl = LockJar::Domain::Dsl.create(&blk)
|
235
|
+
dependencies += dsl_dependencies( dsl, groups, with_locals ).map(&:to_dep)
|
236
|
+
maps = dsl.maps
|
237
|
+
end
|
238
|
+
|
239
|
+
if maps && maps.size > 0
|
240
|
+
mapped_dependencies = []
|
241
|
+
|
242
|
+
maps.each do |notation, replacements|
|
243
|
+
dependencies.each do |dep|
|
244
|
+
if dep =~ /#{notation}/
|
245
|
+
replacements.each do |replacement|
|
246
|
+
mapped_dependencies << replacement
|
247
|
+
end
|
248
|
+
else
|
249
|
+
mapped_dependencies << dep
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
dependencies = mapped_dependencies
|
255
|
+
end
|
256
|
+
|
257
|
+
if opts[:resolve]
|
258
|
+
dependencies = resolver(opts).resolve( dependencies )
|
259
|
+
end
|
260
|
+
|
261
|
+
if opts[:local_paths]
|
262
|
+
opts.delete( :local_paths ) # remove list opts so resolver is not reset
|
263
|
+
resolver(opts).to_local_paths( dependencies )
|
264
|
+
|
265
|
+
else
|
266
|
+
dependencies
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
# Load paths from a lockfile or block. Paths are loaded once per lockfile.
|
271
|
+
#
|
272
|
+
# @param [String] lockfile_path the lockfile
|
273
|
+
# @param [Array] groups to load into classpath
|
274
|
+
# @param [Hash] opts
|
275
|
+
# @param [Block] blk
|
276
|
+
def load( lockfile_or_path, groups = ['default'], opts = {}, &blk )
|
277
|
+
|
278
|
+
lockfile = nil
|
279
|
+
|
280
|
+
# lockfile is only loaded once
|
281
|
+
unless lockfile_or_path.nil?
|
282
|
+
# loaded a Lockfile instance
|
283
|
+
if lockfile_or_path.is_a? LockJar::Domain::Lockfile
|
284
|
+
lockfile = lockfile_or_path
|
285
|
+
|
286
|
+
# check if lockfile path is already loaded
|
287
|
+
elsif LockJar::Registry.instance.lockfile_registered?( lockfile_or_path )
|
288
|
+
return
|
289
|
+
|
290
|
+
# convert lockfile path to a Lockfile instance
|
291
|
+
else
|
292
|
+
lockfile = LockJar::Domain::Lockfile.read( lockfile_or_path )
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
if opts[:local_repo].nil? && lockfile.local_repository
|
297
|
+
opts[:local_repo] = lockfile.local_repository
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
# set local_repo if passed in the block
|
302
|
+
unless blk.nil?
|
303
|
+
dsl = LockJar::Domain::Dsl.create(&blk)
|
304
|
+
|
305
|
+
# set local_repo from block
|
306
|
+
if opts[:local_repo].nil? && dsl.local_repository
|
307
|
+
opts[:local_repo] = dsl.local_repository
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# registered merged lockfiles for lockfile
|
312
|
+
if lockfile && !lockfile.merged.empty?
|
313
|
+
lockfile.merged.each do |path|
|
314
|
+
LockJar::Registry.instance.register_lockfile( path )
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
dependencies = LockJar::Registry.instance.register_jars( list( lockfile, groups, opts, &blk ) )
|
319
|
+
|
320
|
+
resolver(opts).load_to_classpath( dependencies )
|
321
|
+
end
|
322
|
+
|
323
|
+
private
|
324
|
+
|
325
|
+
def lockfile_dependencies( lockfile, groups, with_locals = true)
|
326
|
+
dependencies = []
|
327
|
+
|
328
|
+
groups.each do |group|
|
329
|
+
if lockfile.groups[group.to_s]
|
330
|
+
dependencies += lockfile.groups[group.to_s]['dependencies']
|
331
|
+
|
332
|
+
if with_locals
|
333
|
+
locals = lockfile.groups[group.to_s]['locals']
|
334
|
+
dependencies += locals if locals
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
dependencies
|
340
|
+
end
|
341
|
+
|
342
|
+
def dsl_dependencies( dsl, groups, with_locals = true)
|
343
|
+
|
344
|
+
dependencies = []
|
345
|
+
|
346
|
+
groups.each do |group|
|
347
|
+
if dsl.artifacts[group.to_s]
|
348
|
+
dependencies += dsl.artifacts[group.to_s]
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
unless with_locals
|
353
|
+
dependencies.select! { |dep| !dep.is_a? LockJar::Domain::Local }
|
354
|
+
end
|
355
|
+
|
356
|
+
dependencies
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|