mguymon-buildr 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1291 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +44 -0
- data/_buildr +35 -0
- data/_jbuildr +35 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/bnd.rb +147 -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 +149 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jaxb_xjc.rb +72 -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 +88 -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/protobuf.rb +88 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +78 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +90 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +217 -0
- data/doc/building.textile +276 -0
- data/doc/contributing.textile +268 -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 +151 -0
- data/doc/extending.textile +212 -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 +109 -0
- data/doc/installing.textile +284 -0
- data/doc/languages.textile +599 -0
- data/doc/mailing_lists.textile +29 -0
- data/doc/more_stuff.textile +845 -0
- data/doc/packaging.textile +618 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +276 -0
- data/doc/quick_start.textile +210 -0
- data/doc/releasing.textile +117 -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 +73 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +287 -0
- data/doc/testing.textile +247 -0
- data/etc/KEYS +189 -0
- data/lib/buildr.rb +44 -0
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +34 -0
- data/lib/buildr/core/application.rb +700 -0
- data/lib/buildr/core/build.rb +516 -0
- data/lib/buildr/core/cc.rb +166 -0
- data/lib/buildr/core/checks.rb +253 -0
- data/lib/buildr/core/common.rb +151 -0
- data/lib/buildr/core/compile.rb +622 -0
- data/lib/buildr/core/doc.rb +276 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +404 -0
- data/lib/buildr/core/generate.rb +197 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +975 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/shell.rb +137 -0
- data/lib/buildr/core/test.rb +843 -0
- data/lib/buildr/core/transports.rb +575 -0
- data/lib/buildr/core/util.rb +537 -0
- data/lib/buildr/groovy.rb +20 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +153 -0
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +57 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +427 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/lib/buildr/ide/idea.rb +576 -0
- data/lib/buildr/java.rb +25 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +460 -0
- data/lib/buildr/java/cobertura.rb +297 -0
- data/lib/buildr/java/commands.rb +223 -0
- data/lib/buildr/java/compiler.rb +135 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/doc.rb +86 -0
- data/lib/buildr/java/ecj.rb +69 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/external.rb +73 -0
- data/lib/buildr/java/jruby.rb +122 -0
- data/lib/buildr/java/jtestr_result.rb +295 -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 +142 -0
- data/lib/buildr/java/packaging.rb +734 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +154 -0
- data/lib/buildr/java/test_result.rb +101 -0
- data/lib/buildr/java/tests.rb +362 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +25 -0
- data/lib/buildr/packaging/archive.rb +535 -0
- data/lib/buildr/packaging/artifact.rb +904 -0
- data/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +105 -0
- data/lib/buildr/packaging/package.rb +249 -0
- data/lib/buildr/packaging/repository_array.rb +108 -0
- data/lib/buildr/packaging/tar.rb +189 -0
- data/lib/buildr/packaging/version_requirement.rb +192 -0
- data/lib/buildr/packaging/zip.rb +178 -0
- data/lib/buildr/packaging/ziptask.rb +356 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/resources/completed.png +0 -0
- data/lib/buildr/resources/failed.png +0 -0
- data/lib/buildr/resources/icons-license.txt +17 -0
- data/lib/buildr/run.rb +195 -0
- data/lib/buildr/scala.rb +26 -0
- data/lib/buildr/scala/bdd.rb +118 -0
- data/lib/buildr/scala/compiler.rb +242 -0
- data/lib/buildr/scala/doc.rb +142 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +52 -0
- data/lib/buildr/scala/tests.rb +171 -0
- data/lib/buildr/shell.rb +185 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +137 -0
- data/rakelib/metrics.rake +39 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +160 -0
- data/rakelib/rspec.rake +91 -0
- data/rakelib/setup.rake +66 -0
- data/rakelib/stage.rake +220 -0
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +631 -0
- data/spec/core/build_spec.rb +837 -0
- data/spec/core/cc_spec.rb +224 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +725 -0
- data/spec/core/compile_spec.rb +658 -0
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/extension_spec.rb +201 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +772 -0
- data/spec/core/run_spec.rb +93 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/core/test_spec.rb +1320 -0
- data/spec/core/transport_spec.rb +544 -0
- data/spec/core/util_spec.rb +141 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +251 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +739 -0
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/ant_spec.rb +37 -0
- data/spec/java/bdd_spec.rb +374 -0
- data/spec/java/cobertura_spec.rb +112 -0
- data/spec/java/commands_spec.rb +93 -0
- data/spec/java/compiler_spec.rb +252 -0
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/ecj_spec.rb +115 -0
- data/spec/java/emma_spec.rb +121 -0
- data/spec/java/external_spec.rb +56 -0
- data/spec/java/java_spec.rb +132 -0
- data/spec/java/packaging_spec.rb +1266 -0
- data/spec/java/run_spec.rb +78 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +497 -0
- data/spec/packaging/archive_spec.rb +775 -0
- data/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/spec/packaging/artifact_spec.rb +1074 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +719 -0
- data/spec/packaging/repository_array_spec.rb +109 -0
- data/spec/sandbox.rb +165 -0
- data/spec/scala/bdd_spec.rb +124 -0
- data/spec/scala/compiler_spec.rb +289 -0
- data/spec/scala/doc_spec.rb +88 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +283 -0
- data/spec/spec_helpers.rb +369 -0
- data/spec/version_requirement_spec.rb +143 -0
- data/spec/xpath_matchers.rb +121 -0
- metadata +649 -0
@@ -0,0 +1,658 @@
|
|
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.expand_path(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 compile_task_without_compiler
|
26
|
+
@compile_task ||= define('foo').compile
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_task
|
30
|
+
@file_taks ||= define('bar').file('src')
|
31
|
+
end
|
32
|
+
|
33
|
+
def sources
|
34
|
+
@sources ||= ['Test1.java', 'Test2.java'].map { |f| File.join('src/main/java/thepackage', f) }.
|
35
|
+
each { |src| write src, "package thepackage; class #{src.pathmap('%n')} {}" }
|
36
|
+
end
|
37
|
+
|
38
|
+
def jars
|
39
|
+
@jars ||= begin
|
40
|
+
write 'jars/src/main/java/Dependency.java', 'class Dependency { }'
|
41
|
+
define 'jars', :version=>'1.0', :base_dir => 'jars' do
|
42
|
+
package(:jar, :id=>'jar1')
|
43
|
+
package(:jar, :id=>'jar2')
|
44
|
+
end
|
45
|
+
project('jars').packages.map(&:to_s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe Buildr::CompileTask do
|
52
|
+
include CompilerHelper
|
53
|
+
|
54
|
+
it 'should respond to from() and return self' do
|
55
|
+
compile_task.from(sources).should be(compile_task)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should respond to from() with FileTask having no compiler set and return self' do
|
59
|
+
compile_task_without_compiler.from(file_task).should be(compile_task)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should respond to from() and add sources' do
|
63
|
+
compile_task.from sources, File.dirname(sources.first)
|
64
|
+
compile_task.sources.should == sources + [File.dirname(sources.first)]
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should respond to with() and return self' do
|
68
|
+
compile_task.with('test.jar').should be(compile_task)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should respond to with() and add dependencies' do
|
72
|
+
jars = (1..3).map { |i| "test#{i}.jar" }
|
73
|
+
compile_task.with *jars
|
74
|
+
compile_task.dependencies.should == artifacts(jars)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should respond to into() and return self' do
|
78
|
+
compile_task.into('code').should be(compile_task)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should respond to into() and create file task' do
|
82
|
+
compile_task.from(sources).into('code')
|
83
|
+
lambda { file('code').invoke }.should run_task('foo:compile')
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should respond to using() and return self' do
|
87
|
+
compile_task.using(:source=>'1.4').should eql(compile_task)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should respond to using() and set options' do
|
91
|
+
compile_task.using(:source=>'1.4', 'target'=>'1.5')
|
92
|
+
compile_task.options.source.should eql('1.4')
|
93
|
+
compile_task.options.target.should eql('1.5')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should attempt to identify compiler' do
|
97
|
+
Compiler.compilers.first.should_receive(:applies_to?).at_least(:once)
|
98
|
+
define('foo')
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should only support existing compilers' do
|
102
|
+
lambda { define('foo') { compile.using(:unknown) } }.should raise_error(ArgumentError, /unknown compiler/i)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should allow overriding the guessed compiler' do
|
106
|
+
write "src/main/java/com/example/Hello.java", ""
|
107
|
+
old_compiler = nil
|
108
|
+
new_compiler = nil
|
109
|
+
define('foo') {
|
110
|
+
old_compiler = compile.compiler
|
111
|
+
compile.using(:scalac)
|
112
|
+
new_compiler = compile.compiler
|
113
|
+
}
|
114
|
+
old_compiler.should == :javac
|
115
|
+
new_compiler.should == :scalac
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
describe Buildr::CompileTask, '#compiler' do
|
121
|
+
it 'should be nil if no compiler identifier' do
|
122
|
+
define('foo').compile.compiler.should be_nil
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should return the selected compiler' do
|
126
|
+
define('foo') { compile.using(:javac) }
|
127
|
+
project('foo').compile.compiler.should eql(:javac)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should attempt to identify compiler if sources are specified' do
|
131
|
+
define 'foo' do
|
132
|
+
Compiler.compilers.first.should_receive(:applies_to?).at_least(:once)
|
133
|
+
compile.from('sources').compiler
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should allow supressing compilation' do
|
138
|
+
write 'src/main/java/package/Test.java', 'class Test {}'
|
139
|
+
define 'foo' do
|
140
|
+
compile.sources.clear
|
141
|
+
end
|
142
|
+
project('foo').compile.invoke
|
143
|
+
Dir['target/classes/*'].should be_empty
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
describe Buildr::CompileTask, '#language' do
|
149
|
+
it 'should be nil if no compiler identifier' do
|
150
|
+
define('foo').compile.language.should be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should return the appropriate language' do
|
154
|
+
define('foo') { compile.using(:javac) }
|
155
|
+
project('foo').compile.language.should eql(:java)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
describe Buildr::CompileTask, '#sources' do
|
161
|
+
include CompilerHelper
|
162
|
+
|
163
|
+
it 'should be empty if no sources in default directory' do
|
164
|
+
compile_task.sources.should be_empty
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should point to default directory if it contains sources' do
|
168
|
+
write 'src/main/java', ''
|
169
|
+
compile_task.sources.first.should point_to_path('src/main/java')
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should be an array' do
|
173
|
+
compile_task.sources += sources
|
174
|
+
compile_task.sources.should == sources
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should allow files' do
|
178
|
+
compile_task.from(sources).into('classes').invoke
|
179
|
+
sources.each { |src| file(src.pathmap('classes/thepackage/%n.class')).should exist }
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should allow directories' do
|
183
|
+
compile_task.from(File.dirname(sources.first)).into('classes').invoke
|
184
|
+
sources.each { |src| file(src.pathmap('classes/thepackage/%n.class')).should exist }
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should allow tasks' do
|
188
|
+
lambda { compile_task.from(file(sources.first)).into('classes').invoke }.should run_task('foo:compile')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should act as prerequisites' do
|
192
|
+
file('src2') { |task| task('prereq').invoke ; mkpath task.name }
|
193
|
+
lambda { compile_task.from('src2').into('classes').invoke }.should run_task('prereq')
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
describe Buildr::CompileTask, '#dependencies' do
|
199
|
+
include CompilerHelper
|
200
|
+
|
201
|
+
it 'should be empty' do
|
202
|
+
compile_task.dependencies.should be_empty
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should be an array' do
|
206
|
+
compile_task.dependencies += jars
|
207
|
+
compile_task.dependencies.should == jars
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should allow files' do
|
211
|
+
compile_task.from(sources).with(jars).into('classes').invoke
|
212
|
+
sources.each { |src| file(src.pathmap('classes/thepackage/%n.class')).should exist }
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should allow tasks' do
|
216
|
+
compile_task.from(sources).with(file(jars.first)).into('classes').invoke
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should allow artifacts' do
|
220
|
+
artifact('group:id:jar:1.0') { |task| mkpath File.dirname(task.to_s) ; cp jars.first.to_s, task.to_s }.enhance jars
|
221
|
+
compile_task.from(sources).with('group:id:jar:1.0').into('classes').invoke
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should allow projects' do
|
225
|
+
define('bar', :version=>'1', :group=>'self') { package :jar }
|
226
|
+
compile_task.with project('bar')
|
227
|
+
compile_task.dependencies.should == project('bar').packages
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'should be accessible as classpath up to version 1.5 since it was deprecated in version 1.3' do
|
231
|
+
Buildr::VERSION.should < '1.5'
|
232
|
+
lambda { compile_task.classpath = jars }.should change(compile_task, :dependencies).to(jars)
|
233
|
+
lambda { compile_task.dependencies = [] }.should change(compile_task, :classpath).to([])
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
describe Buildr::CompileTask, '#target' do
|
240
|
+
include CompilerHelper
|
241
|
+
|
242
|
+
it 'should be a file task' do
|
243
|
+
compile_task.from(@sources).into('classes')
|
244
|
+
compile_task.target.should be_kind_of(Rake::FileTask)
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should accept a task' do
|
248
|
+
task = file('classes')
|
249
|
+
compile_task.into(task).target.should be(task)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should create dependency in file task when set' do
|
253
|
+
compile_task.from(sources).into('classes')
|
254
|
+
lambda { file('classes').invoke }.should run_task('foo:compile')
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
describe Buildr::CompileTask, '#options' do
|
260
|
+
include CompilerHelper
|
261
|
+
|
262
|
+
it 'should have getter and setter methods' do
|
263
|
+
compile_task.options.foo = 'bar'
|
264
|
+
compile_task.options.foo.should eql('bar')
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'should have bracket accessors' do
|
268
|
+
compile_task.options[:foo] = 'bar'
|
269
|
+
compile_task.options[:foo].should eql('bar')
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'should map from bracket accessor to get/set accessor' do
|
273
|
+
compile_task.options[:foo] = 'bar'
|
274
|
+
compile_task.options.foo.should eql('bar')
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should be independent of parent' do
|
278
|
+
define 'foo' do
|
279
|
+
compile.using(:javac, :source=>'1.4')
|
280
|
+
define 'bar' do
|
281
|
+
compile.using(:javac, :source=>'1.5')
|
282
|
+
end
|
283
|
+
end
|
284
|
+
project('foo').compile.options.source.should eql('1.4')
|
285
|
+
project('foo:bar').compile.options.source.should eql('1.5')
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
describe Buildr::CompileTask, '#invoke' do
|
291
|
+
include CompilerHelper
|
292
|
+
|
293
|
+
it 'should compile into target directory' do
|
294
|
+
compile_task.from(sources).into('code').invoke
|
295
|
+
Dir['code/thepackage/*.class'].should_not be_empty
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should compile only once' do
|
299
|
+
compile_task.from(sources)
|
300
|
+
lambda { compile_task.target.invoke }.should run_task('foo:compile')
|
301
|
+
lambda { compile_task.invoke }.should_not run_task('foo:compile')
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should compile if there are source files to compile' do
|
305
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'should not compile unless there are source files to compile' do
|
309
|
+
lambda { compile_task.invoke }.should_not run_task('foo:compile')
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'should require source file or directory to exist' do
|
313
|
+
lambda { compile_task.from('empty').into('classes').invoke }.should raise_error(RuntimeError, /Don't know how to build/)
|
314
|
+
end
|
315
|
+
|
316
|
+
it 'should run all source files as prerequisites' do
|
317
|
+
mkpath 'src'
|
318
|
+
file('src').should_receive :invoke_prerequisites
|
319
|
+
compile_task.from('src').invoke
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'should require dependencies to exist' do
|
323
|
+
lambda { compile_task.from(sources).with('no-such.jar').into('classes').invoke }.should \
|
324
|
+
raise_error(RuntimeError, /Don't know how to build/)
|
325
|
+
end
|
326
|
+
|
327
|
+
it 'should run all dependencies as prerequisites' do
|
328
|
+
file(File.expand_path('no-such.jar')) { |task| task('prereq').invoke }
|
329
|
+
lambda { compile_task.from(sources).with('no-such.jar').into('classes').invoke }.should run_tasks(['prereq', 'foo:compile'])
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'should force compilation if no target' do
|
333
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should force compilation if target empty' do
|
337
|
+
time = Time.now
|
338
|
+
mkpath compile_task.target.to_s
|
339
|
+
File.utime(time - 1, time - 1, compile_task.target.to_s)
|
340
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'should force compilation if sources newer than compiled' do
|
344
|
+
# Simulate class files that are older than source files.
|
345
|
+
time = Time.now
|
346
|
+
sources.each { |src| File.utime(time + 1, time + 1, src) }
|
347
|
+
sources.map { |src| src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
348
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
349
|
+
File.utime(time - 1, time - 1, project('foo').compile.target.to_s)
|
350
|
+
lambda { compile_task.from(sources).invoke }.should run_task('foo:compile')
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'should not force compilation if sources older than compiled' do
|
354
|
+
# When everything has the same timestamp, nothing is compiled again.
|
355
|
+
time = Time.now
|
356
|
+
sources.map { |src| src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
357
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
358
|
+
lambda { compile_task.from(sources).invoke }.should_not run_task('foo:compile')
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should not force compilation if dependencies older than compiled' do
|
362
|
+
jars; project('jars').task("package").invoke
|
363
|
+
time = Time.now
|
364
|
+
jars.each { |jar| File.utime(time - 1 , time - 1, jar) }
|
365
|
+
sources.map { |src| File.utime(time, time, src); src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
366
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
367
|
+
lambda { compile_task.from(sources).with(jars).invoke }.should_not run_task('foo:compile')
|
368
|
+
end
|
369
|
+
|
370
|
+
it 'should force compilation if dependencies newer than compiled' do
|
371
|
+
jars; project('jars').task("package").invoke
|
372
|
+
# On my machine the times end up the same, so need to push dependencies in the past.
|
373
|
+
time = Time.now
|
374
|
+
sources.map { |src| src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
375
|
+
each { |kls| write kls ; File.utime(time - 1, time - 1, kls) }
|
376
|
+
File.utime(time - 1, time - 1, project('foo').compile.target.to_s)
|
377
|
+
jars.each { |jar| File.utime(time + 1, time + 1, jar) }
|
378
|
+
lambda { compile_task.from(sources).with(jars).invoke }.should run_task('foo:compile')
|
379
|
+
end
|
380
|
+
|
381
|
+
it 'should timestamp target directory if specified' do
|
382
|
+
time = Time.now - 10
|
383
|
+
mkpath compile_task.target.to_s
|
384
|
+
File.utime(time, time, compile_task.target.to_s)
|
385
|
+
compile_task.timestamp.should be_close(time, 1)
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'should touch target if anything compiled' do
|
389
|
+
mkpath compile_task.target.to_s
|
390
|
+
File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
|
391
|
+
compile_task.from(sources).invoke
|
392
|
+
File.stat(compile_task.target.to_s).mtime.should be_close(Time.now, 2)
|
393
|
+
end
|
394
|
+
|
395
|
+
it 'should not touch target if nothing compiled' do
|
396
|
+
mkpath compile_task.target.to_s
|
397
|
+
File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
|
398
|
+
compile_task.invoke
|
399
|
+
File.stat(compile_task.target.to_s).mtime.should be_close(Time.now - 10, 2)
|
400
|
+
end
|
401
|
+
|
402
|
+
it 'should not touch target if failed to compile' do
|
403
|
+
mkpath compile_task.target.to_s
|
404
|
+
File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
|
405
|
+
write 'failed.java', 'not a class'
|
406
|
+
suppress_stdout { compile_task.from('failed.java').invoke rescue nil }
|
407
|
+
File.stat(compile_task.target.to_s).mtime.should be_close(Time.now - 10, 2)
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'should complain if source directories and no compiler selected' do
|
411
|
+
mkpath 'sources'
|
412
|
+
define 'bar' do
|
413
|
+
lambda { compile.from('sources').invoke }.should raise_error(RuntimeError, /no compiler selected/i)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
|
419
|
+
shared_examples_for 'accessor task' do
|
420
|
+
it 'should return a task' do
|
421
|
+
define('foo').send(@task_name).should be_kind_of(Rake::Task)
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'should always return the same task' do
|
425
|
+
task_name, task = @task_name, nil
|
426
|
+
define('foo') { task = self.send(task_name) }
|
427
|
+
project('foo').send(task_name).should be(task)
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should be unique for the project' do
|
431
|
+
define('foo') { define 'bar' }
|
432
|
+
project('foo').send(@task_name).should_not eql(project('foo:bar').send(@task_name))
|
433
|
+
end
|
434
|
+
|
435
|
+
it 'should be named after the project' do
|
436
|
+
define('foo') { define 'bar' }
|
437
|
+
project('foo:bar').send(@task_name).name.should eql("foo:bar:#{@task_name}")
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
|
442
|
+
describe Project, '#compile' do
|
443
|
+
before { @task_name = 'compile' }
|
444
|
+
it_should_behave_like 'accessor task'
|
445
|
+
|
446
|
+
it 'should return a compile task' do
|
447
|
+
define('foo').compile.should be_instance_of(CompileTask)
|
448
|
+
end
|
449
|
+
|
450
|
+
it 'should accept sources and add to source list' do
|
451
|
+
define('foo') { compile('file1', 'file2') }
|
452
|
+
project('foo').compile.sources.should include('file1', 'file2')
|
453
|
+
end
|
454
|
+
|
455
|
+
it 'should accept block and enhance task' do
|
456
|
+
write 'src/main/java/Test.java', 'class Test {}'
|
457
|
+
action = task('action')
|
458
|
+
define('foo') { compile { action.invoke } }
|
459
|
+
lambda { project('foo').compile.invoke }.should run_tasks('foo:compile', action)
|
460
|
+
end
|
461
|
+
|
462
|
+
it 'should execute resources task' do
|
463
|
+
define 'foo'
|
464
|
+
lambda { project('foo').compile.invoke }.should run_task('foo:resources')
|
465
|
+
end
|
466
|
+
|
467
|
+
it 'should be recursive' do
|
468
|
+
write 'bar/src/main/java/Test.java', 'class Test {}'
|
469
|
+
define('foo') { define 'bar' }
|
470
|
+
lambda { project('foo').compile.invoke }.should run_task('foo:bar:compile')
|
471
|
+
end
|
472
|
+
|
473
|
+
it 'should be a local task' do
|
474
|
+
write 'bar/src/main/java/Test.java', 'class Test {}'
|
475
|
+
define('foo') { define 'bar' }
|
476
|
+
lambda do
|
477
|
+
in_original_dir project('foo:bar').base_dir do
|
478
|
+
task('compile').invoke
|
479
|
+
end
|
480
|
+
end.should run_task('foo:bar:compile').but_not('foo:compile')
|
481
|
+
end
|
482
|
+
|
483
|
+
it 'should run from build task' do
|
484
|
+
write 'bar/src/main/java/Test.java', 'class Test {}'
|
485
|
+
define('foo') { define 'bar' }
|
486
|
+
lambda { task('build').invoke }.should run_task('foo:bar:compile')
|
487
|
+
end
|
488
|
+
|
489
|
+
it 'should clean after itself' do
|
490
|
+
mkpath 'code'
|
491
|
+
define('foo') { compile.into('code') }
|
492
|
+
lambda { task('clean').invoke }.should change { File.exist?('code') }.to(false)
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
|
497
|
+
describe Project, '#resources' do
|
498
|
+
before { @task_name = 'resources' }
|
499
|
+
it_should_behave_like 'accessor task'
|
500
|
+
|
501
|
+
it 'should return a resources task' do
|
502
|
+
define('foo').resources.should be_instance_of(ResourcesTask)
|
503
|
+
end
|
504
|
+
|
505
|
+
it 'should provide a filter' do
|
506
|
+
define('foo').resources.filter.should be_instance_of(Filter)
|
507
|
+
end
|
508
|
+
|
509
|
+
it 'should include src/main/resources as source directory' do
|
510
|
+
write 'src/main/resources/test'
|
511
|
+
define('foo').resources.sources.first.should point_to_path('src/main/resources')
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'should include src/main/resources directory only if it exists' do
|
515
|
+
define('foo').resources.sources.should be_empty
|
516
|
+
end
|
517
|
+
|
518
|
+
it 'should accept prerequisites' do
|
519
|
+
tasks = ['task1', 'task2'].each { |name| task(name) }
|
520
|
+
define('foo') { resources 'task1', 'task2' }
|
521
|
+
lambda { project('foo').resources.invoke }.should run_tasks('task1', 'task2')
|
522
|
+
end
|
523
|
+
|
524
|
+
it 'should respond to from and add additional sources' do
|
525
|
+
write 'src/main/resources/original'
|
526
|
+
write 'extra/spicy'
|
527
|
+
define('foo') { resources.from 'extra' }
|
528
|
+
project('foo').resources.invoke
|
529
|
+
FileList['target/resources/*'].sort.should == ['target/resources/original', 'target/resources/spicy']
|
530
|
+
end
|
531
|
+
|
532
|
+
it 'should pass include pattern to filter' do
|
533
|
+
3.times { |i| write "src/main/resources/test#{i + 1}" }
|
534
|
+
define('foo') { resources.include('test2') }
|
535
|
+
project('foo').resources.invoke
|
536
|
+
FileList['target/resources/*'].should == ['target/resources/test2']
|
537
|
+
end
|
538
|
+
|
539
|
+
it 'should pass exclude pattern to filter' do
|
540
|
+
3.times { |i| write "src/main/resources/test#{i + 1}" }
|
541
|
+
define('foo') { resources.exclude('test2') }
|
542
|
+
project('foo').resources.invoke
|
543
|
+
FileList['target/resources/*'].sort.should == ['target/resources/test1', 'target/resources/test3']
|
544
|
+
end
|
545
|
+
|
546
|
+
it 'should accept block and enhance task' do
|
547
|
+
action = task('action')
|
548
|
+
define('foo') { resources { action.invoke } }
|
549
|
+
lambda { project('foo').resources.invoke }.should run_tasks('foo:resources', action)
|
550
|
+
end
|
551
|
+
|
552
|
+
it 'should set target directory to target/resources' do
|
553
|
+
write 'src/main/resources/foo'
|
554
|
+
define('foo').resources.target.to_s.should point_to_path('target/resources')
|
555
|
+
end
|
556
|
+
|
557
|
+
it 'should use provided target directoy' do
|
558
|
+
define('foo') { resources.filter.into('the_resources') }
|
559
|
+
project('foo').resources.target.to_s.should point_to_path('the_resources')
|
560
|
+
end
|
561
|
+
|
562
|
+
it 'should create file task for target directory' do
|
563
|
+
write 'src/main/resources/foo'
|
564
|
+
define 'foo'
|
565
|
+
project('foo').file('target/resources').invoke
|
566
|
+
file('target/resources/foo').should exist
|
567
|
+
end
|
568
|
+
|
569
|
+
it 'should copy resources to target directory' do
|
570
|
+
write 'src/main/resources/foo', 'Foo'
|
571
|
+
define('foo').compile.invoke
|
572
|
+
file('target/resources/foo').should contain('Foo')
|
573
|
+
end
|
574
|
+
|
575
|
+
it 'should copy new resources to target directory' do
|
576
|
+
time = Time.now
|
577
|
+
mkdir_p 'target/resources'
|
578
|
+
File.utime(time-1, time-1, 'target/resources')
|
579
|
+
|
580
|
+
write 'src/main/resources/foo', 'Foo'
|
581
|
+
|
582
|
+
define('foo')
|
583
|
+
project('foo').file('target/resources').invoke
|
584
|
+
file('target/resources/foo').should exist
|
585
|
+
end
|
586
|
+
|
587
|
+
it 'should copy updated resources to target directory' do
|
588
|
+
time = Time.now
|
589
|
+
mkdir_p 'target/resources'
|
590
|
+
write 'target/resources/foo', 'Foo'
|
591
|
+
File.utime(time-1, time-1, 'target/resources')
|
592
|
+
File.utime(time-1, time-1, 'target/resources/foo')
|
593
|
+
|
594
|
+
write 'src/main/resources/foo', 'Foo2'
|
595
|
+
define('foo')
|
596
|
+
project('foo').file('target/resources').invoke
|
597
|
+
file('target/resources/foo').should contain('Foo2')
|
598
|
+
end
|
599
|
+
|
600
|
+
it 'should not create target directory unless there are resources' do
|
601
|
+
define('foo').compile.invoke
|
602
|
+
file('target/resources').should_not exist
|
603
|
+
end
|
604
|
+
|
605
|
+
it 'should run from target/resources' do
|
606
|
+
write 'src/main/resources/test'
|
607
|
+
define('foo')
|
608
|
+
lambda { project('foo').resources.target.invoke }.should change { File.exist?('target/resources/test') }.to(true)
|
609
|
+
end
|
610
|
+
|
611
|
+
it 'should not be recursive' do
|
612
|
+
define('foo') { define 'bar' }
|
613
|
+
lambda { project('foo').resources.invoke }.should_not run_task('foo:bar:resources')
|
614
|
+
end
|
615
|
+
|
616
|
+
it 'should use current profile for filtering' do
|
617
|
+
write 'profiles.yaml', <<-YAML
|
618
|
+
development:
|
619
|
+
filter:
|
620
|
+
foo: bar
|
621
|
+
test:
|
622
|
+
filter:
|
623
|
+
foo: baz
|
624
|
+
YAML
|
625
|
+
write 'src/main/resources/foo', '${foo}'
|
626
|
+
define('foo').compile.invoke
|
627
|
+
file('target/resources/foo').should contain('bar')
|
628
|
+
end
|
629
|
+
|
630
|
+
it 'should use current profile as default for filtering' do
|
631
|
+
write 'profiles.yaml', <<-YAML
|
632
|
+
development:
|
633
|
+
filter:
|
634
|
+
foo: bar
|
635
|
+
YAML
|
636
|
+
write 'src/main/resources/foo', '${foo} ${baz}'
|
637
|
+
define('foo') do
|
638
|
+
resources.filter.using 'baz' => 'qux'
|
639
|
+
end
|
640
|
+
project('foo').compile.invoke
|
641
|
+
file('target/resources/foo').should contain('bar qux')
|
642
|
+
end
|
643
|
+
|
644
|
+
it 'should allow clearing default filter mapping' do
|
645
|
+
write 'profiles.yaml', <<-YAML
|
646
|
+
development:
|
647
|
+
filter:
|
648
|
+
foo: bar
|
649
|
+
YAML
|
650
|
+
write 'src/main/resources/foo', '${foo} ${baz}'
|
651
|
+
define('foo') do
|
652
|
+
resources.filter.mapping.clear
|
653
|
+
resources.filter.using 'baz' => 'qux'
|
654
|
+
end
|
655
|
+
project('foo').compile.invoke
|
656
|
+
file('target/resources/foo').should contain('${foo} qux')
|
657
|
+
end
|
658
|
+
end
|