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