buildr 1.3.5-x86-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,583 @@
|
|
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
|
+
module CompilerHelper
|
21
|
+
def compile_task
|
22
|
+
@compile_task ||= define('foo').compile.using(:javac)
|
23
|
+
end
|
24
|
+
|
25
|
+
def sources
|
26
|
+
@sources ||= ['Test1.java', 'Test2.java'].map { |f| File.join('src/main/java/thepackage', f) }.
|
27
|
+
each { |src| write src, "package thepackage; class #{src.pathmap('%n')} {}" }
|
28
|
+
end
|
29
|
+
|
30
|
+
def jars
|
31
|
+
@jars ||= begin
|
32
|
+
write 'jars/src/main/java/Dependency.java', 'class Dependency { }'
|
33
|
+
define 'jars', :version=>'1.0', :base_dir => 'jars' do
|
34
|
+
package(:jar, :id=>'jar1')
|
35
|
+
package(:jar, :id=>'jar2')
|
36
|
+
end
|
37
|
+
project('jars').packages.map(&:to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
describe Buildr::CompileTask do
|
44
|
+
include CompilerHelper
|
45
|
+
|
46
|
+
it 'should respond to from() and return self' do
|
47
|
+
compile_task.from(sources).should be(compile_task)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should respond to from() and add sources' do
|
51
|
+
compile_task.from sources, File.dirname(sources.first)
|
52
|
+
compile_task.sources.should == sources + [File.dirname(sources.first)]
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should respond to with() and return self' do
|
56
|
+
compile_task.with('test.jar').should be(compile_task)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should respond to with() and add dependencies' do
|
60
|
+
jars = (1..3).map { |i| "test#{i}.jar" }
|
61
|
+
compile_task.with *jars
|
62
|
+
compile_task.dependencies.should == artifacts(jars)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should respond to into() and return self' do
|
66
|
+
compile_task.into('code').should be(compile_task)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should respond to into() and create file task' do
|
70
|
+
compile_task.from(sources).into('code')
|
71
|
+
lambda { file('code').invoke }.should run_task('foo:compile')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should respond to using() and return self' do
|
75
|
+
compile_task.using(:source=>'1.4').should eql(compile_task)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should respond to using() and set options' do
|
79
|
+
compile_task.using(:source=>'1.4', 'target'=>'1.5')
|
80
|
+
compile_task.options.source.should eql('1.4')
|
81
|
+
compile_task.options.target.should eql('1.5')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should attempt to identify compiler' do
|
85
|
+
Compiler.compilers.first.should_receive(:applies_to?).at_least(:once)
|
86
|
+
define('foo')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should only support existing compilers' do
|
90
|
+
lambda { define('foo') { compile.using(:unknown) } }.should raise_error(ArgumentError, /unknown compiler/i)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should only allow setting the compiler once' do
|
94
|
+
lambda { define('foo') { compile.using(:javac).using(:scalac) } }.should raise_error(RuntimeError, /already selected/i)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
describe Buildr::CompileTask, '#compiler' do
|
100
|
+
it 'should be nil if no compiler identifier' do
|
101
|
+
define('foo').compile.compiler.should be_nil
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return the selected compiler' do
|
105
|
+
define('foo') { compile.using(:javac) }
|
106
|
+
project('foo').compile.compiler.should eql(:javac)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should attempt to identify compiler if sources are specified' do
|
110
|
+
define 'foo' do
|
111
|
+
Compiler.compilers.first.should_receive(:applies_to?).at_least(:once)
|
112
|
+
compile.from('sources').compiler
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should allow supressing compilation' do
|
117
|
+
write 'src/main/java/package/Test.java', 'class Test {}'
|
118
|
+
define 'foo' do
|
119
|
+
compile.sources.clear
|
120
|
+
end
|
121
|
+
project('foo').compile.invoke
|
122
|
+
Dir['target/classes/*'].should be_empty
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
describe Buildr::CompileTask, '#language' do
|
128
|
+
it 'should be nil if no compiler identifier' do
|
129
|
+
define('foo').compile.language.should be_nil
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should return the appropriate language' do
|
133
|
+
define('foo') { compile.using(:javac) }
|
134
|
+
project('foo').compile.language.should eql(:java)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
describe Buildr::CompileTask, '#sources' do
|
140
|
+
include CompilerHelper
|
141
|
+
|
142
|
+
it 'should be empty if no sources in default directory' do
|
143
|
+
compile_task.sources.should be_empty
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should point to default directory if it contains sources' do
|
147
|
+
write 'src/main/java', ''
|
148
|
+
compile_task.sources.first.should point_to_path('src/main/java')
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should be an array' do
|
152
|
+
compile_task.sources += sources
|
153
|
+
compile_task.sources.should == sources
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should allow files' do
|
157
|
+
compile_task.from(sources).into('classes').invoke
|
158
|
+
sources.each { |src| file(src.pathmap('classes/thepackage/%n.class')).should exist }
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should allow directories' do
|
162
|
+
compile_task.from(File.dirname(sources.first)).into('classes').invoke
|
163
|
+
sources.each { |src| file(src.pathmap('classes/thepackage/%n.class')).should exist }
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should allow tasks' do
|
167
|
+
lambda { compile_task.from(file(sources.first)).into('classes').invoke }.should run_task('foo:compile')
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should act as prerequisites' do
|
171
|
+
file('src2') { |task| task('prereq').invoke ; mkpath task.name }
|
172
|
+
lambda { compile_task.from('src2').into('classes').invoke }.should run_task('prereq')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
describe Buildr::CompileTask, '#dependencies' do
|
178
|
+
include CompilerHelper
|
179
|
+
|
180
|
+
it 'should be empty' do
|
181
|
+
compile_task.dependencies.should be_empty
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should be an array' do
|
185
|
+
compile_task.dependencies += jars
|
186
|
+
compile_task.dependencies.should == jars
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'should allow files' do
|
190
|
+
compile_task.from(sources).with(jars).into('classes').invoke
|
191
|
+
sources.each { |src| file(src.pathmap('classes/thepackage/%n.class')).should exist }
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should allow tasks' do
|
195
|
+
compile_task.from(sources).with(file(jars.first)).into('classes').invoke
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should allow artifacts' do
|
199
|
+
artifact('group:id:jar:1.0') { |task| mkpath File.dirname(task.to_s) ; cp jars.first.to_s, task.to_s }.enhance jars
|
200
|
+
compile_task.from(sources).with('group:id:jar:1.0').into('classes').invoke
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should allow projects' do
|
204
|
+
define('bar', :version=>'1', :group=>'self') { package :jar }
|
205
|
+
compile_task.with project('bar')
|
206
|
+
compile_task.dependencies.should == project('bar').packages
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should be accessible as classpath up to version 1.5 since it was deprecated in version 1.3' do
|
210
|
+
Buildr::VERSION.should < '1.5'
|
211
|
+
lambda { compile_task.classpath = jars }.should change(compile_task, :dependencies).to(jars)
|
212
|
+
lambda { compile_task.dependencies = [] }.should change(compile_task, :classpath).to([])
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
describe Buildr::CompileTask, '#target' do
|
219
|
+
include CompilerHelper
|
220
|
+
|
221
|
+
it 'should be a file task' do
|
222
|
+
compile_task.from(@sources).into('classes')
|
223
|
+
compile_task.target.should be_kind_of(Rake::FileTask)
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'should accept a task' do
|
227
|
+
task = file('classes')
|
228
|
+
compile_task.into(task).target.should be(task)
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should create dependency in file task when set' do
|
232
|
+
compile_task.from(sources).into('classes')
|
233
|
+
lambda { file('classes').invoke }.should run_task('foo:compile')
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
describe Buildr::CompileTask, '#options' do
|
239
|
+
include CompilerHelper
|
240
|
+
|
241
|
+
it 'should have getter and setter methods' do
|
242
|
+
compile_task.options.foo = 'bar'
|
243
|
+
compile_task.options.foo.should eql('bar')
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should have bracket accessors' do
|
247
|
+
compile_task.options[:foo] = 'bar'
|
248
|
+
compile_task.options[:foo].should eql('bar')
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should map from bracket accessor to get/set accessor' do
|
252
|
+
compile_task.options[:foo] = 'bar'
|
253
|
+
compile_task.options.foo.should eql('bar')
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'should be independent of parent' do
|
257
|
+
define 'foo' do
|
258
|
+
compile.using(:javac, :source=>'1.4')
|
259
|
+
define 'bar' do
|
260
|
+
compile.using(:javac, :source=>'1.5')
|
261
|
+
end
|
262
|
+
end
|
263
|
+
project('foo').compile.options.source.should eql('1.4')
|
264
|
+
project('foo:bar').compile.options.source.should eql('1.5')
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
|
269
|
+
describe Buildr::CompileTask, '#invoke' do
|
270
|
+
include CompilerHelper
|
271
|
+
|
272
|
+
it 'should compile into target directory' do
|
273
|
+
compile_task.from(sources).into('code').invoke
|
274
|
+
Dir['code/thepackage/*.class'].should_not be_empty
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should compile only once' do
|
278
|
+
compile_task.from(sources)
|
279
|
+
lambda { compile_task.target.invoke }.should run_task('foo:compile')
|
280
|
+
lambda { compile_task.invoke }.should_not run_task('foo:compile')
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'should compile if there are source files to compile' do
|
284
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should not compile unless there are source files to compile' do
|
288
|
+
lambda { compile_task.invoke }.should_not run_task('foo:compile')
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'should require source file or directory to exist' do
|
292
|
+
lambda { compile_task.from('empty').into('classes').invoke }.should raise_error(RuntimeError, /Don't know how to build/)
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'should run all source files as prerequisites' do
|
296
|
+
mkpath 'src'
|
297
|
+
file('src').should_receive :invoke_prerequisites
|
298
|
+
compile_task.from('src').invoke
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'should require dependencies to exist' do
|
302
|
+
lambda { compile_task.from(sources).with('no-such.jar').into('classes').invoke }.should \
|
303
|
+
raise_error(RuntimeError, /Don't know how to build/)
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'should run all dependencies as prerequisites' do
|
307
|
+
file(File.expand_path('no-such.jar')) { |task| task('prereq').invoke }
|
308
|
+
lambda { compile_task.from(sources).with('no-such.jar').into('classes').invoke }.should run_tasks(['prereq', 'foo:compile'])
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should force compilation if no target' do
|
312
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'should force compilation if target empty' do
|
316
|
+
time = Time.now
|
317
|
+
mkpath compile_task.target.to_s
|
318
|
+
File.utime(time - 1, time - 1, compile_task.target.to_s)
|
319
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'should force compilation if sources newer than compiled' do
|
323
|
+
# Simulate class files that are older than source files.
|
324
|
+
time = Time.now
|
325
|
+
sources.each { |src| File.utime(time + 1, time + 1, src) }
|
326
|
+
sources.map { |src| src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
327
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
328
|
+
File.utime(time - 1, time - 1, project('foo').compile.target.to_s)
|
329
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'should not force compilation if sources older than compiled' do
|
333
|
+
# When everything has the same timestamp, nothing is compiled again.
|
334
|
+
time = Time.now
|
335
|
+
sources.map { |src| src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
336
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
337
|
+
lambda { compile_task.from(sources).invoke }.should_not run_task('foo:compile')
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'should force compilation if dependencies newer than compiled' do
|
341
|
+
jars; project('jars').task("package").invoke
|
342
|
+
# On my machine the times end up the same, so need to push dependencies in the past.
|
343
|
+
time = Time.now
|
344
|
+
sources.map { |src| src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
345
|
+
each { |kls| write kls ; File.utime(time - 1, time - 1, kls) }
|
346
|
+
File.utime(time - 1, time - 1, project('foo').compile.target.to_s)
|
347
|
+
jars.each { |jar| File.utime(time + 1, time + 1, jar) }
|
348
|
+
lambda { compile_task.from(sources).with(jars).invoke }.should run_task('foo:compile')
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'should not force compilation if dependencies older than compiled' do
|
352
|
+
jars; project('jars').task("package").invoke
|
353
|
+
time = Time.now
|
354
|
+
jars.each { |jar| File.utime(time - 1 , time - 1, jar) }
|
355
|
+
sources.map { |src| File.utime(time, time, src); src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
356
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
357
|
+
lambda { compile_task.from(sources).with(jars).invoke }.should_not run_task('foo:compile')
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'should timestamp target directory if specified' do
|
361
|
+
time = Time.now - 10
|
362
|
+
mkpath compile_task.target.to_s
|
363
|
+
File.utime(time, time, compile_task.target.to_s)
|
364
|
+
compile_task.timestamp.should be_close(time, 1)
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'should touch target if anything compiled' do
|
368
|
+
mkpath compile_task.target.to_s
|
369
|
+
File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
|
370
|
+
compile_task.from(sources).invoke
|
371
|
+
File.stat(compile_task.target.to_s).mtime.should be_close(Time.now, 2)
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'should not touch target if nothing compiled' do
|
375
|
+
mkpath compile_task.target.to_s
|
376
|
+
File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
|
377
|
+
compile_task.invoke
|
378
|
+
File.stat(compile_task.target.to_s).mtime.should be_close(Time.now - 10, 2)
|
379
|
+
end
|
380
|
+
|
381
|
+
it 'should not touch target if failed to compile' do
|
382
|
+
mkpath compile_task.target.to_s
|
383
|
+
File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
|
384
|
+
write 'failed.java', 'not a class'
|
385
|
+
suppress_stdout { compile_task.from('failed.java').invoke rescue nil }
|
386
|
+
File.stat(compile_task.target.to_s).mtime.should be_close(Time.now - 10, 2)
|
387
|
+
end
|
388
|
+
|
389
|
+
it 'should complain if source directories and no compiler selected' do
|
390
|
+
mkpath 'sources'
|
391
|
+
define 'bar' do
|
392
|
+
lambda { compile.from('sources').invoke }.should raise_error(RuntimeError, /no compiler selected/i)
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
|
398
|
+
describe 'accessor task', :shared=>true do
|
399
|
+
it 'should return a task' do
|
400
|
+
define('foo').send(@task_name).should be_kind_of(Rake::Task)
|
401
|
+
end
|
402
|
+
|
403
|
+
it 'should always return the same task' do
|
404
|
+
task_name, task = @task_name, nil
|
405
|
+
define('foo') { task = self.send(task_name) }
|
406
|
+
project('foo').send(task_name).should be(task)
|
407
|
+
end
|
408
|
+
|
409
|
+
it 'should be unique for the project' do
|
410
|
+
define('foo') { define 'bar' }
|
411
|
+
project('foo').send(@task_name).should_not eql(project('foo:bar').send(@task_name))
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'should be named after the project' do
|
415
|
+
define('foo') { define 'bar' }
|
416
|
+
project('foo:bar').send(@task_name).name.should eql("foo:bar:#{@task_name}")
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
|
421
|
+
describe Project, '#compile' do
|
422
|
+
before { @task_name = 'compile' }
|
423
|
+
it_should_behave_like 'accessor task'
|
424
|
+
|
425
|
+
it 'should return a compile task' do
|
426
|
+
define('foo').compile.should be_instance_of(CompileTask)
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should accept sources and add to source list' do
|
430
|
+
define('foo') { compile('file1', 'file2') }
|
431
|
+
project('foo').compile.sources.should include('file1', 'file2')
|
432
|
+
end
|
433
|
+
|
434
|
+
it 'should accept block and enhance task' do
|
435
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
436
|
+
action = task('action')
|
437
|
+
define('foo') { compile { action.invoke } }
|
438
|
+
lambda { project('foo').compile.invoke }.should run_tasks('foo:compile', action)
|
439
|
+
end
|
440
|
+
|
441
|
+
it 'should execute resources task' do
|
442
|
+
define 'foo'
|
443
|
+
lambda { project('foo').compile.invoke }.should run_task('foo:resources')
|
444
|
+
end
|
445
|
+
|
446
|
+
it 'should be recursive' do
|
447
|
+
write 'bar/src/main/java/Test.java', 'class Test {}'
|
448
|
+
define('foo') { define 'bar' }
|
449
|
+
lambda { project('foo').compile.invoke }.should run_task('foo:bar:compile')
|
450
|
+
end
|
451
|
+
|
452
|
+
it 'should be a local task' do
|
453
|
+
write 'bar/src/main/java/Test.java', 'class Test {}'
|
454
|
+
define('foo') { define 'bar' }
|
455
|
+
lambda do
|
456
|
+
in_original_dir project('foo:bar').base_dir do
|
457
|
+
task('compile').invoke
|
458
|
+
end
|
459
|
+
end.should run_task('foo:bar:compile').but_not('foo:compile')
|
460
|
+
end
|
461
|
+
|
462
|
+
it 'should run from build task' do
|
463
|
+
write 'bar/src/main/java/Test.java', 'class Test {}'
|
464
|
+
define('foo') { define 'bar' }
|
465
|
+
lambda { task('build').invoke }.should run_task('foo:bar:compile')
|
466
|
+
end
|
467
|
+
|
468
|
+
it 'should clean after itself' do
|
469
|
+
mkpath 'code'
|
470
|
+
define('foo') { compile.into('code') }
|
471
|
+
lambda { task('clean').invoke }.should change { File.exist?('code') }.to(false)
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
|
476
|
+
describe Project, '#resources' do
|
477
|
+
before { @task_name = 'resources' }
|
478
|
+
it_should_behave_like 'accessor task'
|
479
|
+
|
480
|
+
it 'should return a resources task' do
|
481
|
+
define('foo').resources.should be_instance_of(ResourcesTask)
|
482
|
+
end
|
483
|
+
|
484
|
+
it 'should provide a filter' do
|
485
|
+
define('foo').resources.filter.should be_instance_of(Filter)
|
486
|
+
end
|
487
|
+
|
488
|
+
it 'should include src/main/resources as source directory' do
|
489
|
+
write 'src/main/resources/test'
|
490
|
+
define('foo').resources.sources.first.should point_to_path('src/main/resources')
|
491
|
+
end
|
492
|
+
|
493
|
+
it 'should include src/main/resources directory only if it exists' do
|
494
|
+
define('foo').resources.sources.should be_empty
|
495
|
+
end
|
496
|
+
|
497
|
+
it 'should accept prerequisites' do
|
498
|
+
tasks = ['task1', 'task2'].each { |name| task(name) }
|
499
|
+
define('foo') { resources 'task1', 'task2' }
|
500
|
+
lambda { project('foo').resources.invoke }.should run_tasks('task1', 'task2')
|
501
|
+
end
|
502
|
+
|
503
|
+
it 'should respond to from and add additional sources' do
|
504
|
+
write 'src/main/resources/original'
|
505
|
+
write 'extra/spicy'
|
506
|
+
define('foo') { resources.from 'extra' }
|
507
|
+
project('foo').resources.invoke
|
508
|
+
FileList['target/resources/*'].sort.should == ['target/resources/original', 'target/resources/spicy']
|
509
|
+
end
|
510
|
+
|
511
|
+
it 'should pass include pattern to filter' do
|
512
|
+
3.times { |i| write "src/main/resources/test#{i + 1}" }
|
513
|
+
define('foo') { resources.include('test2') }
|
514
|
+
project('foo').resources.invoke
|
515
|
+
FileList['target/resources/*'].should == ['target/resources/test2']
|
516
|
+
end
|
517
|
+
|
518
|
+
it 'should pass exclude pattern to filter' do
|
519
|
+
3.times { |i| write "src/main/resources/test#{i + 1}" }
|
520
|
+
define('foo') { resources.exclude('test2') }
|
521
|
+
project('foo').resources.invoke
|
522
|
+
FileList['target/resources/*'].sort.should == ['target/resources/test1', 'target/resources/test3']
|
523
|
+
end
|
524
|
+
|
525
|
+
it 'should accept block and enhance task' do
|
526
|
+
action = task('action')
|
527
|
+
define('foo') { resources { action.invoke } }
|
528
|
+
lambda { project('foo').resources.invoke }.should run_tasks('foo:resources', action)
|
529
|
+
end
|
530
|
+
|
531
|
+
it 'should set target directory to target/resources' do
|
532
|
+
write 'src/main/resources/foo'
|
533
|
+
define('foo').resources.target.to_s.should point_to_path('target/resources')
|
534
|
+
end
|
535
|
+
|
536
|
+
it 'should use provided target directoy' do
|
537
|
+
define('foo') { resources.filter.into('the_resources') }
|
538
|
+
project('foo').resources.target.to_s.should point_to_path('the_resources')
|
539
|
+
end
|
540
|
+
|
541
|
+
it 'should create file task for target directory' do
|
542
|
+
write 'src/main/resources/foo'
|
543
|
+
define 'foo'
|
544
|
+
project('foo').file('target/resources').invoke
|
545
|
+
file('target/resources/foo').should exist
|
546
|
+
end
|
547
|
+
|
548
|
+
it 'should copy resources to target directory' do
|
549
|
+
write 'src/main/resources/foo', 'Foo'
|
550
|
+
define('foo').compile.invoke
|
551
|
+
file('target/resources/foo').should contain('Foo')
|
552
|
+
end
|
553
|
+
|
554
|
+
it 'should not create target directory unless there are resources' do
|
555
|
+
define('foo').compile.invoke
|
556
|
+
file('target/resources').should_not exist
|
557
|
+
end
|
558
|
+
|
559
|
+
it 'should run from target/resources' do
|
560
|
+
write 'src/main/resources/test'
|
561
|
+
define('foo')
|
562
|
+
lambda { project('foo').resources.target.invoke }.should change { File.exist?('target/resources/test') }.to(true)
|
563
|
+
end
|
564
|
+
|
565
|
+
it 'should not be recursive' do
|
566
|
+
define('foo') { define 'bar' }
|
567
|
+
lambda { project('foo').resources.invoke }.should_not run_task('foo:bar:resources')
|
568
|
+
end
|
569
|
+
|
570
|
+
it 'should use current profile for filtering' do
|
571
|
+
write 'profiles.yaml', <<-YAML
|
572
|
+
development:
|
573
|
+
filter:
|
574
|
+
foo: bar
|
575
|
+
test:
|
576
|
+
filter:
|
577
|
+
foo: baz
|
578
|
+
YAML
|
579
|
+
write 'src/main/resources/foo', '${foo}'
|
580
|
+
define('foo').compile.invoke
|
581
|
+
file('target/resources/foo').should contain('bar')
|
582
|
+
end
|
583
|
+
end
|