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/spec/lock_jar_spec.rb
CHANGED
@@ -1,90 +1,97 @@
|
|
1
|
-
require
|
2
|
-
require 'rubygems'
|
1
|
+
require 'spec_helper'
|
3
2
|
require 'lib/lock_jar'
|
4
3
|
require 'lib/lock_jar/domain/dsl'
|
5
4
|
require 'naether'
|
6
5
|
|
7
6
|
describe LockJar do
|
7
|
+
include Spec::Helpers
|
8
8
|
|
9
9
|
before do
|
10
10
|
LockJar::Runtime.instance.reset!
|
11
11
|
|
12
|
-
if File.
|
13
|
-
|
12
|
+
if File.exist?(TEMP_DIR)
|
13
|
+
remove_file("#{TEMP_DIR}/Jarfile.lock")
|
14
14
|
else
|
15
|
-
Dir.mkdir(
|
15
|
+
Dir.mkdir(TEMP_DIR)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
context
|
19
|
+
describe '#lock' do
|
20
|
+
context 'creates a lockfile' do
|
21
21
|
let(:lockfile) do
|
22
|
-
LockJar.lock(
|
23
|
-
File.
|
22
|
+
LockJar.lock(lockjar_source, local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/Jarfile.lock")
|
23
|
+
expect(File).to exist("#{TEMP_DIR}/Jarfile.lock")
|
24
24
|
LockJar.read("#{TEMP_DIR}/Jarfile.lock")
|
25
25
|
end
|
26
26
|
|
27
|
-
context
|
28
|
-
let(:lockjar_source) {
|
27
|
+
context 'from Jarfile' do
|
28
|
+
let(:lockjar_source) { 'spec/fixtures/Jarfile' }
|
29
29
|
|
30
30
|
let(:expected_version) { LockJar::VERSION }
|
31
31
|
let(:expected_local_repository) { '~/.m2/repository' }
|
32
|
-
let(:expected_excludes) { %w
|
33
|
-
let(:expected_remote_repositories) { %w
|
32
|
+
let(:expected_excludes) { %w(commons-logging logkit) }
|
33
|
+
let(:expected_remote_repositories) { %w(http://repo1.maven.org/maven2/) }
|
34
34
|
let(:expected_groups) do
|
35
35
|
{
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
36
|
+
'default' => {
|
37
|
+
'locals' => ['spec/fixtures/naether-0.13.0.jar'],
|
38
|
+
'dependencies' => %w(
|
39
|
+
ch.qos.logback:logback-classic:jar:0.9.24
|
40
|
+
ch.qos.logback:logback-core:jar:0.9.24 com.metapossum:metapossum-scanner:jar:1.0
|
41
|
+
com.slackworks:modelcitizen:jar:0.2.2
|
42
|
+
commons-beanutils:commons-beanutils:jar:1.8.3 commons-io:commons-io:jar:1.4
|
43
|
+
commons-lang:commons-lang:jar:2.6 commons-logging:commons-logging:jar:1.1.1
|
44
|
+
org.apache.mina:mina-core:jar:2.0.4
|
45
|
+
org.slf4j:slf4j-api:jar:1.6.1
|
46
|
+
),
|
47
|
+
'artifacts' => [
|
48
|
+
{
|
49
|
+
'jar:org.apache.mina:mina-core:jar:2.0.4' => {
|
50
|
+
'transitive' => { 'org.slf4j:slf4j-api:jar:1.6.1' => {} }
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
'pom:spec/pom.xml' => {
|
55
|
+
'scopes' => %w(runtime compile),
|
56
|
+
'transitive' => {
|
57
|
+
'com.slackworks:modelcitizen:jar:0.2.2' => {
|
58
|
+
'com.metapossum:metapossum-scanner:jar:1.0' => {
|
59
|
+
'commons-io:commons-io:jar:1.4' => {}
|
60
|
+
},
|
61
|
+
'commons-beanutils:commons-beanutils:jar:1.8.3' => {
|
62
|
+
'commons-logging:commons-logging:jar:1.1.1' => {}
|
63
|
+
},
|
64
|
+
'ch.qos.logback:logback-classic:jar:0.9.24' => {
|
65
|
+
'ch.qos.logback:logback-core:jar:0.9.24' => {}
|
66
|
+
},
|
67
|
+
'commons-lang:commons-lang:jar:2.6' => {}
|
68
|
+
}
|
64
69
|
}
|
65
70
|
}
|
66
71
|
}
|
67
|
-
|
72
|
+
]
|
68
73
|
},
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
+
'development' => {
|
75
|
+
'dependencies' => ['com.typesafe:config:jar:0.5.0'],
|
76
|
+
'artifacts' => [
|
77
|
+
{ 'jar:com.typesafe:config:jar:0.5.0' => { 'transitive' => {} } }
|
78
|
+
]
|
74
79
|
},
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
'test' => {
|
81
|
+
'dependencies' => %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1),
|
82
|
+
'artifacts' => [
|
83
|
+
{
|
84
|
+
'jar:junit:junit:jar:4.10' => {
|
85
|
+
'transitive' => { 'org.hamcrest:hamcrest-core:jar:1.1' => {} }
|
86
|
+
}
|
87
|
+
}
|
88
|
+
]
|
81
89
|
}
|
82
90
|
}
|
83
91
|
end
|
84
92
|
end
|
85
93
|
|
86
|
-
context
|
87
|
-
|
94
|
+
context 'from a dsl' do
|
88
95
|
describe '#without_default_maven_repo' do
|
89
96
|
let(:lockjar_source) do
|
90
97
|
LockJar::Domain::Dsl.create do
|
@@ -95,16 +102,19 @@ describe LockJar do
|
|
95
102
|
end
|
96
103
|
|
97
104
|
let(:expected_version) { LockJar::VERSION }
|
98
|
-
let(:expected_maps) { {
|
99
|
-
let(:expected_remote_repositories) {
|
105
|
+
let(:expected_maps) { { 'junit:junit:4.10' => [TEMP_DIR] } }
|
106
|
+
let(:expected_remote_repositories) { ['https://repository.jboss.org/nexus/content/groups/public'] }
|
100
107
|
let(:expected_groups) do
|
101
108
|
{
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
109
|
+
'default' => {
|
110
|
+
'dependencies' => %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1),
|
111
|
+
'artifacts' => [
|
112
|
+
{
|
113
|
+
'jar:junit:junit:jar:4.10' => {
|
114
|
+
'transitive' => { 'org.hamcrest:hamcrest-core:jar:1.1' => {} }
|
115
|
+
}
|
116
|
+
}
|
117
|
+
]
|
108
118
|
}
|
109
119
|
}
|
110
120
|
end
|
@@ -115,22 +125,25 @@ describe LockJar do
|
|
115
125
|
describe '#map' do
|
116
126
|
let(:lockjar_source) do
|
117
127
|
LockJar::Domain::Dsl.create do
|
118
|
-
map 'junit:junit:4.10',
|
128
|
+
map 'junit:junit:4.10', TEMP_DIR
|
119
129
|
jar 'junit:junit:4.10'
|
120
130
|
end
|
121
131
|
end
|
122
132
|
|
123
133
|
let(:expected_version) { LockJar::VERSION }
|
124
|
-
let(:expected_maps) { {
|
125
|
-
let(:expected_remote_repositories) {
|
134
|
+
let(:expected_maps) { { 'junit:junit:4.10' => [TEMP_DIR] } }
|
135
|
+
let(:expected_remote_repositories) { ['http://repo1.maven.org/maven2/'] }
|
126
136
|
let(:expected_groups) do
|
127
137
|
{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
138
|
+
'default' => {
|
139
|
+
'dependencies' => %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1),
|
140
|
+
'artifacts' => [
|
141
|
+
{
|
142
|
+
'jar:junit:junit:jar:4.10' => {
|
143
|
+
'transitive' => { 'org.hamcrest:hamcrest-core:jar:1.1' => {} }
|
144
|
+
}
|
145
|
+
}
|
146
|
+
]
|
134
147
|
}
|
135
148
|
}
|
136
149
|
end
|
@@ -148,28 +161,31 @@ describe LockJar do
|
|
148
161
|
end
|
149
162
|
|
150
163
|
let(:expected_version) { LockJar::VERSION }
|
151
|
-
let(:expected_excludes) { %w
|
152
|
-
let(:expected_remote_repositories) { %w
|
164
|
+
let(:expected_excludes) { %w(commons-logging logkit) }
|
165
|
+
let(:expected_remote_repositories) { %w(http://repo1.maven.org/maven2/ https://repository.jboss.org/nexus/content/groups/public) }
|
153
166
|
let(:expected_groups) do
|
154
|
-
{
|
155
|
-
{
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
{
|
168
|
+
'default' => {
|
169
|
+
'dependencies' => %w(
|
170
|
+
avalon-framework:avalon-framework:jar:4.1.3 javax.jms:jms:jar:1.1
|
171
|
+
javax.servlet:servlet-api:jar:2.3 log4j:log4j:jar:1.2.12
|
172
|
+
opensymphony:oscache:jar:2.4.1
|
173
|
+
),
|
174
|
+
'artifacts' => [
|
175
|
+
{
|
176
|
+
'jar:opensymphony:oscache:jar:2.4.1' => {
|
177
|
+
'transitive' => {
|
178
|
+
'commons-logging:commons-logging:jar:1.1' => {
|
179
|
+
'logkit:logkit:jar:1.0.1' => {},
|
180
|
+
'log4j:log4j:jar:1.2.12' => {},
|
181
|
+
'avalon-framework:avalon-framework:jar:4.1.3' => {}
|
182
|
+
},
|
183
|
+
'javax.jms:jms:jar:1.1' => {},
|
184
|
+
'javax.servlet:servlet-api:jar:2.3' => {}
|
185
|
+
}
|
170
186
|
}
|
171
187
|
}
|
172
|
-
|
188
|
+
]
|
173
189
|
}
|
174
190
|
}
|
175
191
|
end
|
@@ -180,45 +196,48 @@ describe LockJar do
|
|
180
196
|
|
181
197
|
context 'from a block' do
|
182
198
|
let(:lockfile) do
|
183
|
-
LockJar.lock(
|
184
|
-
jar
|
199
|
+
LockJar.lock(local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/NoRepoJarfile.lock") do
|
200
|
+
jar 'org.eclipse.jetty:jetty-servlet:8.1.3.v20120416'
|
185
201
|
end
|
186
202
|
|
187
|
-
File.
|
203
|
+
File.exist?("#{TEMP_DIR}/NoRepoJarfile.lock").should be_true
|
188
204
|
|
189
205
|
LockJar.read("#{TEMP_DIR}/NoRepoJarfile.lock")
|
190
206
|
end
|
191
207
|
|
192
208
|
let(:expected_version) { LockJar::VERSION }
|
193
|
-
let(:expected_remote_repositories) { %w
|
209
|
+
let(:expected_remote_repositories) { %w(http://repo1.maven.org/maven2/) }
|
194
210
|
let(:expected_groups) do
|
195
211
|
{
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
212
|
+
'default' => {
|
213
|
+
'dependencies' => %w(
|
214
|
+
org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016
|
215
|
+
org.eclipse.jetty:jetty-continuation:jar:8.1.3.v20120416
|
216
|
+
org.eclipse.jetty:jetty-http:jar:8.1.3.v20120416
|
217
|
+
org.eclipse.jetty:jetty-io:jar:8.1.3.v20120416
|
218
|
+
org.eclipse.jetty:jetty-security:jar:8.1.3.v20120416
|
219
|
+
org.eclipse.jetty:jetty-server:jar:8.1.3.v20120416
|
220
|
+
org.eclipse.jetty:jetty-servlet:jar:8.1.3.v20120416
|
221
|
+
org.eclipse.jetty:jetty-util:jar:8.1.3.v20120416),
|
222
|
+
'artifacts' => [
|
223
|
+
{
|
224
|
+
'jar:org.eclipse.jetty:jetty-servlet:jar:8.1.3.v20120416' => {
|
225
|
+
'transitive' => {
|
226
|
+
'org.eclipse.jetty:jetty-security:jar:8.1.3.v20120416' => {
|
227
|
+
'org.eclipse.jetty:jetty-server:jar:8.1.3.v20120416' => {
|
228
|
+
'org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016' => {},
|
229
|
+
'org.eclipse.jetty:jetty-continuation:jar:8.1.3.v20120416' => {},
|
230
|
+
'org.eclipse.jetty:jetty-http:jar:8.1.3.v20120416' => {
|
231
|
+
'org.eclipse.jetty:jetty-io:jar:8.1.3.v20120416' => {
|
232
|
+
'org.eclipse.jetty:jetty-util:jar:8.1.3.v20120416' => {}
|
233
|
+
}
|
215
234
|
}
|
216
235
|
}
|
217
236
|
}
|
218
237
|
}
|
219
238
|
}
|
220
239
|
}
|
221
|
-
|
240
|
+
]
|
222
241
|
}
|
223
242
|
}
|
224
243
|
end
|
@@ -228,12 +247,11 @@ describe LockJar do
|
|
228
247
|
end
|
229
248
|
end
|
230
249
|
|
231
|
-
describe
|
232
|
-
it
|
233
|
-
|
234
|
-
LockJar.lock( "spec/fixtures/Jarfile", :download_artifacts => false, :local_repo => "#{TEMP_DIR}/test-repo-install", :lockfile => "#{TEMP_DIR}/Jarfile.lock" )
|
250
|
+
describe '#install' do
|
251
|
+
it 'should install jars' do
|
252
|
+
LockJar.lock('spec/fixtures/Jarfile', download_artifacts: false, local_repo: "#{TEMP_DIR}/test-repo-install", lockfile: "#{TEMP_DIR}/Jarfile.lock")
|
235
253
|
|
236
|
-
jars = LockJar.install(
|
254
|
+
jars = LockJar.install("#{TEMP_DIR}/Jarfile.lock", ['default'], local_repo: "#{TEMP_DIR}/test-repo-install")
|
237
255
|
jars.should eql([
|
238
256
|
File.expand_path("#{TEMP_DIR}/test-repo-install/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"),
|
239
257
|
File.expand_path("#{TEMP_DIR}/test-repo-install/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"),
|
@@ -247,103 +265,133 @@ describe LockJar do
|
|
247
265
|
File.expand_path("#{TEMP_DIR}/test-repo-install/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar")
|
248
266
|
])
|
249
267
|
end
|
250
|
-
|
251
268
|
end
|
252
269
|
|
253
|
-
describe
|
270
|
+
describe '#register_jarfile' do
|
254
271
|
after do
|
255
272
|
LockJar.reset_registered_jarfiles
|
256
273
|
end
|
257
274
|
|
258
275
|
it 'should add an existing jarfiles in order' do
|
259
|
-
LockJar.register_jarfile
|
260
|
-
LockJar.register_jarfile
|
261
|
-
LockJar.registered_jarfiles.should ==
|
262
|
-
[
|
276
|
+
LockJar.register_jarfile 'spec/fixtures/Jarfile'
|
277
|
+
LockJar.register_jarfile 'spec/fixtures/Jarfile2'
|
278
|
+
LockJar.registered_jarfiles.keys.should ==
|
279
|
+
['spec/fixtures/Jarfile', 'spec/fixtures/Jarfile2']
|
263
280
|
end
|
264
281
|
|
265
282
|
it 'should not add a missing jarfile' do
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
"Jarfile not found: spec/fixtures/NotAJarfile")
|
283
|
+
expect { LockJar.register_jarfile 'spec/fixtures/NotAJarfile' }.to(
|
284
|
+
raise_error(RuntimeError, 'Jarfile not found: spec/fixtures/NotAJarfile')
|
285
|
+
)
|
270
286
|
end
|
271
287
|
end
|
272
288
|
|
273
|
-
describe
|
289
|
+
describe '#lock_registered_jarfiles' do
|
274
290
|
after do
|
275
291
|
LockJar.reset_registered_jarfiles
|
276
292
|
end
|
277
293
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
294
|
+
let(:lock_registered_jarfiles) { LockJar.lock_registered_jarfiles lockfile: lockfile }
|
295
|
+
|
296
|
+
context 'with LRJJarfile1.lock' do
|
297
|
+
let(:lockfile) { "#{TEMP_DIR}/LRJJarfile1.lock" }
|
298
|
+
|
299
|
+
before do
|
300
|
+
File.unlink lockfile if File.exist? lockfile
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'should work with no jarfiles' do
|
304
|
+
expect(lock_registered_jarfiles).to be_nil
|
305
|
+
expect(File).to_not exist(lockfile)
|
306
|
+
end
|
284
307
|
end
|
285
308
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
309
|
+
context 'with multiple lockfiles' do
|
310
|
+
let(:lockfile) { "#{TEMP_DIR}/LRJJarfile2.lock" }
|
311
|
+
|
312
|
+
before do
|
313
|
+
LockJar.register_jarfile 'spec/fixtures/Jarfile'
|
314
|
+
LockJar.register_jarfile 'spec/fixtures/Jarfile2'
|
315
|
+
File.unlink lockfile if File.exist? lockfile
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'should dependencies from all jarfiles' do
|
319
|
+
artifacts = lock_registered_jarfiles.to_hash['groups']['default']['artifacts'].flat_map(&:keys)
|
320
|
+
artifacts.should eq %w(
|
321
|
+
jar:org.apache.mina:mina-core:jar:2.0.4
|
322
|
+
pom:spec/pom.xml
|
323
|
+
jar:org.eclipse.jetty:jetty-servlet:jar:8.1.3.v20120416
|
324
|
+
)
|
325
|
+
expect(File).to exist(lockfile)
|
326
|
+
end
|
299
327
|
end
|
300
|
-
end
|
301
328
|
|
302
|
-
|
303
|
-
|
329
|
+
context 'with gem lockfiles' do
|
330
|
+
let(:lockfile) { "#{TEMP_DIR}/Jarfile.lock" }
|
331
|
+
let(:gem_spec) { Gem::Specification.find_by_name('jarfile_gem') }
|
332
|
+
let(:lock_registered_jarfiles) { LockJar.lock_registered_jarfiles lockfile: lockfile }
|
304
333
|
|
305
|
-
|
334
|
+
before do
|
335
|
+
LockJar.register_jarfile File.join(gem_spec.full_gem_path, 'Jarfile'), gem_spec
|
336
|
+
File.unlink lockfile if File.exist? lockfile
|
337
|
+
end
|
306
338
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
"org.slf4j:slf4j-api:jar:1.6.1", "spec/fixtures/naether-0.13.0.jar", "com.typesafe:config:jar:0.5.0" ])
|
339
|
+
it 'should have gem dependencies' do
|
340
|
+
artifacts = lock_registered_jarfiles.to_hash['groups']['default']['artifacts'].flat_map(&:keys)
|
341
|
+
artifacts.should eq %w(
|
342
|
+
jar:commons-lang:commons-lang:jar:2.4
|
343
|
+
)
|
344
|
+
expect(File).to exist(lockfile)
|
345
|
+
end
|
315
346
|
end
|
347
|
+
end
|
316
348
|
|
317
|
-
|
349
|
+
describe '#list' do
|
350
|
+
it 'should list jars' do
|
351
|
+
LockJar.lock('spec/fixtures/Jarfile', local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/Jarfile.lock")
|
352
|
+
|
353
|
+
jars = LockJar.list("#{TEMP_DIR}/Jarfile.lock", ['default', 'development', 'bad scope'], local_repo: "#{TEMP_DIR}/test-repo")
|
354
|
+
jars.should eql(
|
355
|
+
%w(
|
356
|
+
ch.qos.logback:logback-classic:jar:0.9.24 ch.qos.logback:logback-core:jar:0.9.24
|
357
|
+
com.metapossum:metapossum-scanner:jar:1.0 com.slackworks:modelcitizen:jar:0.2.2
|
358
|
+
commons-beanutils:commons-beanutils:jar:1.8.3 commons-io:commons-io:jar:1.4
|
359
|
+
commons-lang:commons-lang:jar:2.6 commons-logging:commons-logging:jar:1.1.1
|
360
|
+
org.apache.mina:mina-core:jar:2.0.4
|
361
|
+
org.slf4j:slf4j-api:jar:1.6.1 spec/fixtures/naether-0.13.0.jar com.typesafe:config:jar:0.5.0
|
362
|
+
)
|
363
|
+
)
|
364
|
+
end
|
365
|
+
|
366
|
+
it 'should replace dependencies with maps' do
|
318
367
|
dsl = LockJar::Domain::Dsl.create do
|
319
|
-
map 'junit:junit',
|
368
|
+
map 'junit:junit', TEMP_DIR
|
320
369
|
jar 'junit:junit:4.10'
|
321
370
|
end
|
322
371
|
|
323
|
-
LockJar.lock(
|
324
|
-
paths = LockJar.list(
|
325
|
-
paths.should eql(
|
372
|
+
LockJar.lock(dsl, local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/ListJarfile.lock")
|
373
|
+
paths = LockJar.list("#{TEMP_DIR}/ListJarfile.lock", local_repo: "#{TEMP_DIR}/test-repo")
|
374
|
+
paths.should eql([TEMP_DIR, 'org.hamcrest:hamcrest-core:jar:1.1'])
|
326
375
|
end
|
327
376
|
|
328
|
-
it
|
377
|
+
it 'should replace dependencies with maps and get local paths' do
|
329
378
|
dsl = LockJar::Domain::Dsl.create do
|
330
|
-
map 'junit:junit',
|
379
|
+
map 'junit:junit', TEMP_DIR
|
331
380
|
jar 'junit:junit:4.10'
|
332
381
|
end
|
333
382
|
|
334
|
-
LockJar.lock(
|
335
|
-
paths = LockJar.list(
|
336
|
-
paths.should eql(
|
383
|
+
LockJar.lock(dsl, local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/ListJarfile.lock")
|
384
|
+
paths = LockJar.list("#{TEMP_DIR}/ListJarfile.lock", local_repo: "#{TEMP_DIR}/test-repo")
|
385
|
+
paths.should eql([TEMP_DIR, 'org.hamcrest:hamcrest-core:jar:1.1'])
|
337
386
|
end
|
338
387
|
end
|
339
388
|
|
340
|
-
describe
|
341
|
-
|
389
|
+
describe '#load' do
|
342
390
|
def expect_java_class_not_loaded(java_class)
|
343
391
|
if Naether.platform == 'java'
|
344
392
|
lambda { java_import java_class }.should raise_error
|
345
393
|
else
|
346
|
-
lambda { Rjb
|
394
|
+
lambda { Rjb.import(java_class) }.should raise_error
|
347
395
|
end
|
348
396
|
end
|
349
397
|
|
@@ -351,13 +399,13 @@ describe LockJar do
|
|
351
399
|
if Naether.platform == 'java'
|
352
400
|
lambda { java_import java_class }.should_not raise_error
|
353
401
|
else
|
354
|
-
lambda { Rjb
|
402
|
+
lambda { Rjb.import(java_class) }.should_not raise_error
|
355
403
|
end
|
356
404
|
end
|
357
405
|
|
358
406
|
let(:expected_jars) do
|
359
407
|
[
|
360
|
-
|
408
|
+
'spec/fixtures/naether-0.13.0.jar',
|
361
409
|
File.expand_path("#{TEMP_DIR}/test-repo/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"),
|
362
410
|
File.expand_path("#{TEMP_DIR}/test-repo/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"),
|
363
411
|
File.expand_path("#{TEMP_DIR}/test-repo/com/metapossum/metapossum-scanner/1.0/metapossum-scanner-1.0.jar"),
|
@@ -367,60 +415,72 @@ describe LockJar do
|
|
367
415
|
File.expand_path("#{TEMP_DIR}/test-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"),
|
368
416
|
File.expand_path("#{TEMP_DIR}/test-repo/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"),
|
369
417
|
File.expand_path("#{TEMP_DIR}/test-repo/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"),
|
370
|
-
File.expand_path("#{TEMP_DIR}/test-repo/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar")
|
418
|
+
File.expand_path("#{TEMP_DIR}/test-repo/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar")
|
371
419
|
]
|
372
420
|
end
|
373
421
|
|
374
|
-
it
|
422
|
+
it 'by Jarfile.lock' do
|
375
423
|
expect_java_class_not_loaded('org.apache.mina.core.IoUtil')
|
376
424
|
|
377
|
-
LockJar.lock(
|
378
|
-
jars = LockJar.load(
|
379
|
-
LockJar::Registry.instance.lockfile_registered?(
|
380
|
-
|
381
|
-
jars.should eql(expected_jars)
|
425
|
+
LockJar.lock('spec/fixtures/Jarfile', local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/Jarfile.lock")
|
426
|
+
jars = LockJar.load("#{TEMP_DIR}/Jarfile.lock", ['default'], local_repo: "#{TEMP_DIR}/test-repo")
|
427
|
+
LockJar::Registry.instance.lockfile_registered?("#{TEMP_DIR}/Jarfile.lock").should be_false
|
382
428
|
|
429
|
+
expect(jars).to eql(expected_jars)
|
383
430
|
expect_java_class_loaded('org.apache.mina.core.IoUtil')
|
384
431
|
end
|
385
432
|
|
386
|
-
it
|
433
|
+
it 'by block with resolve option' do
|
387
434
|
expect_java_class_not_loaded('org.modeshape.common.math.Duration')
|
388
435
|
|
389
|
-
jars = LockJar.load(:
|
436
|
+
jars = LockJar.load(local_repo: TEST_REPO, resolve: true) do
|
390
437
|
jar 'org.modeshape:modeshape-common:3.4.0.Final'
|
391
438
|
end
|
392
439
|
|
393
|
-
jars.should eql(
|
440
|
+
jars.should eql([File.expand_path(TEST_REPO + '/org/modeshape/modeshape-common/3.4.0.Final/modeshape-common-3.4.0.Final.jar')])
|
394
441
|
|
395
442
|
expect_java_class_loaded('org.modeshape.common.math.Duration')
|
396
443
|
end
|
444
|
+
|
445
|
+
context 'with disable option' do
|
446
|
+
it 'consective calls to load should return nil' do
|
447
|
+
LockJar.load(local_repo: TEST_REPO, resolve: true, disable: true) do
|
448
|
+
jar 'org.modeshape:modeshape-common:3.4.0.Final'
|
449
|
+
end
|
450
|
+
|
451
|
+
jars = LockJar.load(local_repo: TEST_REPO, resolve: true) do
|
452
|
+
jar 'another:jar:1.2.3'
|
453
|
+
end
|
454
|
+
expect(jars).to be_empty
|
455
|
+
end
|
456
|
+
end
|
397
457
|
end
|
398
458
|
|
399
|
-
describe
|
459
|
+
describe '#extract_args' do
|
400
460
|
# Certain argument combinations can't really be tested
|
401
461
|
|
402
462
|
it 'should have the right defaults for :lockfile' do
|
403
|
-
LockJar.send(:extract_args, :lockfile, []).should
|
463
|
+
LockJar.send(:extract_args, :lockfile, []).should eq ['Jarfile.lock', ['default'], {}]
|
404
464
|
end
|
405
465
|
|
406
466
|
it 'should have the right defaults for :jarfile' do
|
407
|
-
LockJar.send(:extract_args, :jarfile, []).should
|
467
|
+
LockJar.send(:extract_args, :jarfile, []).should eq ['Jarfile', ['default'], {}]
|
408
468
|
end
|
409
469
|
|
410
470
|
it 'should not have a default filename if a block is given' do
|
411
471
|
blk = proc {}
|
412
|
-
LockJar.send(:extract_args, :jarfile, [], &blk).should
|
413
|
-
LockJar.send(:extract_args, :lockfile, [], &blk).should
|
472
|
+
LockJar.send(:extract_args, :jarfile, [], &blk).should eq [nil, ['default'], {}]
|
473
|
+
LockJar.send(:extract_args, :lockfile, [], &blk).should eq [nil, ['default'], {}]
|
414
474
|
end
|
415
475
|
|
416
476
|
it 'should use the :lockfile opt when lockfile is requested' do
|
417
|
-
LockJar.send(:extract_args, :lockfile, [{lockfile:
|
477
|
+
LockJar.send(:extract_args, :lockfile, [{ lockfile: 'LF' }]).should eq ['LF', ['default'], { lockfile: 'LF' }]
|
418
478
|
end
|
419
479
|
it 'should not use the :lockfile opt when jarfile is requested' do
|
420
|
-
LockJar.send(:extract_args, :jarfile, [{lockfile:
|
480
|
+
LockJar.send(:extract_args, :jarfile, [{ lockfile: 'LF' }]).should eq ['Jarfile', ['default'], { lockfile: 'LF' }]
|
421
481
|
end
|
422
482
|
it 'should not use the :lockfile opt when a lockfile provided' do
|
423
|
-
LockJar.send(:extract_args, :lockfile, [
|
483
|
+
LockJar.send(:extract_args, :lockfile, ['MyLF', { lockfile: 'LF' }]).should eq ['MyLF', ['default'], { lockfile: 'LF' }]
|
424
484
|
end
|
425
485
|
end
|
426
486
|
end
|