buildr 1.2.10 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,446 @@
|
|
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
|
+
|
17
|
+
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
18
|
+
|
19
|
+
|
20
|
+
describe 'javac compiler' do
|
21
|
+
it 'should identify itself from source directories' do
|
22
|
+
write 'src/main/java/com/example/Test.java', 'package com.example; class Test {}'
|
23
|
+
define('foo').compile.compiler.should eql(:javac)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should identify from source directories using custom layout' do
|
27
|
+
write 'src/com/example/Code.java', 'package com.example; class Code {}'
|
28
|
+
write 'testing/com/example/Test.java', 'package com.example; class Test {}'
|
29
|
+
custom = Layout.new
|
30
|
+
custom[:source, :main, :java] = 'src'
|
31
|
+
custom[:source, :test, :java] = 'testing'
|
32
|
+
define 'foo', :layout=>custom do
|
33
|
+
compile.compiler.should eql(:javac)
|
34
|
+
test.compile.compiler.should eql(:javac)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should identify from compile source directories' do
|
39
|
+
write 'src/com/example/Code.java', 'package com.example; class Code {}'
|
40
|
+
write 'testing/com/example/Test.java', 'package com.example; class Test {}'
|
41
|
+
define 'foo' do
|
42
|
+
lambda { compile.from 'src' }.should change { compile.compiler }.to(:javac)
|
43
|
+
lambda { test.compile.from 'testing' }.should change { test.compile.compiler }.to(:javac)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should report the language as :java' do
|
48
|
+
define('foo').compile.using(:javac).language.should eql(:java)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should set the target directory to target/classes' do
|
52
|
+
define 'foo' do
|
53
|
+
lambda { compile.using(:javac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should not override existing target directory' do
|
58
|
+
define 'foo' do
|
59
|
+
compile.into('classes')
|
60
|
+
lambda { compile.using(:javac) }.should_not change { compile.target }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should not change existing list of sources' do
|
65
|
+
define 'foo' do
|
66
|
+
compile.from('sources')
|
67
|
+
lambda { compile.using(:javac) }.should_not change { compile.sources }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should include classpath dependencies' do
|
72
|
+
write 'src/dependency/Dependency.java', 'class Dependency {}'
|
73
|
+
define 'dependency', :version=>'1.0' do
|
74
|
+
compile.from('src/dependency').into('target/dependency')
|
75
|
+
package(:jar)
|
76
|
+
end
|
77
|
+
write 'src/test/DependencyTest.java', 'class DependencyTest { Dependency _var; }'
|
78
|
+
define('foo').compile.from('src/test').with(project('dependency')).invoke
|
79
|
+
file('target/classes/DependencyTest.class').should exist
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should include tools.jar dependency' do
|
83
|
+
write 'src/main/java/UseApt.java', <<-JAVA
|
84
|
+
import com.sun.mirror.apt.AnnotationProcessor;
|
85
|
+
public class UseApt { }
|
86
|
+
JAVA
|
87
|
+
define('foo').compile.invoke
|
88
|
+
file('target/classes/UseApt.class').should exist
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
describe 'javac compiler options' do
|
94
|
+
def compile_task
|
95
|
+
@compile_task ||= define('foo').compile.using(:javac)
|
96
|
+
end
|
97
|
+
|
98
|
+
def javac_args
|
99
|
+
compile_task.instance_eval { @compiler }.send(:javac_args)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should set warnings option to false by default' do
|
103
|
+
compile_task.options.warnings.should be_false
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should set wranings option to true when running with --verbose option' do
|
107
|
+
verbose true
|
108
|
+
compile_task.options.warnings.should be_true
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should use -nowarn argument when warnings is false' do
|
112
|
+
compile_task.using(:warnings=>false)
|
113
|
+
javac_args.should include('-nowarn')
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should not use -nowarn argument when warnings is true' do
|
117
|
+
compile_task.using(:warnings=>true)
|
118
|
+
javac_args.should_not include('-nowarn')
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should not use -verbose argument by default' do
|
122
|
+
javac_args.should_not include('-verbose')
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should use -verbose argument when running with --trace option' do
|
126
|
+
trace true
|
127
|
+
javac_args.should include('-verbose')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should set debug option to true by default' do
|
131
|
+
compile_task.options.debug.should be_true
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should set debug option to false based on Buildr.options' do
|
135
|
+
Buildr.options.debug = false
|
136
|
+
compile_task.options.debug.should be_false
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should set debug option to false based on debug environment variable' do
|
140
|
+
ENV['debug'] = 'no'
|
141
|
+
compile_task.options.debug.should be_false
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should set debug option to false based on DEBUG environment variable' do
|
145
|
+
ENV['DEBUG'] = 'no'
|
146
|
+
compile_task.options.debug.should be_false
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should use -g argument when debug option is true' do
|
150
|
+
compile_task.using(:debug=>true)
|
151
|
+
javac_args.should include('-g')
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should not use -g argument when debug option is false' do
|
155
|
+
compile_task.using(:debug=>false)
|
156
|
+
javac_args.should_not include('-g')
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should set deprecation option to false by default' do
|
160
|
+
compile_task.options.deprecation.should be_false
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should use -deprecation argument when deprecation is true' do
|
164
|
+
compile_task.using(:deprecation=>true)
|
165
|
+
javac_args.should include('-deprecation')
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should not use -deprecation argument when deprecation is false' do
|
169
|
+
compile_task.using(:deprecation=>false)
|
170
|
+
javac_args.should_not include('-deprecation')
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should not set source option by default' do
|
174
|
+
compile_task.options.source.should be_nil
|
175
|
+
javac_args.should_not include('-source')
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should not set target option by default' do
|
179
|
+
compile_task.options.target.should be_nil
|
180
|
+
javac_args.should_not include('-target')
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should use -source nn argument if source option set' do
|
184
|
+
compile_task.using(:source=>'1.5')
|
185
|
+
javac_args.should include('-source', '1.5')
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should use -target nn argument if target option set' do
|
189
|
+
compile_task.using(:target=>'1.5')
|
190
|
+
javac_args.should include('-target', '1.5')
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should set lint option to false by default' do
|
194
|
+
compile_task.options.lint.should be_false
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should use -lint argument if lint option is true' do
|
198
|
+
compile_task.using(:lint=>true)
|
199
|
+
javac_args.should include('-Xlint')
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should use -lint argument with value of option' do
|
203
|
+
compile_task.using(:lint=>'all')
|
204
|
+
javac_args.should include('-Xlint:all')
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'should use -lint argument with value of option as array' do
|
208
|
+
compile_task.using(:lint=>['path', 'serial'])
|
209
|
+
javac_args.should include('-Xlint:path,serial')
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should not set other option by default' do
|
213
|
+
compile_task.options.other.should be_nil
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'should pass other argument if other option is string' do
|
217
|
+
compile_task.using(:other=>'-Xprint')
|
218
|
+
javac_args.should include('-Xprint')
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should pass other argument if other option is array' do
|
222
|
+
compile_task.using(:other=>['-Xstdout', 'msgs'])
|
223
|
+
javac_args.should include('-Xstdout', 'msgs')
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'should complain about options it doesn\'t know' do
|
227
|
+
write 'source/Test.java', 'class Test {}'
|
228
|
+
compile_task.using(:unknown=>'option')
|
229
|
+
lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
|
230
|
+
end
|
231
|
+
|
232
|
+
it 'should inherit options from parent' do
|
233
|
+
define 'foo' do
|
234
|
+
compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :source=>'1.5', :target=>'1.4')
|
235
|
+
define 'bar' do
|
236
|
+
compile.using(:javac)
|
237
|
+
compile.options.warnings.should be_true
|
238
|
+
compile.options.debug.should be_true
|
239
|
+
compile.options.deprecation.should be_true
|
240
|
+
compile.options.source.should eql('1.5')
|
241
|
+
compile.options.target.should eql('1.4')
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
after do
|
247
|
+
Buildr.options.debug = nil
|
248
|
+
ENV.delete "debug"
|
249
|
+
ENV.delete "DEBUG"
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
describe Project, '#javadoc' do
|
255
|
+
def sources
|
256
|
+
@sources ||= (1..3).map { |i| "Test#{i}" }.
|
257
|
+
each { |name| write "src/main/java/foo/#{name}.java", "package foo; public class #{name}{}" }.
|
258
|
+
map { |name| "src/main/java/foo/#{name}.java" }
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'should return the project\'s Javadoc task' do
|
262
|
+
define('foo') { compile.using(:javac) }
|
263
|
+
project('foo').javadoc.name.should eql('foo:javadoc')
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should return a Javadoc task' do
|
267
|
+
define('foo') { compile.using(:javac) }
|
268
|
+
project('foo').javadoc.should be_kind_of(Javadoc::JavadocTask)
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should set target directory to target/javadoc' do
|
272
|
+
define 'foo' do
|
273
|
+
compile.using(:javac)
|
274
|
+
javadoc.target.to_s.should point_to_path('target/javadoc')
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'should create file task for target directory' do
|
279
|
+
define 'foo' do
|
280
|
+
compile.using(:javac)
|
281
|
+
javadoc.should_receive(:invoke_prerequisites)
|
282
|
+
end
|
283
|
+
project('foo').file('target/javadoc').invoke
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'should respond to into() and return self' do
|
287
|
+
define 'foo' do
|
288
|
+
compile.using(:javac)
|
289
|
+
javadoc.into('docs').should be(javadoc)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'should respond to into() and change target directory' do
|
294
|
+
define 'foo' do
|
295
|
+
compile.using(:javac)
|
296
|
+
javadoc.into('docs')
|
297
|
+
javadoc.should_receive(:invoke_prerequisites)
|
298
|
+
end
|
299
|
+
file('docs').invoke
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'should respond to from() and return self' do
|
303
|
+
task = nil
|
304
|
+
define('foo') { task = javadoc.from('srcs') }
|
305
|
+
task.should be(project('foo').javadoc)
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'should respond to from() and add sources' do
|
309
|
+
define 'foo' do
|
310
|
+
compile.using(:javac)
|
311
|
+
javadoc.from('srcs').should be(javadoc)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'should respond to from() and add file task' do
|
316
|
+
define 'foo' do
|
317
|
+
compile.using(:javac)
|
318
|
+
javadoc.from('srcs').should be(javadoc)
|
319
|
+
end
|
320
|
+
project('foo').javadoc.source_files.first.should point_to_path('srcs')
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should respond to from() and add project\'s sources and dependencies' do
|
324
|
+
write 'bar/src/main/java/Test.java'
|
325
|
+
define 'foo' do
|
326
|
+
compile.using(:javac)
|
327
|
+
define('bar') { compile.using(:javac).with 'group:id:jar:1.0' }
|
328
|
+
javadoc.from project('foo:bar')
|
329
|
+
end
|
330
|
+
project('foo').javadoc.source_files.first.should point_to_path('bar/src/main/java/Test.java')
|
331
|
+
project('foo').javadoc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'should generate javadocs from project' do
|
335
|
+
sources
|
336
|
+
define('foo') { compile.using(:javac) }
|
337
|
+
project('foo').javadoc.source_files.sort.should == sources.sort.map { |f| File.expand_path(f) }
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'should include compile dependencies' do
|
341
|
+
define('foo') { compile.using(:javac).with 'group:id:jar:1.0' }
|
342
|
+
project('foo').javadoc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'should respond to include() and return self' do
|
346
|
+
define 'foo' do
|
347
|
+
compile.using(:javac)
|
348
|
+
javadoc.include('srcs').should be(javadoc)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'should respond to include() and add files' do
|
353
|
+
included = sources.first
|
354
|
+
define 'foo' do
|
355
|
+
compile.using(:javac)
|
356
|
+
javadoc.include included
|
357
|
+
end
|
358
|
+
project('foo').javadoc.source_files.should include(included)
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should respond to exclude() and return self' do
|
362
|
+
define 'foo' do
|
363
|
+
compile.using(:javac)
|
364
|
+
javadoc.exclude('srcs').should be(javadoc)
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'should respond to exclude() and ignore files' do
|
369
|
+
excluded = sources.first
|
370
|
+
define 'foo' do
|
371
|
+
compile.using(:javac)
|
372
|
+
javadoc.exclude excluded
|
373
|
+
end
|
374
|
+
sources
|
375
|
+
project('foo').javadoc.source_files.sort.should == sources[1..-1].map { |f| File.expand_path(f) }
|
376
|
+
end
|
377
|
+
|
378
|
+
it 'should respond to using() and return self' do
|
379
|
+
define 'foo' do
|
380
|
+
compile.using(:javac)
|
381
|
+
javadoc.using(:windowtitle=>'Fooing').should be(javadoc)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'should respond to using() and accept options' do
|
386
|
+
define 'foo' do
|
387
|
+
compile.using(:javac)
|
388
|
+
javadoc.using :windowtitle=>'Fooing'
|
389
|
+
end
|
390
|
+
project('foo').javadoc.options[:windowtitle].should eql('Fooing')
|
391
|
+
end
|
392
|
+
|
393
|
+
it 'should pick -windowtitle from project name' do
|
394
|
+
define 'foo' do
|
395
|
+
compile.using(:javac)
|
396
|
+
javadoc.options[:windowtitle].should eql('foo')
|
397
|
+
|
398
|
+
define 'bar' do
|
399
|
+
compile.using(:javac)
|
400
|
+
javadoc.options[:windowtitle].should eql('foo:bar')
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'should pick -windowtitle from project description' do
|
406
|
+
desc 'My App'
|
407
|
+
define 'foo' do
|
408
|
+
compile.using(:javac)
|
409
|
+
javadoc.options[:windowtitle].should eql('My App')
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
it 'should produce documentation' do
|
414
|
+
sources
|
415
|
+
define('foo') { compile.using(:javac) }
|
416
|
+
project('foo').javadoc.invoke
|
417
|
+
(1..3).map { |i| "target/javadoc/foo/Test#{i}.html" }.each { |f| file(f).should exist }
|
418
|
+
end
|
419
|
+
|
420
|
+
it 'should fail on error' do
|
421
|
+
write 'Test.java', 'class Test {}'
|
422
|
+
define 'foo' do
|
423
|
+
compile.using(:javac)
|
424
|
+
javadoc.include 'Test.java'
|
425
|
+
end
|
426
|
+
lambda { project('foo').javadoc.invoke }.should raise_error(RuntimeError, /Failed to generate Javadocs/)
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should be local task' do
|
430
|
+
define 'foo' do
|
431
|
+
define('bar') { compile.using(:javac) }
|
432
|
+
end
|
433
|
+
project('foo:bar').javadoc.should_receive(:invoke_prerequisites)
|
434
|
+
in_original_dir(project('foo:bar').base_dir) { task('javadoc').invoke }
|
435
|
+
end
|
436
|
+
|
437
|
+
it 'should not recurse' do
|
438
|
+
define 'foo' do
|
439
|
+
compile.using(:javac)
|
440
|
+
define('bar') { compile.using(:javac) }
|
441
|
+
end
|
442
|
+
project('foo:bar').javadoc.should_not_receive(:invoke_prerequisites)
|
443
|
+
project('foo').javadoc.invoke
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
@@ -0,0 +1,1042 @@
|
|
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
|
+
|
17
|
+
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
18
|
+
require File.join(File.dirname(__FILE__), 'packaging_helper')
|
19
|
+
|
20
|
+
|
21
|
+
describe Project, '#manifest' do
|
22
|
+
it 'should include user name' do
|
23
|
+
ENV['USER'] = 'MysteriousJoe'
|
24
|
+
define('foo').manifest['Build-By'].should eql('MysteriousJoe')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should include JDK version' do
|
28
|
+
define('foo').manifest['Build-Jdk'].should =~ /^1\.\d+\.\w+$/
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should include project comment' do
|
32
|
+
desc 'My Project'
|
33
|
+
define('foo').manifest['Implementation-Title'].should eql('My Project')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should include project name if no comment' do
|
37
|
+
define('foo').manifest['Implementation-Title'].should eql('foo')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should include project version' do
|
41
|
+
define('foo', :version=>'2.1').manifest['Implementation-Version'].should eql('2.1')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should not include project version unless specified' do
|
45
|
+
define('foo').manifest['Implementation-Version'].should be_nil
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should inherit from parent project' do
|
49
|
+
define('foo', :version=>'2.1') { define 'bar' }
|
50
|
+
project('foo:bar').manifest['Implementation-Version'].should eql('2.1')
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
shared_examples_for 'package with manifest' do
|
57
|
+
before do
|
58
|
+
@long_line = 'No line may be longer than 72 bytes (not characters), in its UTF8-encoded form. If a value would make the initial line longer than this, it should be continued on extra lines (each starting with a single SPACE).'
|
59
|
+
end
|
60
|
+
|
61
|
+
def package_with_manifest(manifest = nil)
|
62
|
+
packaging = @packaging
|
63
|
+
@project = define('foo', :version=>'1.2') do
|
64
|
+
package packaging
|
65
|
+
package(packaging).with(:manifest=>manifest) unless manifest.nil?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def inspect_manifest
|
70
|
+
package = project('foo').package(@packaging)
|
71
|
+
package.invoke
|
72
|
+
yield Buildr::Packaging::Java::Manifest.from_zip(package)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should include default header when no options specified' do
|
76
|
+
ENV['USER'] = 'MysteriousJoe'
|
77
|
+
package_with_manifest # Nothing for default.
|
78
|
+
inspect_manifest do |manifest|
|
79
|
+
manifest.sections.size.should be(1)
|
80
|
+
manifest.main.should == {
|
81
|
+
'Manifest-Version' =>'1.0',
|
82
|
+
'Created-By' =>'Buildr',
|
83
|
+
'Implementation-Title' =>@project.name,
|
84
|
+
'Implementation-Version' =>'1.2',
|
85
|
+
'Build-Jdk' =>ENV_JAVA['java.version'],
|
86
|
+
'Build-By' =>'MysteriousJoe'
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should not exist when manifest=false' do
|
92
|
+
package_with_manifest false
|
93
|
+
@project.package(@packaging).invoke
|
94
|
+
Zip::ZipFile.open(@project.package(@packaging).to_s) do |zip|
|
95
|
+
zip.file.exist?('META-INF/MANIFEST.MF').should be_false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should map manifest from hash' do
|
100
|
+
package_with_manifest 'Foo'=>1, :bar=>'Bar'
|
101
|
+
inspect_manifest do |manifest|
|
102
|
+
manifest.sections.size.should be(1)
|
103
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
104
|
+
manifest.main['Created-By'].should eql('Buildr')
|
105
|
+
manifest.main['Foo'].should eql('1')
|
106
|
+
manifest.main['bar'].should eql('Bar')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should end hash manifest with EOL' do
|
111
|
+
package_with_manifest 'Foo'=>1, :bar=>'Bar'
|
112
|
+
package = project('foo').package(@packaging)
|
113
|
+
package.invoke
|
114
|
+
Zip::ZipFile.open(package.to_s) { |zip| zip.file.read('META-INF/MANIFEST.MF').should =~ /#{Buildr::Packaging::Java::Manifest::LINE_SEPARATOR}$/ }
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should break hash manifest lines longer than 72 characters using continuations' do
|
118
|
+
package_with_manifest 'foo'=>@long_line
|
119
|
+
package = project('foo').package(@packaging)
|
120
|
+
inspect_manifest do |manifest|
|
121
|
+
manifest.main['foo'].should == @long_line
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should map manifest from array' do
|
126
|
+
package_with_manifest [ { :foo=>'first' }, { :bar=>'second' } ]
|
127
|
+
inspect_manifest do |manifest|
|
128
|
+
manifest.sections.size.should be(2)
|
129
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
130
|
+
manifest.main['foo'].should eql('first')
|
131
|
+
manifest.sections.last['bar'].should eql('second')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should end array manifest with EOL' do
|
136
|
+
package_with_manifest [ { :foo=>'first' }, { :bar=>'second' } ]
|
137
|
+
package = project('foo').package(@packaging)
|
138
|
+
package.invoke
|
139
|
+
Zip::ZipFile.open(package.to_s) { |zip| zip.file.read('META-INF/MANIFEST.MF')[-1].should == ?\n }
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should break array manifest lines longer than 72 characters using continuations' do
|
143
|
+
package_with_manifest ['foo'=>@long_line]
|
144
|
+
package = project('foo').package(@packaging)
|
145
|
+
inspect_manifest do |manifest|
|
146
|
+
manifest.main['foo'].should == @long_line
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should put Name: at beginning of section' do
|
151
|
+
package_with_manifest [ {}, { 'Name'=>'first', :Foo=>'first', :bar=>'second' } ]
|
152
|
+
package = project('foo').package(@packaging)
|
153
|
+
package.invoke
|
154
|
+
inspect_manifest do |manifest|
|
155
|
+
manifest.sections[1]["Name"].should == "first"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should create manifest from proc' do
|
160
|
+
package_with_manifest lambda { 'Meta: data' }
|
161
|
+
inspect_manifest do |manifest|
|
162
|
+
manifest.sections.size.should be(1)
|
163
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
164
|
+
manifest.main['Meta'].should eql('data')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should create manifest from file' do
|
169
|
+
write 'MANIFEST.MF', 'Meta: data'
|
170
|
+
package_with_manifest 'MANIFEST.MF'
|
171
|
+
inspect_manifest do |manifest|
|
172
|
+
manifest.sections.size.should be(1)
|
173
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
174
|
+
manifest.main['Meta'].should eql('data')
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should create manifest from task' do
|
179
|
+
file 'MANIFEST.MF' do |task|
|
180
|
+
write task.to_s, 'Meta: data'
|
181
|
+
end
|
182
|
+
package_with_manifest 'MANIFEST.MF'
|
183
|
+
inspect_manifest do |manifest|
|
184
|
+
manifest.sections.size.should be(1)
|
185
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
186
|
+
manifest.main['Meta'].should eql('data')
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should respond to with() and accept manifest' do
|
191
|
+
write 'DISCLAIMER'
|
192
|
+
mkpath 'target/classes'
|
193
|
+
packaging = @packaging
|
194
|
+
define('foo', :version=>'1.0') { package(packaging).with :manifest=>{'Foo'=>'data'} }
|
195
|
+
inspect_manifest { |manifest| manifest.main['Foo'].should eql('data') }
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should include META-INF directory' do
|
199
|
+
packaging = @packaging
|
200
|
+
package = define('foo', :version=>'1.0') { package(packaging) }.packages.first
|
201
|
+
package.invoke
|
202
|
+
Zip::ZipFile.open(package.to_s) do |zip|
|
203
|
+
zip.entries.map(&:to_s).should include('META-INF/')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
describe Project, '#meta_inf' do
|
210
|
+
it 'should by an array' do
|
211
|
+
define('foo').meta_inf.should be_kind_of(Array)
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should include LICENSE file if found' do
|
215
|
+
write 'LICENSE'
|
216
|
+
define('foo').meta_inf.first.should point_to_path('LICENSE')
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should be empty unless LICENSE exists' do
|
220
|
+
define('foo').meta_inf.should be_empty
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should inherit from parent project' do
|
224
|
+
write 'LICENSE'
|
225
|
+
define('foo') { define 'bar' }
|
226
|
+
project('foo:bar').meta_inf.first.should point_to_path('LICENSE')
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should expect LICENSE file parent project' do
|
230
|
+
write 'bar/LICENSE'
|
231
|
+
define('foo') { define 'bar' }
|
232
|
+
project('foo:bar').meta_inf.should be_empty
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
describe 'package with meta_inf', :shared=>true do
|
238
|
+
|
239
|
+
def package_with_meta_inf(meta_inf = nil)
|
240
|
+
packaging = @packaging
|
241
|
+
@project = Buildr.define('foo', :version=>'1.2') do
|
242
|
+
package packaging
|
243
|
+
package(packaging).with(:meta_inf=>meta_inf) if meta_inf
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def inspect_meta_inf
|
248
|
+
package = project('foo').package(@packaging)
|
249
|
+
package.invoke
|
250
|
+
assumed = Array(@meta_inf_ignore)
|
251
|
+
Zip::ZipFile.open(package.to_s) do |zip|
|
252
|
+
entries = zip.entries.map(&:to_s).select { |f| File.dirname(f) == 'META-INF' }.map { |f| File.basename(f) }
|
253
|
+
assumed.each { |f| entries.should include(f) }
|
254
|
+
yield entries - assumed if block_given?
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'should default to LICENSE file' do
|
259
|
+
write 'LICENSE'
|
260
|
+
package_with_meta_inf
|
261
|
+
inspect_meta_inf { |files| files.should eql(['LICENSE']) }
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'should be empty if no LICENSE file' do
|
265
|
+
package_with_meta_inf
|
266
|
+
inspect_meta_inf { |files| files.should be_empty }
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'should include file specified by :meta_inf option' do
|
270
|
+
write 'README'
|
271
|
+
package_with_meta_inf 'README'
|
272
|
+
inspect_meta_inf { |files| files.should eql(['README']) }
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'should include files specified by :meta_inf option' do
|
276
|
+
files = ['README', 'DISCLAIMER'].each { |file| write file }
|
277
|
+
package_with_meta_inf files
|
278
|
+
inspect_meta_inf { |files| files.should eql(files) }
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'should include file task specified by :meta_inf option' do
|
282
|
+
file('README') { |task| write task.to_s }
|
283
|
+
package_with_meta_inf file('README')
|
284
|
+
inspect_meta_inf { |files| files.should eql(['README']) }
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should include file tasks specified by :meta_inf option' do
|
288
|
+
files = ['README', 'DISCLAIMER'].each { |file| file(file) { |task| write task.to_s } }
|
289
|
+
package_with_meta_inf files.map { |f| file(f) }
|
290
|
+
inspect_meta_inf { |files| files.should eql(files) }
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'should complain if cannot find file' do
|
294
|
+
package_with_meta_inf 'README'
|
295
|
+
lambda { inspect_meta_inf }.should raise_error(RuntimeError, /README/)
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should complain if cannot build task' do
|
299
|
+
file('README') { fail 'Failed' }
|
300
|
+
package_with_meta_inf 'README'
|
301
|
+
lambda { inspect_meta_inf }.should raise_error(RuntimeError, /Failed/)
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should respond to with() and accept manifest and meta_inf' do
|
305
|
+
write 'DISCLAIMER'
|
306
|
+
mkpath 'target/classes'
|
307
|
+
packaging = @packaging
|
308
|
+
define('foo', :version=>'1.0') { package(packaging).with :meta_inf=>'DISCLAIMER' }
|
309
|
+
inspect_meta_inf { |files| files.should eql(['DISCLAIMER']) }
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
|
314
|
+
describe Packaging, 'jar' do
|
315
|
+
it_should_behave_like 'packaging'
|
316
|
+
before { @packaging = :jar }
|
317
|
+
it_should_behave_like 'package with manifest'
|
318
|
+
it_should_behave_like 'package with meta_inf'
|
319
|
+
before { @meta_inf_ignore = 'MANIFEST.MF' }
|
320
|
+
|
321
|
+
it 'should use files from compile directory if nothing included' do
|
322
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
323
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
324
|
+
project('foo').package(:jar).invoke
|
325
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
326
|
+
jar.entries.map(&:to_s).sort.should include('META-INF/MANIFEST.MF', 'Test.class')
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should use files from resources directory if nothing included' do
|
331
|
+
write 'src/main/resources/test/important.properties'
|
332
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
333
|
+
project('foo').package(:jar).invoke
|
334
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
335
|
+
jar.entries.map(&:to_s).sort.should include('test/important.properties')
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
it 'should include class directories' do
|
340
|
+
write 'src/main/java/code/Test.java', 'package code ; class Test {}'
|
341
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
342
|
+
project('foo').package(:jar).invoke
|
343
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
344
|
+
jar.entries.map(&:to_s).sort.should include('code/')
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'should include resource files starting with dot' do
|
349
|
+
write 'src/main/resources/test/.config'
|
350
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
351
|
+
project('foo').package(:jar).invoke
|
352
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
353
|
+
jar.entries.map(&:to_s).sort.should include('test/.config')
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
it 'should include empty resource directories' do
|
358
|
+
mkpath 'src/main/resources/empty'
|
359
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
360
|
+
project('foo').package(:jar).invoke
|
361
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
362
|
+
jar.entries.map(&:to_s).sort.should include('empty/')
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
|
368
|
+
describe Packaging, 'war' do
|
369
|
+
it_should_behave_like 'packaging'
|
370
|
+
before { @packaging = :war }
|
371
|
+
it_should_behave_like 'package with manifest'
|
372
|
+
it_should_behave_like 'package with meta_inf'
|
373
|
+
before { @meta_inf_ignore = 'MANIFEST.MF' }
|
374
|
+
|
375
|
+
def make_jars
|
376
|
+
artifact('group:id:jar:1.0') { |t| write t.to_s }
|
377
|
+
artifact('group:id:jar:2.0') { |t| write t.to_s }
|
378
|
+
end
|
379
|
+
|
380
|
+
def inspect_war
|
381
|
+
project('foo').package(:war).invoke
|
382
|
+
Zip::ZipFile.open(project('foo').package(:war).to_s) do |war|
|
383
|
+
yield war.entries.map(&:to_s).sort
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
it 'should use files from webapp directory if nothing included' do
|
388
|
+
write 'src/main/webapp/test.html'
|
389
|
+
define('foo', :version=>'1.0') { package(:war) }
|
390
|
+
inspect_war { |files| files.should include('test.html') }
|
391
|
+
end
|
392
|
+
|
393
|
+
it 'should accept files from :classes option' do
|
394
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
395
|
+
write 'classes/test'
|
396
|
+
define('foo', :version=>'1.0') { package(:war).with(:classes=>'classes') }
|
397
|
+
inspect_war { |files| files.should include('WEB-INF/classes/test') }
|
398
|
+
end
|
399
|
+
|
400
|
+
it 'should use files from compile directory if nothing included' do
|
401
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
402
|
+
define('foo', :version=>'1.0') { package(:war) }
|
403
|
+
inspect_war { |files| files.should include('WEB-INF/classes/Test.class') }
|
404
|
+
end
|
405
|
+
|
406
|
+
it 'should ignore compile directory if no source files to compile' do
|
407
|
+
define('foo', :version=>'1.0') { package(:war) }
|
408
|
+
inspect_war { |files| files.should_not include('target/classes') }
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'should include only specified classes directories' do
|
412
|
+
write 'src/main/java'
|
413
|
+
define('foo', :version=>'1.0') { package(:war).with :classes=>_('additional') }
|
414
|
+
project('foo').package(:war).classes.should_not include(project('foo').file('target/classes'))
|
415
|
+
project('foo').package(:war).classes.should include(project('foo').file('additional'))
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'should use files from resources directory if nothing included' do
|
419
|
+
write 'src/main/resources/test/important.properties'
|
420
|
+
define('foo', :version=>'1.0') { package(:war) }
|
421
|
+
inspect_war { |files| files.should include('WEB-INF/classes/test/important.properties') }
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'should include empty resource directories' do
|
425
|
+
mkpath 'src/main/resources/empty'
|
426
|
+
define('foo', :version=>'1.0') { package(:war) }
|
427
|
+
inspect_war { |files| files.should include('WEB-INF/classes/empty/') }
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should accept file from :libs option' do
|
431
|
+
make_jars
|
432
|
+
define('foo', :version=>'1.0') { package(:war).with(:libs=>'group:id:jar:1.0') }
|
433
|
+
inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar') }
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'should accept file from :libs option' do
|
437
|
+
make_jars
|
438
|
+
define('foo', :version=>'1.0') { package(:war).with(:libs=>['group:id:jar:1.0', 'group:id:jar:2.0']) }
|
439
|
+
inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar', 'WEB-INF/lib/id-2.0.jar') }
|
440
|
+
end
|
441
|
+
|
442
|
+
it 'should use artifacts from compile classpath if no libs specified' do
|
443
|
+
make_jars
|
444
|
+
define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war) }
|
445
|
+
inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar', 'WEB-INF/lib/id-2.0.jar') }
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'should include only specified libraries' do
|
449
|
+
define 'foo', :version=>'1.0' do
|
450
|
+
compile.with 'group:id:jar:1.0'
|
451
|
+
package(:war).with :libs=>'additional:id:jar:1.0'
|
452
|
+
end
|
453
|
+
project('foo').package(:war).libs.should_not include(artifact('group:id:jar:1.0'))
|
454
|
+
project('foo').package(:war).libs.should include(artifact('additional:id:jar:1.0'))
|
455
|
+
end
|
456
|
+
|
457
|
+
end
|
458
|
+
|
459
|
+
|
460
|
+
describe Packaging, 'aar' do
|
461
|
+
it_should_behave_like 'packaging'
|
462
|
+
before { @packaging = :aar }
|
463
|
+
it_should_behave_like 'package with manifest'
|
464
|
+
it_should_behave_like 'package with meta_inf'
|
465
|
+
before do
|
466
|
+
write 'src/main/axis2/services.xml'
|
467
|
+
@meta_inf_ignore = ['MANIFEST.MF', 'services.xml']
|
468
|
+
end
|
469
|
+
|
470
|
+
def make_jars
|
471
|
+
artifact('group:id:jar:1.0') { |t| write t.to_s }
|
472
|
+
artifact('group:id:jar:2.0') { |t| write t.to_s }
|
473
|
+
end
|
474
|
+
|
475
|
+
def inspect_aar
|
476
|
+
project('foo').package(:aar).invoke
|
477
|
+
Zip::ZipFile.open(project('foo').package(:aar).to_s) do |aar|
|
478
|
+
yield aar.entries.map(&:to_s).sort
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
it 'should automatically include services.xml and any *.wsdl files under src/main/axis2' do
|
483
|
+
write 'src/main/axis2/my-service.wsdl'
|
484
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
485
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'META-INF/services.xml', 'META-INF/my-service.wsdl') }
|
486
|
+
end
|
487
|
+
|
488
|
+
it 'should accept files from :include option' do
|
489
|
+
write 'test'
|
490
|
+
define('foo', :version=>'1.0') { package(:aar).include 'test' }
|
491
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'test') }
|
492
|
+
end
|
493
|
+
|
494
|
+
it 'should use files from compile directory if nothing included' do
|
495
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
496
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
497
|
+
inspect_aar { |files| files.should include('Test.class') }
|
498
|
+
end
|
499
|
+
|
500
|
+
it 'should use files from resources directory if nothing included' do
|
501
|
+
write 'src/main/resources/test/important.properties'
|
502
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
503
|
+
inspect_aar { |files| files.should include('test/important.properties') }
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'should include empty resource directories' do
|
507
|
+
mkpath 'src/main/resources/empty'
|
508
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
509
|
+
inspect_aar { |files| files.should include('empty/') }
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'should accept file from :libs option' do
|
513
|
+
make_jars
|
514
|
+
define('foo', :version=>'1.0') { package(:aar).with :libs=>'group:id:jar:1.0' }
|
515
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'lib/id-1.0.jar') }
|
516
|
+
end
|
517
|
+
|
518
|
+
it 'should accept file from :libs option' do
|
519
|
+
make_jars
|
520
|
+
define('foo', :version=>'1.0') { package(:aar).with :libs=>['group:id:jar:1.0', 'group:id:jar:2.0'] }
|
521
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'lib/id-1.0.jar', 'lib/id-2.0.jar') }
|
522
|
+
end
|
523
|
+
|
524
|
+
it 'should NOT use artifacts from compile classpath if no libs specified' do
|
525
|
+
make_jars
|
526
|
+
define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:aar) }
|
527
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF') }
|
528
|
+
end
|
529
|
+
|
530
|
+
it 'should return all libraries from libs attribute' do
|
531
|
+
define 'foo', :version=>'1.0' do
|
532
|
+
compile.with 'group:id:jar:1.0'
|
533
|
+
package(:aar).with :libs=>'additional:id:jar:1.0'
|
534
|
+
end
|
535
|
+
project('foo').package(:aar).libs.should_not include(artifact('group:id:jar:1.0'))
|
536
|
+
project('foo').package(:aar).libs.should include(artifact('additional:id:jar:1.0'))
|
537
|
+
end
|
538
|
+
|
539
|
+
end
|
540
|
+
|
541
|
+
|
542
|
+
describe Packaging, 'ear' do
|
543
|
+
it_should_behave_like 'packaging'
|
544
|
+
before { @packaging = :ear }
|
545
|
+
it_should_behave_like 'package with manifest'
|
546
|
+
it_should_behave_like 'package with meta_inf'
|
547
|
+
before { @meta_inf_ignore = ['MANIFEST.MF', 'application.xml'] }
|
548
|
+
|
549
|
+
def inspect_ear
|
550
|
+
project('foo').package(:ear).invoke
|
551
|
+
Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
|
552
|
+
yield ear.entries.map(&:to_s).sort
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
def inspect_application_xml
|
557
|
+
project('foo').package(:ear).invoke
|
558
|
+
Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
|
559
|
+
yield REXML::Document.new(ear.read('META-INF/application.xml')).root
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
def inspect_classpath(package)
|
564
|
+
project('foo').package(:ear).invoke
|
565
|
+
Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
|
566
|
+
File.open('tmp.zip', 'wb') do |tmp|
|
567
|
+
tmp.write ear.file.read(package)
|
568
|
+
end
|
569
|
+
manifest = Buildr::Packaging::Java::Manifest.from_zip('tmp.zip')
|
570
|
+
yield manifest.main['Class-Path'].to_s.split(' ')
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
it 'should set display name from project id' do
|
575
|
+
define 'foo', :version=>'1.0' do
|
576
|
+
package(:ear).display_name.should eql('foo')
|
577
|
+
define 'bar' do
|
578
|
+
package(:ear).display_name.should eql('foo-bar')
|
579
|
+
end
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
it 'should set display name in application.xml' do
|
584
|
+
define 'foo', :version=>'1.0' do
|
585
|
+
package(:ear)
|
586
|
+
end
|
587
|
+
inspect_application_xml { |xml| xml.get_text('/application/display-name').should == 'foo' }
|
588
|
+
end
|
589
|
+
|
590
|
+
it 'should accept different display name' do
|
591
|
+
define 'foo', :version=>'1.0' do
|
592
|
+
package(:ear).display_name = 'bar'
|
593
|
+
end
|
594
|
+
inspect_application_xml { |xml| xml.get_text('/application/display-name').should == 'bar' }
|
595
|
+
end
|
596
|
+
|
597
|
+
it 'should map WARs to /war directory' do
|
598
|
+
define 'foo', :version=>'1.0' do
|
599
|
+
package(:ear) << package(:war)
|
600
|
+
end
|
601
|
+
inspect_ear { |files| files.should include('war/foo-1.0.war') }
|
602
|
+
end
|
603
|
+
|
604
|
+
it 'should map EJBs to /ejb directory' do
|
605
|
+
define 'foo', :version=>'1.0' do
|
606
|
+
package(:ear).add :ejb=>package(:jar)
|
607
|
+
end
|
608
|
+
inspect_ear { |files| files.should include('ejb/foo-1.0.jar') }
|
609
|
+
end
|
610
|
+
|
611
|
+
it 'should not modify original artifact for its components' do
|
612
|
+
define 'one', :version => '1.0' do
|
613
|
+
write 'src/main/resources/one.txt', '1'
|
614
|
+
package(:jar)
|
615
|
+
end
|
616
|
+
|
617
|
+
define 'two', :version => '1.0' do
|
618
|
+
write 'src/main/resources/two.txt', '2'
|
619
|
+
package(:jar)
|
620
|
+
end
|
621
|
+
|
622
|
+
define 'foo', :version => '1.0' do
|
623
|
+
package(:ear).add project(:one).package(:jar)
|
624
|
+
package(:ear).add :ejb => project(:two).package(:jar)
|
625
|
+
end
|
626
|
+
|
627
|
+
inspect_ear { |files| files.should include('lib/one-1.0.jar', 'ejb/two-1.0.jar') }
|
628
|
+
|
629
|
+
Buildr::Packaging::Java::Manifest.from_zip(project('one').package(:jar)).main['Class-Path'].should be_nil
|
630
|
+
Buildr::Packaging::Java::Manifest.from_zip(project('two').package(:jar)).main['Class-Path'].should be_nil
|
631
|
+
|
632
|
+
inspect_classpath 'ejb/two-1.0.jar' do |classpath|
|
633
|
+
classpath.should include('../lib/one-1.0.jar')
|
634
|
+
end
|
635
|
+
end
|
636
|
+
|
637
|
+
it 'should map JARs to /lib directory' do
|
638
|
+
define 'foo', :version=>'1.0' do
|
639
|
+
package(:ear) << package(:jar)
|
640
|
+
end
|
641
|
+
inspect_ear { |files| files.should include('lib/foo-1.0.jar') }
|
642
|
+
end
|
643
|
+
|
644
|
+
it 'should accept component type with :type option' do
|
645
|
+
define 'foo', :version=>'1.0' do
|
646
|
+
package(:ear).add package(:jar), :type=>:ejb
|
647
|
+
end
|
648
|
+
inspect_ear { |files| files.should include('ejb/foo-1.0.jar') }
|
649
|
+
end
|
650
|
+
|
651
|
+
it 'should accept component and its type as type=>artiract' do
|
652
|
+
define 'foo', :version=>'1.0' do
|
653
|
+
package(:ear).add :ejb=>package(:jar)
|
654
|
+
end
|
655
|
+
inspect_ear { |files| files.should include('ejb/foo-1.0.jar') }
|
656
|
+
end
|
657
|
+
|
658
|
+
it 'should map typed JARs to /jar directory' do
|
659
|
+
define 'foo', :version=>'1.0' do
|
660
|
+
package(:ear).add :jar=>package(:jar)
|
661
|
+
end
|
662
|
+
inspect_ear { |files| files.should include('jar/foo-1.0.jar') }
|
663
|
+
end
|
664
|
+
|
665
|
+
it 'should add multiple components at a time using the type=>component style' do
|
666
|
+
define 'bar', :version => '1.5' do
|
667
|
+
package(:war) # must be added as a webapp
|
668
|
+
package(:jar) # must be added as a shared lib
|
669
|
+
package(:zip) # this one should be excluded
|
670
|
+
end
|
671
|
+
define 'baz', :version => '1.5' do
|
672
|
+
package(:jar, :id => 'one')
|
673
|
+
package(:jar, :id => 'two')
|
674
|
+
end
|
675
|
+
define 'foo', :version => '1.0' do
|
676
|
+
package(:ear).add :lib => project('baz'),
|
677
|
+
:war => project('bar').package(:war),
|
678
|
+
:ejb => project('bar').package(:jar)
|
679
|
+
end
|
680
|
+
inspect_ear do |files|
|
681
|
+
files.should include(*%w{ lib/one-1.5.jar lib/two-1.5.jar war/bar-1.5.war ejb/bar-1.5.jar })
|
682
|
+
files.should_not satisfy { files.any? { |f| f =~ /\.zip$/ } }
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
686
|
+
it 'should add all EAR supported packages when given a project argument' do
|
687
|
+
define 'bar', :version => '1.5' do
|
688
|
+
package(:war) # must be added as a webapp
|
689
|
+
package(:jar) # must be added as a shared lib
|
690
|
+
package(:zip) # this one should be excluded
|
691
|
+
end
|
692
|
+
define 'baz', :version => '1.5' do
|
693
|
+
package(:war)
|
694
|
+
package(:jar)
|
695
|
+
end
|
696
|
+
define 'foo', :version => '1.0' do
|
697
|
+
package(:ear).add projects(:bar, :baz)
|
698
|
+
end
|
699
|
+
inspect_ear do |files|
|
700
|
+
files.should include('war/bar-1.5.war', 'lib/bar-1.5.jar', 'lib/baz-1.5.jar', 'war/baz-1.5.war')
|
701
|
+
files.should_not satisfy { files.any? { |f| f =~ /\.zip$/ } }
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
it 'should complain about unknown component type' do
|
706
|
+
define 'foo', :version=>'1.0' do
|
707
|
+
lambda { package(:ear).add package(:zip) }.should raise_error(RuntimeError, /ear component/i)
|
708
|
+
end
|
709
|
+
end
|
710
|
+
|
711
|
+
it 'should allow unknown component types with explicit type' do
|
712
|
+
define 'foo', :version=>'1.0' do
|
713
|
+
package(:ear).add :lib=>package(:zip)
|
714
|
+
end
|
715
|
+
inspect_ear { |files| files.should include('lib/foo-1.0.zip') }
|
716
|
+
end
|
717
|
+
|
718
|
+
it 'should accept alternative directory name' do
|
719
|
+
define 'foo', :version=>'1.0' do
|
720
|
+
package(:ear).add package(:jar), :path=>'trash'
|
721
|
+
end
|
722
|
+
inspect_ear { |files| files.should include('trash/foo-1.0.jar') }
|
723
|
+
end
|
724
|
+
|
725
|
+
it 'should accept customization of directory map' do
|
726
|
+
define 'foo', :version=>'1.0' do
|
727
|
+
package(:ear).dirs[:jar] = 'jarred'
|
728
|
+
package(:ear).add :jar=>package(:jar)
|
729
|
+
end
|
730
|
+
inspect_ear { |files| files.should include('jarred/foo-1.0.jar') }
|
731
|
+
end
|
732
|
+
|
733
|
+
it 'should accept customization of directory map with nil paths in application.xml' do
|
734
|
+
define 'foo', :version=>'1.0' do
|
735
|
+
package(:ear).dirs[:war] = nil
|
736
|
+
package(:ear).add :war=>package(:war)
|
737
|
+
package(:ear).add package(:jar)
|
738
|
+
end
|
739
|
+
inspect_ear { |files| files.should include('foo-1.0.war') }
|
740
|
+
inspect_application_xml do |xml|
|
741
|
+
xml.get_text("/application/module[@id='foo']/web/web-uri").to_s.should eql('foo-1.0.war')
|
742
|
+
end
|
743
|
+
end
|
744
|
+
|
745
|
+
it 'should accept customization of directory map with nil paths in the classpath' do
|
746
|
+
define 'foo', :version=>'1.0' do
|
747
|
+
package(:ear).dirs[:lib] = nil
|
748
|
+
package(:ear).add :war=>package(:war)
|
749
|
+
package(:ear) << package(:jar)
|
750
|
+
end
|
751
|
+
inspect_classpath 'war/foo-1.0.war' do |classpath|
|
752
|
+
classpath.should include('../foo-1.0.jar')
|
753
|
+
end
|
754
|
+
end
|
755
|
+
|
756
|
+
it 'should list WAR components in application.xml' do
|
757
|
+
define 'foo', :version=>'1.0' do
|
758
|
+
package(:ear) << package(:war) << package(:war, :id=>'bar')
|
759
|
+
end
|
760
|
+
inspect_application_xml do |xml|
|
761
|
+
xml.get_elements("/application/module[@id='foo'][web]").should_not be_empty
|
762
|
+
xml.get_elements("/application/module[@id='bar'][web]").should_not be_empty
|
763
|
+
end
|
764
|
+
end
|
765
|
+
|
766
|
+
it 'should specify web-uri for WAR components in application.xml' do
|
767
|
+
define 'foo', :version=>'1.0' do
|
768
|
+
package(:ear) << package(:war)
|
769
|
+
package(:ear).add package(:war, :id=>'bar'), :path=>'ws'
|
770
|
+
end
|
771
|
+
inspect_application_xml do |xml|
|
772
|
+
xml.get_text("/application/module[@id='foo']/web/web-uri").to_s.should eql('war/foo-1.0.war')
|
773
|
+
xml.get_text("/application/module[@id='bar']/web/web-uri").to_s.should eql('ws/bar-1.0.war')
|
774
|
+
end
|
775
|
+
end
|
776
|
+
|
777
|
+
it 'should specify context-root for WAR components in application.xml' do
|
778
|
+
define 'foo', :version=>'1.0' do
|
779
|
+
package(:ear) << package(:war)
|
780
|
+
package(:ear).add package(:war, :id=>'bar')
|
781
|
+
end
|
782
|
+
inspect_application_xml do |xml|
|
783
|
+
xml.get_text("/application/module[@id='foo']/web/context-root").to_s.should eql('/foo')
|
784
|
+
xml.get_text("/application/module[@id='bar']/web/context-root").to_s.should eql('/bar')
|
785
|
+
end
|
786
|
+
end
|
787
|
+
|
788
|
+
it 'should accept context-root for WAR components in application.xml' do
|
789
|
+
define 'foo', :version=>'1.0' do
|
790
|
+
package(:ear).add package(:war), :context_root=>'rooted'
|
791
|
+
end
|
792
|
+
inspect_application_xml do |xml|
|
793
|
+
xml.get_text("/application/module[@id='foo']/web/context-root").to_s.should eql('/rooted')
|
794
|
+
end
|
795
|
+
end
|
796
|
+
|
797
|
+
it 'should allow disabling the context root' do
|
798
|
+
define 'foo', :version=>'1.0' do
|
799
|
+
package(:ear).add package(:war), :context_root=>false
|
800
|
+
end
|
801
|
+
inspect_application_xml do |xml|
|
802
|
+
xml.get_elements("/application/module[@id='foo']/web/context-root").should be_empty
|
803
|
+
end
|
804
|
+
end
|
805
|
+
|
806
|
+
it 'should list EJB components in application.xml' do
|
807
|
+
define 'foo', :version=>'1.0' do
|
808
|
+
package(:ear).add :ejb=>package(:jar)
|
809
|
+
package(:ear).add :ejb=>package(:jar, :id=>'bar')
|
810
|
+
end
|
811
|
+
inspect_application_xml do |xml|
|
812
|
+
xml.get_text("/application/module[@id='foo']/ejb").to_s.should eql('ejb/foo-1.0.jar')
|
813
|
+
xml.get_text("/application/module[@id='bar']/ejb").to_s.should eql('ejb/bar-1.0.jar')
|
814
|
+
end
|
815
|
+
end
|
816
|
+
|
817
|
+
it 'should list JAR components in application.xml' do
|
818
|
+
define 'foo', :version=>'1.0' do
|
819
|
+
package(:ear) << { :jar=>package(:jar) } << { :jar=>package(:jar, :id=>'bar') }
|
820
|
+
end
|
821
|
+
inspect_application_xml do |xml|
|
822
|
+
jars = xml.get_elements('/application/jar').map(&:texts).map(&:to_s)
|
823
|
+
jars.should include('jar/foo-1.0.jar', 'jar/bar-1.0.jar')
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
it 'should update WAR component classpath to include libraries' do
|
828
|
+
define 'foo', :version=>'1.0' do
|
829
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
830
|
+
package(:ear).add package(:war)
|
831
|
+
end
|
832
|
+
inspect_classpath 'war/foo-1.0.war' do |classpath|
|
833
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
837
|
+
it 'should update WAR component classpath but skip internal libraries' do
|
838
|
+
define 'foo', :version=>'1.0' do
|
839
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
840
|
+
package(:war).with(:libs=>package(:jar, :id=>'lib1'))
|
841
|
+
package(:ear).add package(:war)
|
842
|
+
end
|
843
|
+
inspect_classpath 'war/foo-1.0.war' do |classpath|
|
844
|
+
classpath.should_not include('../lib/lib1-1.0.jar')
|
845
|
+
classpath.should include('../lib/lib2-1.0.jar')
|
846
|
+
end
|
847
|
+
end
|
848
|
+
|
849
|
+
it 'should update EJB component classpath to include libraries' do
|
850
|
+
define 'foo', :version=>'1.0' do
|
851
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
852
|
+
package(:ear).add :ejb=>package(:jar)
|
853
|
+
end
|
854
|
+
inspect_classpath 'ejb/foo-1.0.jar' do |classpath|
|
855
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
856
|
+
end
|
857
|
+
end
|
858
|
+
|
859
|
+
it 'should update JAR component classpath to include libraries' do
|
860
|
+
define 'foo', :version=>'1.0' do
|
861
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
862
|
+
package(:ear).add :jar=>package(:jar)
|
863
|
+
end
|
864
|
+
inspect_classpath 'jar/foo-1.0.jar' do |classpath|
|
865
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
it 'should deal with very long classpaths' do
|
870
|
+
define 'foo', :version=>'1.0' do
|
871
|
+
20.times { |i| package(:ear) << package(:jar, :id=>"lib#{i}") }
|
872
|
+
package(:ear).add :jar=>package(:jar)
|
873
|
+
end
|
874
|
+
inspect_classpath 'jar/foo-1.0.jar' do |classpath|
|
875
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
876
|
+
end
|
877
|
+
end
|
878
|
+
|
879
|
+
|
880
|
+
it 'should generate relative classpaths for top level EJB' do
|
881
|
+
define 'foo', :version => '1.0' do
|
882
|
+
package(:ear).add package(:jar, :id => 'one'), :path => '.'
|
883
|
+
package(:ear).add package(:jar, :id => 'two'), :path => 'dos'
|
884
|
+
package(:ear).add package(:jar, :id => 'three'), :path => 'tres'
|
885
|
+
package(:ear).add :ejb => package(:jar, :id => 'ejb1'), :path => '.'
|
886
|
+
end
|
887
|
+
inspect_classpath 'ejb1-1.0.jar' do |classpath|
|
888
|
+
classpath.should include(*%w{ one-1.0.jar dos/two-1.0.jar tres/three-1.0.jar })
|
889
|
+
end
|
890
|
+
end
|
891
|
+
|
892
|
+
it 'should generate relative classpaths for second level EJB' do
|
893
|
+
define 'foo', :version => '1.0' do
|
894
|
+
package(:ear).add package(:jar, :id => 'one'), :path => '.'
|
895
|
+
package(:ear).add package(:jar, :id => 'two'), :path => 'dos'
|
896
|
+
package(:ear).add package(:jar, :id => 'three'), :path => 'tres'
|
897
|
+
package(:ear).add :ejb => package(:jar, :id => 'ejb2'), :path => 'dos'
|
898
|
+
end
|
899
|
+
inspect_classpath 'dos/ejb2-1.0.jar' do |classpath|
|
900
|
+
classpath.should include(*%w{ ../one-1.0.jar two-1.0.jar ../tres/three-1.0.jar })
|
901
|
+
end
|
902
|
+
end
|
903
|
+
|
904
|
+
it 'should generate relative classpaths for nested EJB' do
|
905
|
+
define 'foo', :version => '1.0' do
|
906
|
+
package(:ear).add package(:jar, :id => 'one'), :path => '.'
|
907
|
+
package(:ear).add package(:jar, :id => 'two'), :path => 'dos'
|
908
|
+
package(:ear).add package(:jar, :id => 'three'), :path => 'dos/tres'
|
909
|
+
package(:ear).add package(:jar, :id => 'four'), :path => 'dos/cuatro'
|
910
|
+
package(:ear).add :ejb => package(:jar, :id => 'ejb4'), :path => 'dos/cuatro'
|
911
|
+
end
|
912
|
+
inspect_classpath 'dos/cuatro/ejb4-1.0.jar' do |classpath|
|
913
|
+
classpath.should include(*%w{ ../../one-1.0.jar ../two-1.0.jar ../tres/three-1.0.jar four-1.0.jar })
|
914
|
+
end
|
915
|
+
end
|
916
|
+
|
917
|
+
end
|
918
|
+
|
919
|
+
|
920
|
+
describe Packaging, 'sources' do
|
921
|
+
it_should_behave_like 'packaging'
|
922
|
+
before { @packaging, @package_type = :sources, :zip }
|
923
|
+
|
924
|
+
it 'should create package of type :zip and classifier \'sources\'' do
|
925
|
+
define 'foo', :version=>'1.0' do
|
926
|
+
package(:sources).type.should eql(:zip)
|
927
|
+
package(:sources).classifier.should eql('sources')
|
928
|
+
package(:sources).name.should match(/foo-1.0-sources.zip$/)
|
929
|
+
end
|
930
|
+
end
|
931
|
+
|
932
|
+
it 'should contain source files' do
|
933
|
+
write 'src/main/java/Source.java'
|
934
|
+
define('foo', :version=>'1.0') { package(:sources) }
|
935
|
+
project('foo').task('package').invoke
|
936
|
+
project('foo').packages.first.should contain('Source.java')
|
937
|
+
end
|
938
|
+
|
939
|
+
it 'should be a ZipTask' do
|
940
|
+
define 'foo', :version=>'1.0' do
|
941
|
+
package(:javadoc).should be_kind_of(ZipTask)
|
942
|
+
end
|
943
|
+
end
|
944
|
+
end
|
945
|
+
|
946
|
+
|
947
|
+
describe Packaging, 'javadoc' do
|
948
|
+
it_should_behave_like 'packaging'
|
949
|
+
before { @packaging, @package_type = :javadoc, :zip }
|
950
|
+
|
951
|
+
it 'should create package of type :zip and classifier \'javadoc\'' do
|
952
|
+
define 'foo', :version=>'1.0' do
|
953
|
+
package(:javadoc).type.should eql(:zip)
|
954
|
+
package(:javadoc).classifier.should eql('javadoc')
|
955
|
+
package(:javadoc).name.pathmap('%f').should eql('foo-1.0-javadoc.zip')
|
956
|
+
end
|
957
|
+
end
|
958
|
+
|
959
|
+
it 'should contain Javadocs' do
|
960
|
+
write 'src/main/java/Source.java', 'public class Source {}'
|
961
|
+
define('foo', :version=>'1.0') { package(:javadoc) }
|
962
|
+
project('foo').task('package').invoke
|
963
|
+
project('foo').packages.first.should contain('Source.html', 'index.html')
|
964
|
+
end
|
965
|
+
|
966
|
+
it 'should use project description in window title' do
|
967
|
+
write 'src/main/java/Source.java', 'public class Source {}'
|
968
|
+
desc 'My Project'
|
969
|
+
define('foo', :version=>'1.0') { package(:javadoc) }
|
970
|
+
project('foo').task('package').invoke
|
971
|
+
project('foo').packages.first.entry('index.html').should contain('My Project')
|
972
|
+
end
|
973
|
+
|
974
|
+
it 'should be a ZipTask' do
|
975
|
+
define 'foo', :version=>'1.0' do
|
976
|
+
package(:javadoc).should be_kind_of(ZipTask)
|
977
|
+
end
|
978
|
+
end
|
979
|
+
end
|
980
|
+
|
981
|
+
|
982
|
+
shared_examples_for 'package_with_' do
|
983
|
+
|
984
|
+
def prepare(options = {})
|
985
|
+
packager = "package_with_#{@packaging}"
|
986
|
+
write 'src/main/java/Source.java'
|
987
|
+
write 'baz/src/main/java/Source.java'
|
988
|
+
define 'foo', :version=>'1.0' do
|
989
|
+
send packager, options
|
990
|
+
define 'bar' ; define 'baz'
|
991
|
+
end
|
992
|
+
end
|
993
|
+
|
994
|
+
def applied_to
|
995
|
+
projects.select { |project| project.packages.first }.map(&:name)
|
996
|
+
end
|
997
|
+
|
998
|
+
it 'should create package of type zip with classifier' do
|
999
|
+
prepare
|
1000
|
+
project('foo').packages.first.to_s.should =~ /foo-1.0-#{@packaging}.zip/
|
1001
|
+
end
|
1002
|
+
|
1003
|
+
it 'should create package for projects that have source files' do
|
1004
|
+
prepare
|
1005
|
+
applied_to.should include('foo', 'foo:baz')
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
it 'should not create package for projects that have no source files' do
|
1009
|
+
prepare
|
1010
|
+
applied_to.should_not include('foo:bar')
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
it 'should limit to projects specified by :only' do
|
1014
|
+
prepare :only=>'baz'
|
1015
|
+
applied_to.should eql(['foo:baz'])
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
it 'should limit to projects specified by :only array' do
|
1019
|
+
prepare :only=>['baz']
|
1020
|
+
applied_to.should eql(['foo:baz'])
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
it 'should ignore project specified by :except' do
|
1024
|
+
prepare :except=>'baz'
|
1025
|
+
applied_to.should eql(['foo'])
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
it 'should ignore projects specified by :except array' do
|
1029
|
+
prepare :except=>['baz']
|
1030
|
+
applied_to.should eql(['foo'])
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
describe 'package_with_sources' do
|
1035
|
+
it_should_behave_like 'package_with_'
|
1036
|
+
before { @packaging = :sources }
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
describe 'package_with_javadoc' do
|
1040
|
+
it_should_behave_like 'package_with_'
|
1041
|
+
before { @packaging = :javadoc }
|
1042
|
+
end
|