buildr 1.3.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +90 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- 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/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +79 -0
- data/doc/extending.textile +186 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,119 @@
|
|
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__), 'test_coverage_helper')
|
18
|
+
Sandbox.require_optional_extension 'buildr/java/emma'
|
19
|
+
artifacts(Buildr::Emma::dependencies).map(&:invoke)
|
20
|
+
|
21
|
+
|
22
|
+
describe Buildr::Emma do
|
23
|
+
before do
|
24
|
+
# Reloading the extension because the sandbox removes all its actions
|
25
|
+
Buildr.module_eval { remove_const :Emma }
|
26
|
+
load File.expand_path('../lib/buildr/java/emma.rb')
|
27
|
+
@tool_module = Buildr::Emma
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_behave_like 'test coverage tool'
|
31
|
+
|
32
|
+
describe 'project-specific' do
|
33
|
+
describe 'metadata file' do
|
34
|
+
it 'should have a default value' do
|
35
|
+
define('foo').emma.metadata_file.should point_to_path('reports/emma/coverage.em')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should be overridable' do
|
39
|
+
define('foo') { emma.metadata_file = path_to('target/metadata.emma') }
|
40
|
+
project('foo').emma.metadata_file.should point_to_path('target/metadata.emma')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should be created during instrumentation' do
|
44
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
45
|
+
define('foo')
|
46
|
+
task('foo:emma:instrument').invoke
|
47
|
+
file(project('foo').emma.metadata_file).should exist
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'coverage file' do
|
52
|
+
it 'should have a default value' do
|
53
|
+
define('foo').emma.coverage_file.should point_to_path('reports/emma/coverage.ec')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should be overridable' do
|
57
|
+
define('foo') { emma.coverage_file = path_to('target/coverage.emma') }
|
58
|
+
project('foo').emma.coverage_file.should point_to_path('target/coverage.emma')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should be created during test' do
|
62
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
63
|
+
write_test :for=>'Foo', :in=>'src/test/java'
|
64
|
+
define('foo')
|
65
|
+
task('foo:test').invoke
|
66
|
+
file(project('foo').emma.coverage_file).should exist
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'instrumentation' do
|
71
|
+
before do
|
72
|
+
['Foo', 'Bar'].each { |cls| write File.join('src/main/java', "#{cls}.java"), "public class #{cls} {}" }
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should instrument only included classes' do
|
76
|
+
define('foo') { emma.include 'Foo' }
|
77
|
+
task("foo:emma:instrument").invoke
|
78
|
+
Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Foo.class'] }
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should not instrument excluded classes' do
|
82
|
+
define('foo') { emma.exclude 'Foo' }
|
83
|
+
task("foo:emma:instrument").invoke
|
84
|
+
Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Bar.class'] }
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should instrument classes that are included but not excluded' do
|
88
|
+
write 'src/main/java/Baz.java', 'public class Baz {}'
|
89
|
+
define('foo') { emma.include('Ba*').exclude('*ar') }
|
90
|
+
task("foo:emma:instrument").invoke
|
91
|
+
Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Baz.class'] }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'reports' do
|
96
|
+
before do
|
97
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
98
|
+
write_test :for=>'Foo', :in=>'src/test/java'
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'in html' do
|
102
|
+
it 'should inform the user if no coverage data' do
|
103
|
+
rm 'src/test/java/FooTest.java'
|
104
|
+
define('foo')
|
105
|
+
lambda { task('foo:emma:html').invoke }.
|
106
|
+
should show_info(/No test coverage report for foo. Missing: #{project('foo').emma.coverage_file}/)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'in xml' do
|
111
|
+
it 'should have an xml file' do
|
112
|
+
define('foo')
|
113
|
+
task('foo:emma:xml').invoke
|
114
|
+
file(File.join(project('foo').emma.report_dir, 'coverage.xml')).should exist
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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
|
+
unless RUBY_PLATFORM =~ /java/
|
21
|
+
describe ENV, 'JAVA_HOME on OS X' do
|
22
|
+
before do
|
23
|
+
@old_home, ENV['JAVA_HOME'] = ENV['JAVA_HOME'], nil
|
24
|
+
@old_env_java = Object.module_eval { remove_const :ENV_JAVA }
|
25
|
+
Config::CONFIG.should_receive(:[]).with('host_os').and_return('darwin0.9')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should point to default JVM' do
|
29
|
+
load File.expand_path('../lib/buildr/java/rjb.rb')
|
30
|
+
ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.framework/Home'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should use value of environment variable if specified' do
|
34
|
+
ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.specified'
|
35
|
+
load File.expand_path('../lib/buildr/java/rjb.rb')
|
36
|
+
ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.specified'
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
ENV['JAVA_HOME'] = @old_home
|
41
|
+
ENV_JAVA.replace @old_env_java
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
describe Java, '#tools_jar' do
|
48
|
+
before do
|
49
|
+
@old_home = ENV['JAVA_HOME']
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'when JAVA_HOME points to a JDK' do
|
53
|
+
before do
|
54
|
+
Java.instance_eval { @tools_jar = nil }
|
55
|
+
write 'jdk/lib/tools.jar'
|
56
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return the path to tools.jar' do
|
60
|
+
Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'when JAVA_HOME points to a JRE inside a JDK' do
|
65
|
+
before do
|
66
|
+
Java.instance_eval { @tools_jar = nil }
|
67
|
+
write 'jdk/lib/tools.jar'
|
68
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk/jre')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should return the path to tools.jar' do
|
72
|
+
Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'when there is no tools.jar' do
|
77
|
+
before do
|
78
|
+
Java.instance_eval { @tools_jar = nil }
|
79
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should return nil' do
|
83
|
+
Java.tools_jar.should be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
after do
|
88
|
+
ENV['JAVA_HOME'] = @old_home
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe Java, '#java' do
|
93
|
+
before do
|
94
|
+
@old_home = ENV['JAVA_HOME']
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'when JAVA_HOME points to an invalid JRE/JDK installation' do
|
98
|
+
before do
|
99
|
+
write 'jdk'
|
100
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should fail with an error message mentioning JAVA_HOME' do
|
104
|
+
begin
|
105
|
+
Java.java ['-version']
|
106
|
+
fail 'Java.java did not fail with JAVA_HOME pointing to invalid JRE/JDK installation'
|
107
|
+
rescue => error
|
108
|
+
error.message.to_s.should match(/JAVA_HOME/)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
after do
|
114
|
+
ENV['JAVA_HOME'] = @old_home
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
describe Java::JavaWrapper do
|
120
|
+
it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
|
121
|
+
Buildr::VERSION.should < '1.5'
|
122
|
+
lambda { Java::JavaWrapper }.should_not raise_error
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,1134 @@
|
|
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/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(package = nil)
|
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 generate a new manifest for a file that does not have one' do
|
100
|
+
Zip::ZipOutputStream.open 'tmp.zip' do |zip|
|
101
|
+
zip.put_next_entry 'empty.txt'
|
102
|
+
end
|
103
|
+
begin
|
104
|
+
manifest = Buildr::Packaging::Java::Manifest.from_zip('tmp.zip')
|
105
|
+
manifest.each do |key, val|
|
106
|
+
Buildr::Packaging::Java::Manifest::STANDARD_HEADER.should include(key)
|
107
|
+
end
|
108
|
+
ensure
|
109
|
+
rm 'tmp.zip'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should map manifest from hash' do
|
114
|
+
package_with_manifest 'Foo'=>1, :bar=>'Bar'
|
115
|
+
inspect_manifest do |manifest|
|
116
|
+
manifest.sections.size.should be(1)
|
117
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
118
|
+
manifest.main['Created-By'].should eql('Buildr')
|
119
|
+
manifest.main['Foo'].should eql('1')
|
120
|
+
manifest.main['bar'].should eql('Bar')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should end hash manifest with EOL' do
|
125
|
+
package_with_manifest 'Foo'=>1, :bar=>'Bar'
|
126
|
+
package = project('foo').package(@packaging)
|
127
|
+
package.invoke
|
128
|
+
Zip::ZipFile.open(package.to_s) { |zip| zip.file.read('META-INF/MANIFEST.MF').should =~ /#{Buildr::Packaging::Java::Manifest::LINE_SEPARATOR}$/ }
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should break hash manifest lines longer than 72 characters using continuations' do
|
132
|
+
package_with_manifest 'foo'=>@long_line
|
133
|
+
package = project('foo').package(@packaging)
|
134
|
+
inspect_manifest do |manifest|
|
135
|
+
manifest.main['foo'].should == @long_line
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should map manifest from array' do
|
140
|
+
package_with_manifest [ { :foo=>'first' }, { :bar=>'second' } ]
|
141
|
+
inspect_manifest do |manifest|
|
142
|
+
manifest.sections.size.should be(2)
|
143
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
144
|
+
manifest.main['foo'].should eql('first')
|
145
|
+
manifest.sections.last['bar'].should eql('second')
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should end array manifest with EOL' do
|
150
|
+
package_with_manifest [ { :foo=>'first' }, { :bar=>'second' } ]
|
151
|
+
package = project('foo').package(@packaging)
|
152
|
+
package.invoke
|
153
|
+
Zip::ZipFile.open(package.to_s) { |zip| zip.file.read('META-INF/MANIFEST.MF')[-1].should == ?\n }
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should break array manifest lines longer than 72 characters using continuations' do
|
157
|
+
package_with_manifest ['foo'=>@long_line]
|
158
|
+
package = project('foo').package(@packaging)
|
159
|
+
inspect_manifest do |manifest|
|
160
|
+
manifest.main['foo'].should == @long_line
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should put Name: at beginning of section' do
|
165
|
+
package_with_manifest [ {}, { 'Name'=>'first', :Foo=>'first', :bar=>'second' } ]
|
166
|
+
package = project('foo').package(@packaging)
|
167
|
+
package.invoke
|
168
|
+
inspect_manifest do |manifest|
|
169
|
+
manifest.sections[1]["Name"].should == "first"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should create manifest from proc' do
|
174
|
+
package_with_manifest lambda { 'Meta: data' }
|
175
|
+
inspect_manifest do |manifest|
|
176
|
+
manifest.sections.size.should be(1)
|
177
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
178
|
+
manifest.main['Meta'].should eql('data')
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should create manifest from file' do
|
183
|
+
write 'MANIFEST.MF', 'Meta: data'
|
184
|
+
package_with_manifest 'MANIFEST.MF'
|
185
|
+
inspect_manifest do |manifest|
|
186
|
+
manifest.sections.size.should be(1)
|
187
|
+
manifest.main['Meta'].should eql('data')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should not add manifest version twice' do
|
192
|
+
write 'MANIFEST.MF', 'Manifest-Version: 1.9'
|
193
|
+
package_with_manifest 'MANIFEST.MF'
|
194
|
+
package ||= project('foo').package(@packaging)
|
195
|
+
package.invoke
|
196
|
+
Zip::ZipFile.open(package.to_s) do |zip|
|
197
|
+
zip.read('META-INF/MANIFEST.MF').scan(/(Manifest-Version)/m).size.should == 1
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should give precedence to version specified in manifest file' do
|
202
|
+
write 'MANIFEST.MF', 'Manifest-Version: 1.9'
|
203
|
+
package_with_manifest 'MANIFEST.MF'
|
204
|
+
inspect_manifest do |manifest|
|
205
|
+
manifest.main['Manifest-Version'].should == '1.9'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should create manifest from task' do
|
210
|
+
file 'MANIFEST.MF' do |task|
|
211
|
+
write task.to_s, 'Meta: data'
|
212
|
+
end
|
213
|
+
package_with_manifest 'MANIFEST.MF'
|
214
|
+
inspect_manifest do |manifest|
|
215
|
+
manifest.sections.size.should be(1)
|
216
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
217
|
+
manifest.main['Meta'].should eql('data')
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should respond to with() and accept manifest' do
|
222
|
+
write 'DISCLAIMER'
|
223
|
+
mkpath 'target/classes'
|
224
|
+
packaging = @packaging
|
225
|
+
define('foo', :version=>'1.0') { package(packaging).with :manifest=>{'Foo'=>'data'} }
|
226
|
+
inspect_manifest { |manifest| manifest.main['Foo'].should eql('data') }
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should include META-INF directory' do
|
230
|
+
packaging = @packaging
|
231
|
+
package = define('foo', :version=>'1.0') { package(packaging) }.packages.first
|
232
|
+
package.invoke
|
233
|
+
Zip::ZipFile.open(package.to_s) do |zip|
|
234
|
+
zip.entries.map(&:to_s).should include('META-INF/')
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should inherit manifest from parent project' do
|
239
|
+
packaging = @packaging
|
240
|
+
package = nil
|
241
|
+
define('foo', :version => '1.0') do
|
242
|
+
manifest['Foo'] = '1'
|
243
|
+
package(packaging)
|
244
|
+
define('bar', :version => '1.0') do
|
245
|
+
manifest['bar'] = 'Bar'
|
246
|
+
package(:jar)
|
247
|
+
package = packages.first
|
248
|
+
end
|
249
|
+
end
|
250
|
+
inspect_manifest(package) do |manifest|
|
251
|
+
manifest.sections.size.should be(1)
|
252
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
253
|
+
manifest.main['Created-By'].should eql('Buildr')
|
254
|
+
manifest.main['Foo'].should eql('1')
|
255
|
+
manifest.main['bar'].should eql('Bar')
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should not modify manifest of parent project' do
|
260
|
+
packaging = @packaging
|
261
|
+
define('foo', :version => '1.0') do
|
262
|
+
manifest['Foo'] = '1'
|
263
|
+
package(packaging)
|
264
|
+
define('bar', :version => '1.0') do
|
265
|
+
manifest['bar'] = 'Bar'
|
266
|
+
package(:jar)
|
267
|
+
end
|
268
|
+
define('baz', :version => '1.0') do
|
269
|
+
manifest['baz'] = 'Baz'
|
270
|
+
package(:jar)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
inspect_manifest(project('foo').packages.first) do |manifest|
|
274
|
+
manifest.sections.size.should be(1)
|
275
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
276
|
+
manifest.main['Created-By'].should eql('Buildr')
|
277
|
+
manifest.main['Foo'].should eql('1')
|
278
|
+
manifest.main['bar'].should be_nil
|
279
|
+
manifest.main['baz'].should be_nil
|
280
|
+
end
|
281
|
+
inspect_manifest(project('foo:bar').packages.first) do |manifest|
|
282
|
+
manifest.sections.size.should be(1)
|
283
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
284
|
+
manifest.main['Created-By'].should eql('Buildr')
|
285
|
+
manifest.main['Foo'].should eql('1')
|
286
|
+
manifest.main['bar'].should eql('Bar')
|
287
|
+
manifest.main['baz'].should be_nil
|
288
|
+
end
|
289
|
+
inspect_manifest(project('foo:baz').packages.first) do |manifest|
|
290
|
+
manifest.sections.size.should be(1)
|
291
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
292
|
+
manifest.main['Created-By'].should eql('Buildr')
|
293
|
+
manifest.main['Foo'].should eql('1')
|
294
|
+
manifest.main['baz'].should eql('Baz')
|
295
|
+
manifest.main['bar'].should be_nil
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
|
301
|
+
describe Project, '#meta_inf' do
|
302
|
+
it 'should by an array' do
|
303
|
+
define('foo').meta_inf.should be_kind_of(Array)
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'should include LICENSE file if found' do
|
307
|
+
write 'LICENSE'
|
308
|
+
define('foo').meta_inf.first.should point_to_path('LICENSE')
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should be empty unless LICENSE exists' do
|
312
|
+
define('foo').meta_inf.should be_empty
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'should inherit from parent project' do
|
316
|
+
write 'LICENSE'
|
317
|
+
define('foo') { define 'bar' }
|
318
|
+
project('foo:bar').meta_inf.first.should point_to_path('LICENSE')
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'should expect LICENSE file parent project' do
|
322
|
+
write 'bar/LICENSE'
|
323
|
+
define('foo') { define 'bar' }
|
324
|
+
project('foo:bar').meta_inf.should be_empty
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
describe 'package with meta_inf', :shared=>true do
|
330
|
+
|
331
|
+
def package_with_meta_inf(meta_inf = nil)
|
332
|
+
packaging = @packaging
|
333
|
+
@project = Buildr.define('foo', :version=>'1.2') do
|
334
|
+
package packaging
|
335
|
+
package(packaging).with(:meta_inf=>meta_inf) if meta_inf
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
def inspect_meta_inf
|
340
|
+
package = project('foo').package(@packaging)
|
341
|
+
package.invoke
|
342
|
+
assumed = Array(@meta_inf_ignore)
|
343
|
+
Zip::ZipFile.open(package.to_s) do |zip|
|
344
|
+
entries = zip.entries.map(&:name).select { |f| File.dirname(f) == 'META-INF' }.map { |f| File.basename(f) }
|
345
|
+
assumed.each { |f| entries.should include(f) }
|
346
|
+
yield entries - assumed if block_given?
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should default to LICENSE file' do
|
351
|
+
write 'LICENSE'
|
352
|
+
package_with_meta_inf
|
353
|
+
inspect_meta_inf { |files| files.should eql(['LICENSE']) }
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'should be empty if no LICENSE file' do
|
357
|
+
package_with_meta_inf
|
358
|
+
inspect_meta_inf { |files| files.should be_empty }
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should include file specified by :meta_inf option' do
|
362
|
+
write 'README'
|
363
|
+
package_with_meta_inf 'README'
|
364
|
+
inspect_meta_inf { |files| files.should eql(['README']) }
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'should include files specified by :meta_inf option' do
|
368
|
+
files = ['README', 'DISCLAIMER'].each { |file| write file }
|
369
|
+
package_with_meta_inf files
|
370
|
+
inspect_meta_inf { |files| files.should eql(files) }
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'should include file task specified by :meta_inf option' do
|
374
|
+
file('README') { |task| write task.to_s }
|
375
|
+
package_with_meta_inf file('README')
|
376
|
+
inspect_meta_inf { |files| files.should eql(['README']) }
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'should include file tasks specified by :meta_inf option' do
|
380
|
+
files = ['README', 'DISCLAIMER'].each { |file| file(file) { |task| write task.to_s } }
|
381
|
+
package_with_meta_inf files.map { |f| file(f) }
|
382
|
+
inspect_meta_inf { |files| files.should eql(files) }
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'should complain if cannot find file' do
|
386
|
+
package_with_meta_inf 'README'
|
387
|
+
lambda { inspect_meta_inf }.should raise_error(RuntimeError, /README/)
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'should complain if cannot build task' do
|
391
|
+
file('README') { fail 'Failed' }
|
392
|
+
package_with_meta_inf 'README'
|
393
|
+
lambda { inspect_meta_inf }.should raise_error(RuntimeError, /Failed/)
|
394
|
+
end
|
395
|
+
|
396
|
+
it 'should respond to with() and accept manifest and meta_inf' do
|
397
|
+
write 'DISCLAIMER'
|
398
|
+
mkpath 'target/classes'
|
399
|
+
packaging = @packaging
|
400
|
+
define('foo', :version=>'1.0') { package(packaging).with :meta_inf=>'DISCLAIMER' }
|
401
|
+
inspect_meta_inf { |files| files.should eql(['DISCLAIMER']) }
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
|
406
|
+
describe Packaging, 'jar' do
|
407
|
+
it_should_behave_like 'packaging'
|
408
|
+
before { @packaging = :jar }
|
409
|
+
it_should_behave_like 'package with manifest'
|
410
|
+
it_should_behave_like 'package with meta_inf'
|
411
|
+
before { @meta_inf_ignore = 'MANIFEST.MF' }
|
412
|
+
|
413
|
+
it 'should use files from compile directory if nothing included' do
|
414
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
415
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
416
|
+
project('foo').package(:jar).invoke
|
417
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
418
|
+
jar.entries.map(&:to_s).sort.should include('META-INF/MANIFEST.MF', 'Test.class')
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'should use files from resources directory if nothing included' do
|
423
|
+
write 'src/main/resources/test/important.properties'
|
424
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
425
|
+
project('foo').package(:jar).invoke
|
426
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
427
|
+
jar.entries.map(&:to_s).sort.should include('test/important.properties')
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
it 'should include class directories' do
|
432
|
+
write 'src/main/java/code/Test.java', 'package code ; class Test {}'
|
433
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
434
|
+
project('foo').package(:jar).invoke
|
435
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
436
|
+
jar.entries.map(&:to_s).sort.should include('code/')
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
it 'should include resource files starting with dot' do
|
441
|
+
write 'src/main/resources/test/.config'
|
442
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
443
|
+
project('foo').package(:jar).invoke
|
444
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
445
|
+
jar.entries.map(&:to_s).sort.should include('test/.config')
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
it 'should include empty resource directories' do
|
450
|
+
mkpath 'src/main/resources/empty'
|
451
|
+
define('foo', :version=>'1.0') { package(:jar) }
|
452
|
+
project('foo').package(:jar).invoke
|
453
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
454
|
+
jar.entries.map(&:to_s).sort.should include('empty/')
|
455
|
+
end
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
|
460
|
+
describe Packaging, 'war' do
|
461
|
+
it_should_behave_like 'packaging'
|
462
|
+
before { @packaging = :war }
|
463
|
+
it_should_behave_like 'package with manifest'
|
464
|
+
it_should_behave_like 'package with meta_inf'
|
465
|
+
before { @meta_inf_ignore = 'MANIFEST.MF' }
|
466
|
+
|
467
|
+
def make_jars
|
468
|
+
artifact('group:id:jar:1.0') { |t| write t.to_s }
|
469
|
+
artifact('group:id:jar:2.0') { |t| write t.to_s }
|
470
|
+
end
|
471
|
+
|
472
|
+
def inspect_war
|
473
|
+
project('foo').package(:war).invoke
|
474
|
+
Zip::ZipFile.open(project('foo').package(:war).to_s) do |war|
|
475
|
+
yield war.entries.map(&:to_s).sort
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
it 'should use files from webapp directory if nothing included' do
|
480
|
+
write 'src/main/webapp/test.html'
|
481
|
+
define('foo', :version=>'1.0') { package(:war) }
|
482
|
+
inspect_war { |files| files.should include('test.html') }
|
483
|
+
end
|
484
|
+
|
485
|
+
it 'should accept files from :classes option' do
|
486
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
487
|
+
write 'classes/test'
|
488
|
+
define('foo', :version=>'1.0') { package(:war).with(:classes=>'classes') }
|
489
|
+
inspect_war { |files| files.should include('WEB-INF/classes/test') }
|
490
|
+
end
|
491
|
+
|
492
|
+
it 'should use files from compile directory if nothing included' do
|
493
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
494
|
+
define('foo', :version=>'1.0') { package(:war) }
|
495
|
+
inspect_war { |files| files.should include('WEB-INF/classes/Test.class') }
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'should ignore compile directory if no source files to compile' do
|
499
|
+
define('foo', :version=>'1.0') { package(:war) }
|
500
|
+
inspect_war { |files| files.should_not include('target/classes') }
|
501
|
+
end
|
502
|
+
|
503
|
+
it 'should include only specified classes directories' do
|
504
|
+
write 'src/main/java'
|
505
|
+
define('foo', :version=>'1.0') { package(:war).with :classes=>_('additional') }
|
506
|
+
project('foo').package(:war).classes.should_not include(project('foo').file('target/classes'))
|
507
|
+
project('foo').package(:war).classes.should include(project('foo').file('additional'))
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'should use files from resources directory if nothing included' do
|
511
|
+
write 'src/main/resources/test/important.properties'
|
512
|
+
define('foo', :version=>'1.0') { package(:war) }
|
513
|
+
inspect_war { |files| files.should include('WEB-INF/classes/test/important.properties') }
|
514
|
+
end
|
515
|
+
|
516
|
+
it 'should include empty resource directories' do
|
517
|
+
mkpath 'src/main/resources/empty'
|
518
|
+
define('foo', :version=>'1.0') { package(:war) }
|
519
|
+
inspect_war { |files| files.should include('WEB-INF/classes/empty/') }
|
520
|
+
end
|
521
|
+
|
522
|
+
it 'should accept file from :libs option' do
|
523
|
+
make_jars
|
524
|
+
define('foo', :version=>'1.0') { package(:war).with(:libs=>'group:id:jar:1.0') }
|
525
|
+
inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar') }
|
526
|
+
end
|
527
|
+
|
528
|
+
it 'should accept file from :libs option' do
|
529
|
+
make_jars
|
530
|
+
define('foo', :version=>'1.0') { package(:war).with(:libs=>['group:id:jar:1.0', 'group:id:jar:2.0']) }
|
531
|
+
inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar', 'WEB-INF/lib/id-2.0.jar') }
|
532
|
+
end
|
533
|
+
|
534
|
+
it 'should use artifacts from compile classpath if no libs specified' do
|
535
|
+
make_jars
|
536
|
+
define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:war) }
|
537
|
+
inspect_war { |files| files.should include('META-INF/MANIFEST.MF', 'WEB-INF/lib/id-1.0.jar', 'WEB-INF/lib/id-2.0.jar') }
|
538
|
+
end
|
539
|
+
|
540
|
+
it 'should include only specified libraries' do
|
541
|
+
define 'foo', :version=>'1.0' do
|
542
|
+
compile.with 'group:id:jar:1.0'
|
543
|
+
package(:war).with :libs=>'additional:id:jar:1.0'
|
544
|
+
end
|
545
|
+
project('foo').package(:war).libs.should_not include(artifact('group:id:jar:1.0'))
|
546
|
+
project('foo').package(:war).libs.should include(artifact('additional:id:jar:1.0'))
|
547
|
+
end
|
548
|
+
|
549
|
+
end
|
550
|
+
|
551
|
+
|
552
|
+
describe Packaging, 'aar' do
|
553
|
+
it_should_behave_like 'packaging'
|
554
|
+
before { @packaging = :aar }
|
555
|
+
it_should_behave_like 'package with manifest'
|
556
|
+
it_should_behave_like 'package with meta_inf'
|
557
|
+
before do
|
558
|
+
write 'src/main/axis2/services.xml'
|
559
|
+
@meta_inf_ignore = ['MANIFEST.MF', 'services.xml']
|
560
|
+
end
|
561
|
+
|
562
|
+
def make_jars
|
563
|
+
artifact('group:id:jar:1.0') { |t| write t.to_s }
|
564
|
+
artifact('group:id:jar:2.0') { |t| write t.to_s }
|
565
|
+
end
|
566
|
+
|
567
|
+
def inspect_aar
|
568
|
+
project('foo').package(:aar).invoke
|
569
|
+
Zip::ZipFile.open(project('foo').package(:aar).to_s) do |aar|
|
570
|
+
yield aar.entries.map(&:to_s).sort
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
it 'should automatically include services.xml and any *.wsdl files under src/main/axis2' do
|
575
|
+
write 'src/main/axis2/my-service.wsdl'
|
576
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
577
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'META-INF/services.xml', 'META-INF/my-service.wsdl') }
|
578
|
+
end
|
579
|
+
|
580
|
+
it 'should accept files from :include option' do
|
581
|
+
write 'test'
|
582
|
+
define('foo', :version=>'1.0') { package(:aar).include 'test' }
|
583
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'test') }
|
584
|
+
end
|
585
|
+
|
586
|
+
it 'should use files from compile directory if nothing included' do
|
587
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
588
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
589
|
+
inspect_aar { |files| files.should include('Test.class') }
|
590
|
+
end
|
591
|
+
|
592
|
+
it 'should use files from resources directory if nothing included' do
|
593
|
+
write 'src/main/resources/test/important.properties'
|
594
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
595
|
+
inspect_aar { |files| files.should include('test/important.properties') }
|
596
|
+
end
|
597
|
+
|
598
|
+
it 'should include empty resource directories' do
|
599
|
+
mkpath 'src/main/resources/empty'
|
600
|
+
define('foo', :version=>'1.0') { package(:aar) }
|
601
|
+
inspect_aar { |files| files.should include('empty/') }
|
602
|
+
end
|
603
|
+
|
604
|
+
it 'should accept file from :libs option' do
|
605
|
+
make_jars
|
606
|
+
define('foo', :version=>'1.0') { package(:aar).with :libs=>'group:id:jar:1.0' }
|
607
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'lib/id-1.0.jar') }
|
608
|
+
end
|
609
|
+
|
610
|
+
it 'should accept file from :libs option' do
|
611
|
+
make_jars
|
612
|
+
define('foo', :version=>'1.0') { package(:aar).with :libs=>['group:id:jar:1.0', 'group:id:jar:2.0'] }
|
613
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF', 'lib/id-1.0.jar', 'lib/id-2.0.jar') }
|
614
|
+
end
|
615
|
+
|
616
|
+
it 'should NOT use artifacts from compile classpath if no libs specified' do
|
617
|
+
make_jars
|
618
|
+
define('foo', :version=>'1.0') { compile.with 'group:id:jar:1.0', 'group:id:jar:2.0' ; package(:aar) }
|
619
|
+
inspect_aar { |files| files.should include('META-INF/MANIFEST.MF') }
|
620
|
+
end
|
621
|
+
|
622
|
+
it 'should return all libraries from libs attribute' do
|
623
|
+
define 'foo', :version=>'1.0' do
|
624
|
+
compile.with 'group:id:jar:1.0'
|
625
|
+
package(:aar).with :libs=>'additional:id:jar:1.0'
|
626
|
+
end
|
627
|
+
project('foo').package(:aar).libs.should_not include(artifact('group:id:jar:1.0'))
|
628
|
+
project('foo').package(:aar).libs.should include(artifact('additional:id:jar:1.0'))
|
629
|
+
end
|
630
|
+
|
631
|
+
end
|
632
|
+
|
633
|
+
|
634
|
+
describe Packaging, 'ear' do
|
635
|
+
it_should_behave_like 'packaging'
|
636
|
+
before { @packaging = :ear }
|
637
|
+
it_should_behave_like 'package with manifest'
|
638
|
+
it_should_behave_like 'package with meta_inf'
|
639
|
+
before { @meta_inf_ignore = ['MANIFEST.MF', 'application.xml'] }
|
640
|
+
|
641
|
+
def inspect_ear
|
642
|
+
project('foo').package(:ear).invoke
|
643
|
+
Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
|
644
|
+
yield ear.entries.map(&:to_s).sort
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
def inspect_application_xml
|
649
|
+
project('foo').package(:ear).invoke
|
650
|
+
Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
|
651
|
+
yield REXML::Document.new(ear.read('META-INF/application.xml')).root
|
652
|
+
end
|
653
|
+
end
|
654
|
+
|
655
|
+
def inspect_classpath(package)
|
656
|
+
project('foo').package(:ear).invoke
|
657
|
+
Zip::ZipFile.open(project('foo').package(:ear).to_s) do |ear|
|
658
|
+
File.open('tmp.zip', 'wb') do |tmp|
|
659
|
+
tmp.write ear.file.read(package)
|
660
|
+
end
|
661
|
+
manifest = Buildr::Packaging::Java::Manifest.from_zip('tmp.zip')
|
662
|
+
yield manifest.main['Class-Path'].split(' ')
|
663
|
+
end
|
664
|
+
end
|
665
|
+
|
666
|
+
it 'should set display name from project id' do
|
667
|
+
define 'foo', :version=>'1.0' do
|
668
|
+
package(:ear).display_name.should eql('foo')
|
669
|
+
define 'bar' do
|
670
|
+
package(:ear).display_name.should eql('foo-bar')
|
671
|
+
end
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
it 'should set display name in application.xml' do
|
676
|
+
define 'foo', :version=>'1.0' do
|
677
|
+
package(:ear)
|
678
|
+
end
|
679
|
+
inspect_application_xml { |xml| xml.get_text('/application/display-name').should == 'foo' }
|
680
|
+
end
|
681
|
+
|
682
|
+
it 'should accept different display name' do
|
683
|
+
define 'foo', :version=>'1.0' do
|
684
|
+
package(:ear).display_name = 'bar'
|
685
|
+
end
|
686
|
+
inspect_application_xml { |xml| xml.get_text('/application/display-name').should == 'bar' }
|
687
|
+
end
|
688
|
+
|
689
|
+
it 'should map WARs to /war directory' do
|
690
|
+
define 'foo', :version=>'1.0' do
|
691
|
+
package(:ear) << package(:war)
|
692
|
+
end
|
693
|
+
inspect_ear { |files| files.should include('war/foo-1.0.war') }
|
694
|
+
end
|
695
|
+
|
696
|
+
it 'should map EJBs to /ejb directory' do
|
697
|
+
define 'foo', :version=>'1.0' do
|
698
|
+
package(:ear).add :ejb=>package(:jar)
|
699
|
+
end
|
700
|
+
inspect_ear { |files| files.should include('ejb/foo-1.0.jar') }
|
701
|
+
end
|
702
|
+
|
703
|
+
it 'should not modify original artifact for its components' do
|
704
|
+
define 'one', :version => '1.0' do
|
705
|
+
write 'src/main/resources/one.txt', '1'
|
706
|
+
package(:jar)
|
707
|
+
end
|
708
|
+
|
709
|
+
define 'two', :version => '1.0' do
|
710
|
+
write 'src/main/resources/two.txt', '2'
|
711
|
+
package(:jar)
|
712
|
+
end
|
713
|
+
|
714
|
+
define 'foo', :version => '1.0' do
|
715
|
+
package(:ear).add project(:one).package(:jar)
|
716
|
+
package(:ear).add :ejb => project(:two).package(:jar)
|
717
|
+
end
|
718
|
+
|
719
|
+
inspect_ear { |files| files.should include('lib/one-1.0.jar', 'ejb/two-1.0.jar') }
|
720
|
+
|
721
|
+
Buildr::Packaging::Java::Manifest.from_zip(project('one').package(:jar)).main['Class-Path'].should be_nil
|
722
|
+
Buildr::Packaging::Java::Manifest.from_zip(project('two').package(:jar)).main['Class-Path'].should be_nil
|
723
|
+
|
724
|
+
inspect_classpath 'ejb/two-1.0.jar' do |classpath|
|
725
|
+
classpath.should include('../lib/one-1.0.jar')
|
726
|
+
end
|
727
|
+
end
|
728
|
+
|
729
|
+
it 'should map JARs to /lib directory' do
|
730
|
+
define 'foo', :version=>'1.0' do
|
731
|
+
package(:ear) << package(:jar)
|
732
|
+
end
|
733
|
+
inspect_ear { |files| files.should include('lib/foo-1.0.jar') }
|
734
|
+
end
|
735
|
+
|
736
|
+
it 'should accept component type with :type option' do
|
737
|
+
define 'foo', :version=>'1.0' do
|
738
|
+
package(:ear).add package(:jar), :type=>:ejb
|
739
|
+
end
|
740
|
+
inspect_ear { |files| files.should include('ejb/foo-1.0.jar') }
|
741
|
+
end
|
742
|
+
|
743
|
+
it 'should accept component and its type as type=>artifact' do
|
744
|
+
define 'foo', :version=>'1.0' do
|
745
|
+
package(:ear).add :ejb=>package(:jar)
|
746
|
+
end
|
747
|
+
inspect_ear { |files| files.should include('ejb/foo-1.0.jar') }
|
748
|
+
end
|
749
|
+
|
750
|
+
it 'should map typed JARs to /jar directory' do
|
751
|
+
define 'foo', :version=>'1.0' do
|
752
|
+
package(:ear).add :jar=>package(:jar)
|
753
|
+
end
|
754
|
+
inspect_ear { |files| files.should include('jar/foo-1.0.jar') }
|
755
|
+
end
|
756
|
+
|
757
|
+
it 'should add multiple components at a time using the type=>component style' do
|
758
|
+
define 'bar', :version => '1.5' do
|
759
|
+
package(:war) # must be added as a webapp
|
760
|
+
package(:jar) # must be added as a shared lib
|
761
|
+
package(:zip) # this one should be excluded
|
762
|
+
end
|
763
|
+
define 'baz', :version => '1.5' do
|
764
|
+
package(:jar, :id => 'one')
|
765
|
+
package(:jar, :id => 'two')
|
766
|
+
end
|
767
|
+
define 'foo', :version => '1.0' do
|
768
|
+
package(:ear).add :lib => project('baz'),
|
769
|
+
:war => project('bar').package(:war),
|
770
|
+
:ejb => project('bar').package(:jar)
|
771
|
+
end
|
772
|
+
inspect_ear do |files|
|
773
|
+
files.should include(*%w{ lib/one-1.5.jar lib/two-1.5.jar war/bar-1.5.war ejb/bar-1.5.jar })
|
774
|
+
files.should_not satisfy { files.any? { |f| f =~ /\.zip$/ } }
|
775
|
+
end
|
776
|
+
end
|
777
|
+
|
778
|
+
it 'should add all EAR supported packages when given a project argument' do
|
779
|
+
define 'bar', :version => '1.5' do
|
780
|
+
package(:war) # must be added as a webapp
|
781
|
+
package(:jar) # must be added as a shared lib
|
782
|
+
package(:zip) # this one should be excluded
|
783
|
+
end
|
784
|
+
define 'baz', :version => '1.5' do
|
785
|
+
package(:war)
|
786
|
+
package(:jar)
|
787
|
+
end
|
788
|
+
define 'foo', :version => '1.0' do
|
789
|
+
package(:ear).add projects(:bar, :baz)
|
790
|
+
end
|
791
|
+
inspect_ear do |files|
|
792
|
+
files.should include('war/bar-1.5.war', 'lib/bar-1.5.jar', 'lib/baz-1.5.jar', 'war/baz-1.5.war')
|
793
|
+
files.should_not satisfy { files.any? { |f| f =~ /\.zip$/ } }
|
794
|
+
end
|
795
|
+
end
|
796
|
+
|
797
|
+
it 'should complain about unknown component type' do
|
798
|
+
define 'foo', :version=>'1.0' do
|
799
|
+
lambda { package(:ear).add package(:zip) }.should raise_error(RuntimeError, /ear component/i)
|
800
|
+
end
|
801
|
+
end
|
802
|
+
|
803
|
+
it 'should allow unknown component types with explicit type' do
|
804
|
+
define 'foo', :version=>'1.0' do
|
805
|
+
package(:ear).add :lib=>package(:zip)
|
806
|
+
end
|
807
|
+
inspect_ear { |files| files.should include('lib/foo-1.0.zip') }
|
808
|
+
end
|
809
|
+
|
810
|
+
it 'should accept alternative directory name' do
|
811
|
+
define 'foo', :version=>'1.0' do
|
812
|
+
package(:ear).add package(:jar), :path=>'trash'
|
813
|
+
end
|
814
|
+
inspect_ear { |files| files.should include('trash/foo-1.0.jar') }
|
815
|
+
end
|
816
|
+
|
817
|
+
it 'should accept customization of directory map' do
|
818
|
+
define 'foo', :version=>'1.0' do
|
819
|
+
package(:ear).dirs[:jar] = 'jarred'
|
820
|
+
package(:ear).add :jar=>package(:jar)
|
821
|
+
end
|
822
|
+
inspect_ear { |files| files.should include('jarred/foo-1.0.jar') }
|
823
|
+
end
|
824
|
+
|
825
|
+
it 'should accept customization of directory map with nil paths in application.xml' do
|
826
|
+
define 'foo', :version=>'1.0' do
|
827
|
+
package(:ear).dirs[:war] = nil
|
828
|
+
package(:ear).add :war=>package(:war)
|
829
|
+
package(:ear).add package(:jar)
|
830
|
+
end
|
831
|
+
inspect_ear { |files| files.should include('foo-1.0.war') }
|
832
|
+
inspect_application_xml do |xml|
|
833
|
+
xml.get_text("/application/module[@id='foo']/web/web-uri").to_s.should eql('foo-1.0.war')
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
837
|
+
it 'should accept customization of directory map with nil paths in the classpath' do
|
838
|
+
define 'foo', :version=>'1.0' do
|
839
|
+
package(:ear).dirs[:lib] = nil
|
840
|
+
package(:ear).add :war=>package(:war)
|
841
|
+
package(:ear) << package(:jar)
|
842
|
+
end
|
843
|
+
inspect_classpath 'war/foo-1.0.war' do |classpath|
|
844
|
+
classpath.should include('../foo-1.0.jar')
|
845
|
+
end
|
846
|
+
end
|
847
|
+
|
848
|
+
it 'should list WAR components in application.xml' do
|
849
|
+
define 'foo', :version=>'1.0' do
|
850
|
+
package(:ear) << package(:war) << package(:war, :id=>'bar')
|
851
|
+
end
|
852
|
+
inspect_application_xml do |xml|
|
853
|
+
xml.get_elements("/application/module[@id='foo'][web]").should_not be_empty
|
854
|
+
xml.get_elements("/application/module[@id='bar'][web]").should_not be_empty
|
855
|
+
end
|
856
|
+
end
|
857
|
+
|
858
|
+
it 'should specify web-uri for WAR components in application.xml' do
|
859
|
+
define 'foo', :version=>'1.0' do
|
860
|
+
package(:ear) << package(:war)
|
861
|
+
package(:ear).add package(:war, :id=>'bar'), :path=>'ws'
|
862
|
+
end
|
863
|
+
inspect_application_xml do |xml|
|
864
|
+
xml.get_text("/application/module[@id='foo']/web/web-uri").to_s.should eql('war/foo-1.0.war')
|
865
|
+
xml.get_text("/application/module[@id='bar']/web/web-uri").to_s.should eql('ws/bar-1.0.war')
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
it 'should specify context-root for WAR components in application.xml' do
|
870
|
+
define 'foo', :version=>'1.0' do
|
871
|
+
package(:ear) << package(:war)
|
872
|
+
package(:ear).add package(:war, :id=>'bar')
|
873
|
+
end
|
874
|
+
inspect_application_xml do |xml|
|
875
|
+
xml.get_text("/application/module[@id='foo']/web/context-root").to_s.should eql('/foo')
|
876
|
+
xml.get_text("/application/module[@id='bar']/web/context-root").to_s.should eql('/bar')
|
877
|
+
end
|
878
|
+
end
|
879
|
+
|
880
|
+
it 'should accept context-root for WAR components in application.xml' do
|
881
|
+
define 'foo', :version=>'1.0' do
|
882
|
+
package(:ear).add package(:war), :context_root=>'rooted'
|
883
|
+
end
|
884
|
+
inspect_application_xml do |xml|
|
885
|
+
xml.get_text("/application/module[@id='foo']/web/context-root").to_s.should eql('/rooted')
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
889
|
+
it 'should allow disabling the context root' do
|
890
|
+
define 'foo', :version=>'1.0' do
|
891
|
+
package(:ear).add package(:war), :context_root=>false
|
892
|
+
end
|
893
|
+
inspect_application_xml do |xml|
|
894
|
+
xml.get_elements("/application/module[@id='foo']/web/context-root").should be_empty
|
895
|
+
end
|
896
|
+
end
|
897
|
+
|
898
|
+
it 'should list EJB components in application.xml' do
|
899
|
+
define 'foo', :version=>'1.0' do
|
900
|
+
package(:ear).add :ejb=>package(:jar)
|
901
|
+
package(:ear).add :ejb=>package(:jar, :id=>'bar')
|
902
|
+
end
|
903
|
+
inspect_application_xml do |xml|
|
904
|
+
xml.get_text("/application/module[@id='foo']/ejb").to_s.should eql('ejb/foo-1.0.jar')
|
905
|
+
xml.get_text("/application/module[@id='bar']/ejb").to_s.should eql('ejb/bar-1.0.jar')
|
906
|
+
end
|
907
|
+
end
|
908
|
+
|
909
|
+
it 'should list JAR components in application.xml' do
|
910
|
+
define 'foo', :version=>'1.0' do
|
911
|
+
package(:ear) << { :jar=>package(:jar) } << { :jar=>package(:jar, :id=>'bar') }
|
912
|
+
end
|
913
|
+
inspect_application_xml do |xml|
|
914
|
+
jars = xml.get_elements('/application/jar').map(&:texts).map(&:join)
|
915
|
+
jars.should include('jar/foo-1.0.jar', 'jar/bar-1.0.jar')
|
916
|
+
end
|
917
|
+
end
|
918
|
+
|
919
|
+
it 'should update WAR component classpath to include libraries' do
|
920
|
+
define 'foo', :version=>'1.0' do
|
921
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
922
|
+
package(:ear).add package(:war)
|
923
|
+
end
|
924
|
+
inspect_classpath 'war/foo-1.0.war' do |classpath|
|
925
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
926
|
+
end
|
927
|
+
end
|
928
|
+
|
929
|
+
it 'should update WAR component classpath but skip internal libraries' do
|
930
|
+
define 'foo', :version=>'1.0' do
|
931
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
932
|
+
package(:war).with(:libs=>package(:jar, :id=>'lib1'))
|
933
|
+
package(:ear).add package(:war)
|
934
|
+
end
|
935
|
+
inspect_classpath 'war/foo-1.0.war' do |classpath|
|
936
|
+
classpath.should_not include('../lib/lib1-1.0.jar')
|
937
|
+
classpath.should include('../lib/lib2-1.0.jar')
|
938
|
+
end
|
939
|
+
end
|
940
|
+
|
941
|
+
it 'should update EJB component classpath to include libraries' do
|
942
|
+
define 'foo', :version=>'1.0' do
|
943
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
944
|
+
package(:ear).add :ejb=>package(:jar, :id=>'foo')
|
945
|
+
end
|
946
|
+
inspect_classpath 'ejb/foo-1.0.jar' do |classpath|
|
947
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
948
|
+
end
|
949
|
+
end
|
950
|
+
|
951
|
+
it 'should update JAR component classpath to include libraries' do
|
952
|
+
define 'foo', :version=>'1.0' do
|
953
|
+
package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
|
954
|
+
package(:ear).add :jar=>package(:jar, :id=>'foo')
|
955
|
+
end
|
956
|
+
inspect_classpath 'jar/foo-1.0.jar' do |classpath|
|
957
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
958
|
+
end
|
959
|
+
end
|
960
|
+
|
961
|
+
it 'should deal with very long classpaths' do
|
962
|
+
define 'foo', :version=>'1.0' do
|
963
|
+
20.times { |i| package(:ear) << package(:jar, :id=>"lib#{i}") }
|
964
|
+
package(:ear).add :jar=>package(:jar, :id=>'foo')
|
965
|
+
end
|
966
|
+
inspect_classpath 'jar/foo-1.0.jar' do |classpath|
|
967
|
+
classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
|
968
|
+
end
|
969
|
+
end
|
970
|
+
|
971
|
+
|
972
|
+
it 'should generate relative classpaths for top level EJB' do
|
973
|
+
define 'foo', :version => '1.0' do
|
974
|
+
package(:ear).add package(:jar, :id => 'one'), :path => '.'
|
975
|
+
package(:ear).add package(:jar, :id => 'two'), :path => 'dos'
|
976
|
+
package(:ear).add package(:jar, :id => 'three'), :path => 'tres'
|
977
|
+
package(:ear).add :ejb => package(:jar, :id => 'ejb1'), :path => '.'
|
978
|
+
end
|
979
|
+
inspect_classpath 'ejb1-1.0.jar' do |classpath|
|
980
|
+
classpath.should include(*%w{ one-1.0.jar dos/two-1.0.jar tres/three-1.0.jar })
|
981
|
+
end
|
982
|
+
end
|
983
|
+
|
984
|
+
it 'should generate relative classpaths for second level EJB' do
|
985
|
+
define 'foo', :version => '1.0' do
|
986
|
+
package(:ear).add package(:jar, :id => 'one'), :path => '.'
|
987
|
+
package(:ear).add package(:jar, :id => 'two'), :path => 'dos'
|
988
|
+
package(:ear).add package(:jar, :id => 'three'), :path => 'tres'
|
989
|
+
package(:ear).add :ejb => package(:jar, :id => 'ejb2'), :path => 'dos'
|
990
|
+
end
|
991
|
+
inspect_classpath 'dos/ejb2-1.0.jar' do |classpath|
|
992
|
+
classpath.should include(*%w{ ../one-1.0.jar two-1.0.jar ../tres/three-1.0.jar })
|
993
|
+
end
|
994
|
+
end
|
995
|
+
|
996
|
+
it 'should generate relative classpaths for nested EJB' do
|
997
|
+
define 'foo', :version => '1.0' do
|
998
|
+
package(:ear).add package(:jar, :id => 'one'), :path => '.'
|
999
|
+
package(:ear).add package(:jar, :id => 'two'), :path => 'dos'
|
1000
|
+
package(:ear).add package(:jar, :id => 'three'), :path => 'dos/tres'
|
1001
|
+
package(:ear).add package(:jar, :id => 'four'), :path => 'dos/cuatro'
|
1002
|
+
package(:ear).add :ejb => package(:jar, :id => 'ejb4'), :path => 'dos/cuatro'
|
1003
|
+
end
|
1004
|
+
inspect_classpath 'dos/cuatro/ejb4-1.0.jar' do |classpath|
|
1005
|
+
classpath.should include(*%w{ ../../one-1.0.jar ../two-1.0.jar ../tres/three-1.0.jar four-1.0.jar })
|
1006
|
+
end
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
|
1012
|
+
describe Packaging, 'sources' do
|
1013
|
+
it_should_behave_like 'packaging'
|
1014
|
+
before { @packaging, @package_type = :sources, :zip }
|
1015
|
+
|
1016
|
+
it 'should create package of type :zip and classifier \'sources\'' do
|
1017
|
+
define 'foo', :version=>'1.0' do
|
1018
|
+
package(:sources).type.should eql(:zip)
|
1019
|
+
package(:sources).classifier.should eql('sources')
|
1020
|
+
package(:sources).name.should match(/foo-1.0-sources.zip$/)
|
1021
|
+
end
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
it 'should contain source files' do
|
1025
|
+
write 'src/main/java/Source.java'
|
1026
|
+
define('foo', :version=>'1.0') { package(:sources) }
|
1027
|
+
project('foo').task('package').invoke
|
1028
|
+
project('foo').packages.first.should contain('Source.java')
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
it 'should be a ZipTask' do
|
1032
|
+
define 'foo', :version=>'1.0' do
|
1033
|
+
package(:javadoc).should be_kind_of(ZipTask)
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
|
1039
|
+
describe Packaging, 'javadoc' do
|
1040
|
+
it_should_behave_like 'packaging'
|
1041
|
+
before { @packaging, @package_type = :javadoc, :zip }
|
1042
|
+
|
1043
|
+
it 'should create package of type :zip and classifier \'javadoc\'' do
|
1044
|
+
define 'foo', :version=>'1.0' do
|
1045
|
+
package(:javadoc).type.should eql(:zip)
|
1046
|
+
package(:javadoc).classifier.should eql('javadoc')
|
1047
|
+
package(:javadoc).name.pathmap('%f').should eql('foo-1.0-javadoc.zip')
|
1048
|
+
end
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
it 'should contain Javadocs' do
|
1052
|
+
write 'src/main/java/Source.java', 'public class Source {}'
|
1053
|
+
define('foo', :version=>'1.0') { package(:javadoc) }
|
1054
|
+
project('foo').task('package').invoke
|
1055
|
+
project('foo').packages.first.should contain('Source.html', 'index.html')
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
it 'should use project description in window title' do
|
1059
|
+
write 'src/main/java/Source.java', 'public class Source {}'
|
1060
|
+
desc 'My Project'
|
1061
|
+
define('foo', :version=>'1.0') { package(:javadoc) }
|
1062
|
+
project('foo').task('package').invoke
|
1063
|
+
project('foo').packages.first.entry('index.html').should contain('My Project')
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
it 'should be a ZipTask' do
|
1067
|
+
define 'foo', :version=>'1.0' do
|
1068
|
+
package(:javadoc).should be_kind_of(ZipTask)
|
1069
|
+
end
|
1070
|
+
end
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
|
1074
|
+
shared_examples_for 'package_with_' do
|
1075
|
+
|
1076
|
+
def prepare(options = {})
|
1077
|
+
packager = "package_with_#{@packaging}"
|
1078
|
+
write 'src/main/java/Source.java'
|
1079
|
+
write 'baz/src/main/java/Source.java'
|
1080
|
+
define 'foo', :version=>'1.0' do
|
1081
|
+
send packager, options
|
1082
|
+
define 'bar' ; define 'baz'
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
def applied_to
|
1087
|
+
projects.select { |project| project.packages.first }.map(&:name)
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
it 'should create package of type zip with classifier' do
|
1091
|
+
prepare
|
1092
|
+
project('foo').packages.first.to_s.should =~ /foo-1.0-#{@packaging}.zip/
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
it 'should create package for projects that have source files' do
|
1096
|
+
prepare
|
1097
|
+
applied_to.should include('foo', 'foo:baz')
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
it 'should not create package for projects that have no source files' do
|
1101
|
+
prepare
|
1102
|
+
applied_to.should_not include('foo:bar')
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
it 'should limit to projects specified by :only' do
|
1106
|
+
prepare :only=>'baz'
|
1107
|
+
applied_to.should eql(['foo:baz'])
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
it 'should limit to projects specified by :only array' do
|
1111
|
+
prepare :only=>['baz']
|
1112
|
+
applied_to.should eql(['foo:baz'])
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
it 'should ignore project specified by :except' do
|
1116
|
+
prepare :except=>'baz'
|
1117
|
+
applied_to.should eql(['foo'])
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
it 'should ignore projects specified by :except array' do
|
1121
|
+
prepare :except=>['baz']
|
1122
|
+
applied_to.should eql(['foo'])
|
1123
|
+
end
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
describe 'package_with_sources' do
|
1127
|
+
it_should_behave_like 'package_with_'
|
1128
|
+
before { @packaging = :sources }
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
describe 'package_with_javadoc' do
|
1132
|
+
it_should_behave_like 'package_with_'
|
1133
|
+
before { @packaging = :javadoc }
|
1134
|
+
end
|