buildr 1.4.5-x86-mswin32 → 1.4.6-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +28 -1
- data/_buildr +1 -1
- data/_jbuildr +1 -1
- data/buildr.gemspec +1 -2
- data/doc/download.textile +41 -76
- data/doc/index.textile +46 -6
- data/doc/installing.textile +2 -2
- data/doc/languages.textile +3 -3
- data/doc/scripts/install-jruby.sh +2 -2
- data/lib/buildr/core/shell.rb +1 -1
- data/lib/buildr/core/transports.rb +1 -1
- data/lib/buildr/ide/eclipse.rb +8 -2
- data/lib/buildr/ide/idea.rb +42 -26
- data/lib/buildr/java/bdd.rb +8 -5
- data/lib/buildr/java/jtestr_result.rb +36 -0
- data/lib/buildr/java/tests.rb +4 -4
- data/lib/buildr/packaging/artifact.rb +4 -2
- data/lib/buildr/packaging/tar.rb +1 -1
- data/lib/buildr/packaging/zip.rb +6 -0
- data/lib/buildr/scala/bdd.rb +17 -4
- data/lib/buildr/scala/compiler.rb +18 -12
- data/lib/buildr/scala/doc.rb +1 -1
- data/lib/buildr/scala/tests.rb +40 -11
- data/lib/buildr/version.rb +1 -1
- data/rakelib/checks.rake +9 -9
- data/rakelib/doc.rake +1 -1
- data/rakelib/package.rake +7 -7
- data/rakelib/release.rake +0 -1
- data/rakelib/rspec.rake +3 -2
- data/rakelib/setup.rake +2 -0
- data/rakelib/stage.rake +3 -3
- data/spec/core/common_spec.rb +1 -1
- data/spec/ide/idea_spec.rb +16 -25
- data/spec/java/bdd_spec.rb +1 -1
- data/spec/packaging/artifact_spec.rb +51 -0
- data/spec/sandbox.rb +41 -5
- data/spec/scala/bdd_spec.rb +1 -6
- data/spec/scala/compiler_spec.rb +56 -24
- data/spec/scala/doc_spec.rb +2 -7
- data/spec/scala/scala.rb +1 -8
- data/spec/scala/tests_spec.rb +14 -6
- metadata +164 -169
- data/lib/buildr/core/#application.rb# +0 -700
- data/lib/buildr/packaging/#package.rb.rej# +0 -19
- data/lib/buildr/scala/#Untitled-2# +0 -7
@@ -1,700 +0,0 @@
|
|
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
|
-
# Portion of this file derived from Rake.
|
18
|
-
# Copyright (c) 2003, 2004 Jim Weirich
|
19
|
-
#
|
20
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
21
|
-
# of this software and associated documentation files (the "Software"), to deal
|
22
|
-
# in the Software without restriction, including without limitation the rights
|
23
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
24
|
-
# copies of the Software, and to permit persons to whom the Software is
|
25
|
-
# furnished to do so, subject to the following conditions:
|
26
|
-
#
|
27
|
-
# The above copyright notice and this permission notice shall be included in
|
28
|
-
# all copies or substantial portions of the Software.
|
29
|
-
#
|
30
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
31
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
32
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
33
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
34
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
35
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
36
|
-
# SOFTWARE.
|
37
|
-
|
38
|
-
|
39
|
-
require 'rake'
|
40
|
-
require 'highline/import'
|
41
|
-
require 'rubygems/source_info_cache' if Gem::VERSION =~ /1.[0-4]/
|
42
|
-
require 'buildr/core/util'
|
43
|
-
Gem.autoload :SourceInfoCache, 'rubygems/source_info_cache' if Gem::VERSION =~ /1.[0-4]2/
|
44
|
-
|
45
|
-
|
46
|
-
# Gem::user_home is nice, but ENV['HOME'] lets you override from the environment.
|
47
|
-
ENV['HOME'] ||= File.expand_path(Gem::user_home)
|
48
|
-
ENV['BUILDR_ENV'] ||= 'development'
|
49
|
-
|
50
|
-
|
51
|
-
module Buildr
|
52
|
-
|
53
|
-
# Provide settings that come from three sources.
|
54
|
-
#
|
55
|
-
# User settings are placed in the .buildr/settings.yaml file located in the user's home directory.
|
56
|
-
# They should only be used for settings that are specific to the user and applied the same way
|
57
|
-
# across all builds. Example for user settings are preferred repositories, path to local repository,
|
58
|
-
# user/name password for uploading to remote repository.
|
59
|
-
#
|
60
|
-
# Build settings are placed in the build.yaml file located in the build directory. They help keep
|
61
|
-
# the buildfile and build.yaml file simple and readable, working to the advantages of each one.
|
62
|
-
# Example for build settings are gems, repositories and artifacts used by that build.
|
63
|
-
#
|
64
|
-
# Profile settings are placed in the profiles.yaml file located in the build directory. They provide
|
65
|
-
# settings that differ in each environment the build runs in. For example, URLs and database
|
66
|
-
# connections will be different when used in development, test and production environments.
|
67
|
-
# The settings for the current environment are obtained by calling #profile.
|
68
|
-
class Settings
|
69
|
-
|
70
|
-
def initialize(application) #:nodoc:
|
71
|
-
@application = application
|
72
|
-
end
|
73
|
-
|
74
|
-
# User settings loaded from setting.yaml file in user's home directory.
|
75
|
-
def user
|
76
|
-
@user ||= load_from('settings', @application.home_dir)
|
77
|
-
end
|
78
|
-
|
79
|
-
# Build settings loaded from build.yaml file in build directory.
|
80
|
-
def build
|
81
|
-
@build ||= load_from('build')
|
82
|
-
end
|
83
|
-
|
84
|
-
# Profiles loaded from profiles.yaml file in build directory.
|
85
|
-
def profiles
|
86
|
-
@profiles ||= load_from('profiles')
|
87
|
-
end
|
88
|
-
|
89
|
-
# :call-seq:
|
90
|
-
# profile => hash
|
91
|
-
#
|
92
|
-
# Returns the profile for the current environment.
|
93
|
-
def profile
|
94
|
-
profiles[@application.environment] ||= {}
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
def load_from(name, path = nil)
|
100
|
-
unless path
|
101
|
-
fail "Internal error: attempting to access local setting before buildfile located" unless @application.rakefile
|
102
|
-
path = File.dirname(@application.rakefile)
|
103
|
-
end
|
104
|
-
file_name = ['yaml', 'yml'].map { |ext| File.join(path, "#{name}.#{ext}") }.find { |fn| File.exist?(fn) }
|
105
|
-
return {} unless file_name
|
106
|
-
yaml = YAML.load(File.read(file_name)) || {}
|
107
|
-
fail "Expecting #{file_name} to be a map (name: value)!" unless Hash === yaml
|
108
|
-
@application.buildfile.enhance [file_name]
|
109
|
-
yaml
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
class Application < Rake::Application #:nodoc:
|
116
|
-
|
117
|
-
# Deprecated: rakefile/Rakefile, removed in 1.5
|
118
|
-
DEFAULT_BUILDFILES = ['buildfile', 'Buildfile', 'buildfile.rb', 'Buildfile.rb'] + DEFAULT_RAKEFILES
|
119
|
-
|
120
|
-
attr_reader :rakefiles, :requires
|
121
|
-
private :rakefiles, :requires
|
122
|
-
|
123
|
-
def initialize
|
124
|
-
super
|
125
|
-
@rakefiles = DEFAULT_BUILDFILES.dup
|
126
|
-
@top_level_tasks = []
|
127
|
-
@home_dir = File.expand_path('.buildr', ENV['HOME'])
|
128
|
-
mkpath @home_dir if !File.exist?(@home_dir) && File.writable?(ENV['HOME'])
|
129
|
-
@settings = Settings.new(self)
|
130
|
-
@on_completion = []
|
131
|
-
@on_failure = []
|
132
|
-
end
|
133
|
-
|
134
|
-
def run
|
135
|
-
standard_exception_handling do
|
136
|
-
init 'Buildr'
|
137
|
-
load_buildfile
|
138
|
-
top_level
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
# Not for external consumption.
|
143
|
-
def switch_to_namespace(names) #:nodoc:
|
144
|
-
current, @scope = @scope, names
|
145
|
-
begin
|
146
|
-
yield
|
147
|
-
ensure
|
148
|
-
@scope = current
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
# Returns list of Gems associated with this buildfile, as listed in build.yaml.
|
153
|
-
# Each entry is of type Gem::Specification.
|
154
|
-
attr_reader :gems
|
155
|
-
|
156
|
-
# Buildr home directory, .buildr under user's home directory.
|
157
|
-
attr_reader :home_dir
|
158
|
-
|
159
|
-
# Copied from BUILD_ENV.
|
160
|
-
def environment
|
161
|
-
ENV['BUILDR_ENV']
|
162
|
-
end
|
163
|
-
|
164
|
-
# Returns the Settings associated with this build.
|
165
|
-
attr_reader :settings
|
166
|
-
|
167
|
-
# :call-seq:
|
168
|
-
# buildfile
|
169
|
-
# Returns the buildfile as a task that you can use as a dependency.
|
170
|
-
def buildfile
|
171
|
-
@buildfile_task ||= BuildfileTask.define_task(File.expand_path(rakefile))
|
172
|
-
end
|
173
|
-
|
174
|
-
# Files that complement the buildfile itself
|
175
|
-
def build_files #:nodoc:
|
176
|
-
deprecated 'Please call buildfile.prerequisites instead'
|
177
|
-
buildfile.prerequisites
|
178
|
-
end
|
179
|
-
|
180
|
-
# Yields to block on successful completion. Primarily used for notifications.
|
181
|
-
def on_completion(&block)
|
182
|
-
@on_completion << block
|
183
|
-
end
|
184
|
-
|
185
|
-
# Yields to block on failure with exception. Primarily used for notifications.
|
186
|
-
def on_failure(&block)
|
187
|
-
@on_failure << block
|
188
|
-
end
|
189
|
-
|
190
|
-
# Call on_completion hooks with the given title and message
|
191
|
-
def build_completed(title, message)
|
192
|
-
@on_completion.each do |block|
|
193
|
-
block.call(title, message) rescue nil
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
# Call on_failure hooks with the given title, message and exception
|
198
|
-
def build_failed(title, message, ex = nil)
|
199
|
-
@on_failure.each do |block|
|
200
|
-
block.call(title, message, ex) rescue nil
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
# :call-seq:
|
205
|
-
# deprecated(message)
|
206
|
-
#
|
207
|
-
# Use with deprecated methods and classes. This method automatically adds the file name and line number,
|
208
|
-
# and the text 'Deprecated' before the message, and eliminated duplicate warnings. It only warns when
|
209
|
-
# running in verbose mode.
|
210
|
-
#
|
211
|
-
# For example:
|
212
|
-
# deprecated 'Please use new_foo instead of foo.'
|
213
|
-
def deprecated(message) #:nodoc:
|
214
|
-
return unless verbose
|
215
|
-
"#{caller[1]}: Deprecated: #{message}".tap do |message|
|
216
|
-
@deprecated ||= {}
|
217
|
-
unless @deprecated[message]
|
218
|
-
@deprecated[message] = true
|
219
|
-
warn message
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
protected
|
225
|
-
|
226
|
-
def load_buildfile # replaces load_rakefile
|
227
|
-
standard_exception_handling do
|
228
|
-
find_buildfile
|
229
|
-
load_gems
|
230
|
-
load_artifact_ns
|
231
|
-
load_tasks
|
232
|
-
raw_load_buildfile
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
def top_level # adds on_completion hook
|
237
|
-
standard_exception_handling do
|
238
|
-
if options.show_tasks
|
239
|
-
display_tasks_and_comments
|
240
|
-
elsif options.show_prereqs
|
241
|
-
display_prerequisites
|
242
|
-
elsif options.execute
|
243
|
-
eval options.execute
|
244
|
-
else
|
245
|
-
@start = Time.now
|
246
|
-
top_level_tasks.each { |task_name| invoke_task(task_name) }
|
247
|
-
if verbose
|
248
|
-
elapsed = Time.now - @start
|
249
|
-
real = []
|
250
|
-
real << ('%ih' % (elapsed / 3600)) if elapsed >= 3600
|
251
|
-
real << ('%im' % ((elapsed / 60) % 60)) if elapsed >= 60
|
252
|
-
real << ('%.3fs' % (elapsed % 60))
|
253
|
-
puts $terminal.color("Completed in #{real.join}", :green)
|
254
|
-
end
|
255
|
-
# On OS X this will load Cocoa and Growl which takes half a second we
|
256
|
-
# don't want to measure, so put this after the console message.
|
257
|
-
title, message = "Your build has completed", "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}"
|
258
|
-
build_completed(title, message)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def handle_options
|
264
|
-
options.rakelib = ['tasks']
|
265
|
-
|
266
|
-
OptionParser.new do |opts|
|
267
|
-
opts.banner = "buildr [-f rakefile] {options} targets..."
|
268
|
-
opts.separator ""
|
269
|
-
opts.separator "Options are ..."
|
270
|
-
|
271
|
-
opts.on_tail("-h", "--help", "-H", "Display this help message.") do
|
272
|
-
puts opts
|
273
|
-
exit 0
|
274
|
-
end
|
275
|
-
standard_buildr_options.each { |args| opts.on(*args) }
|
276
|
-
end.parse!
|
277
|
-
end
|
278
|
-
|
279
|
-
def standard_buildr_options # replaces standard_rake_options
|
280
|
-
[
|
281
|
-
['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
|
282
|
-
lambda { |value|
|
283
|
-
options.show_tasks = true
|
284
|
-
options.full_description = true
|
285
|
-
options.show_task_pattern = Regexp.new(value || '')
|
286
|
-
}
|
287
|
-
],
|
288
|
-
['--execute', '-E CODE',
|
289
|
-
"Execute some Ruby code after loading the buildfile",
|
290
|
-
lambda { |value| options.execute = value }
|
291
|
-
],
|
292
|
-
['--environment', '-e ENV',
|
293
|
-
"Environment name (e.g. development, test, production).",
|
294
|
-
lambda { |value| ENV['BUILDR_ENV'] = value }
|
295
|
-
],
|
296
|
-
['--generate [PATH]',
|
297
|
-
"Generate buildfile from either pom.xml file or directory path.",
|
298
|
-
lambda { |value|
|
299
|
-
value ||= File.exist?('pom.xml') ? 'pom.xml' : Dir.pwd
|
300
|
-
raw_generate_buildfile value
|
301
|
-
exit 0
|
302
|
-
}
|
303
|
-
],
|
304
|
-
['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
|
305
|
-
lambda { |value| $:.push(value) }
|
306
|
-
],
|
307
|
-
['--prereqs', '-P [PATTERN]', "Display the tasks and dependencies (matching optional PATTERN), then exit.",
|
308
|
-
lambda { |value|
|
309
|
-
options.show_prereqs = true
|
310
|
-
options.show_task_pattern = Regexp.new(value || '')
|
311
|
-
}
|
312
|
-
],
|
313
|
-
['--quiet', '-q', "Do not log messages to standard output.",
|
314
|
-
lambda { |value| verbose(false) }
|
315
|
-
],
|
316
|
-
['--buildfile', '-f FILE', "Use FILE as the buildfile.",
|
317
|
-
lambda { |value|
|
318
|
-
@rakefiles.clear
|
319
|
-
@rakefiles << value
|
320
|
-
}
|
321
|
-
],
|
322
|
-
['--rakelibdir', '--rakelib', '-R PATH',
|
323
|
-
"Auto-import any .rake files in PATH. (default is 'tasks')",
|
324
|
-
lambda { |value| options.rakelib = value.split(':') }
|
325
|
-
],
|
326
|
-
['--require', '-r MODULE', "Require MODULE before executing rakefile.",
|
327
|
-
lambda { |value|
|
328
|
-
begin
|
329
|
-
require value
|
330
|
-
rescue LoadError => ex
|
331
|
-
begin
|
332
|
-
rake_require value
|
333
|
-
rescue LoadError => ex2
|
334
|
-
raise ex
|
335
|
-
end
|
336
|
-
end
|
337
|
-
}
|
338
|
-
],
|
339
|
-
['--rules', "Trace the rules resolution.",
|
340
|
-
lambda { |value| options.trace_rules = true }
|
341
|
-
],
|
342
|
-
['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
|
343
|
-
lambda { |value| options.nosearch = true }
|
344
|
-
],
|
345
|
-
['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
|
346
|
-
lambda { |value|
|
347
|
-
verbose(false)
|
348
|
-
options.silent = true
|
349
|
-
}
|
350
|
-
],
|
351
|
-
['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
|
352
|
-
lambda { |value|
|
353
|
-
options.show_tasks = true
|
354
|
-
options.show_task_pattern = Regexp.new(value || '')
|
355
|
-
options.full_description = false
|
356
|
-
}
|
357
|
-
],
|
358
|
-
['--trace', '-t [CATEGORIES]', "Turn on invoke/execute tracing, enable full backtrace.",
|
359
|
-
lambda { |value|
|
360
|
-
options.trace = true
|
361
|
-
options.trace_categories = value ? value.split(',').map { |v| v.downcase.to_sym } : []
|
362
|
-
options.trace_all = options.trace_categories.include? :all
|
363
|
-
verbose(true)
|
364
|
-
}
|
365
|
-
],
|
366
|
-
['--verbose', '-v', "Log message to standard output (default).",
|
367
|
-
lambda { |value| verbose(true) }
|
368
|
-
],
|
369
|
-
['--version', '-V', "Display the program version.",
|
370
|
-
lambda { |value|
|
371
|
-
puts "Buildr #{Buildr::VERSION}#{RUBY_PLATFORM[/java/] ? " (JRuby #{JRUBY_VERSION})" : ""}"
|
372
|
-
exit 0
|
373
|
-
}
|
374
|
-
],
|
375
|
-
['--offline', '-o', "Do not try to download anything",
|
376
|
-
lambda { |value|
|
377
|
-
trace 'Working in offline mode; snapshot will not be updated.'
|
378
|
-
options.work_offline = true
|
379
|
-
}
|
380
|
-
],
|
381
|
-
['--update-snapshots', '-u', "Force updating all dependencies whose version contains SNAPSHOT",
|
382
|
-
lambda { |value|
|
383
|
-
trace 'Force update of SNAPSHOT artifacts.'
|
384
|
-
options.update_snapshots = true
|
385
|
-
}
|
386
|
-
]
|
387
|
-
]
|
388
|
-
end
|
389
|
-
|
390
|
-
def find_buildfile
|
391
|
-
buildfile, location = find_rakefile_location || (tty_output? && ask_generate_buildfile)
|
392
|
-
fail "No Buildfile found (looking for: #{@rakefiles.join(', ')})" if buildfile.nil?
|
393
|
-
@rakefile = buildfile
|
394
|
-
Dir.chdir(location)
|
395
|
-
end
|
396
|
-
|
397
|
-
def ask_generate_buildfile
|
398
|
-
source = choose do |menu|
|
399
|
-
menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
|
400
|
-
menu.choice("From Maven2 POM file") { 'pom.xml' } if File.exist?('pom.xml')
|
401
|
-
menu.choice("From directory structure") { Dir.pwd }
|
402
|
-
menu.choice("Cancel") { }
|
403
|
-
end
|
404
|
-
if source
|
405
|
-
buildfile = raw_generate_buildfile(source)
|
406
|
-
[buildfile, File.dirname(buildfile)]
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
def raw_generate_buildfile(source)
|
411
|
-
# We need rakefile to be known, for settings.build to be accessible.
|
412
|
-
@rakefile = File.expand_path(DEFAULT_BUILDFILES.first)
|
413
|
-
fail "Buildfile already exists" if File.exist?(@rakefile) && !(tty_output? && agree('Buildfile exists, overwrite?'))
|
414
|
-
script = File.directory?(source) ? Generate.from_directory(source) : Generate.from_maven2_pom(source)
|
415
|
-
File.open @rakefile, 'w' do |file|
|
416
|
-
file.puts script
|
417
|
-
end
|
418
|
-
puts "Created #{@rakefile}" if verbose
|
419
|
-
@rakefile
|
420
|
-
end
|
421
|
-
|
422
|
-
def raw_load_buildfile # replaces raw_load_rakefile
|
423
|
-
puts "(in #{Dir.pwd}, #{environment})" unless options.silent
|
424
|
-
load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
|
425
|
-
load_imports
|
426
|
-
Buildr.projects
|
427
|
-
end
|
428
|
-
|
429
|
-
# Load/install all Gems specified in build.yaml file.
|
430
|
-
def load_gems #:nodoc:
|
431
|
-
missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
|
432
|
-
unless missing_deps.empty?
|
433
|
-
newly_installed = Util::Gems.install(*missing_deps)
|
434
|
-
installed += newly_installed
|
435
|
-
end
|
436
|
-
installed.each do |spec|
|
437
|
-
if gem(spec.name, spec.version.to_s)
|
438
|
-
# TODO: is this intended to load rake tasks from the installed gems?
|
439
|
-
# We should use a convention like .. if the gem has a _buildr.rb file, load it.
|
440
|
-
|
441
|
-
#FileList[spec.require_paths.map { |path| File.expand_path("#{path}/*.rb", spec.full_gem_path) }].
|
442
|
-
# map { |path| File.basename(path) }.each { |file| require file }
|
443
|
-
#FileList[File.expand_path('tasks/*.rake', spec.full_gem_path)].each do |file|
|
444
|
-
# Buildr.application.add_import file
|
445
|
-
#end
|
446
|
-
end
|
447
|
-
end
|
448
|
-
@gems = installed
|
449
|
-
end
|
450
|
-
|
451
|
-
# Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
|
452
|
-
# for listed and uninstalled Gem, which is the installed before loading the buildfile.
|
453
|
-
def listed_gems #:nodoc:
|
454
|
-
Array(settings.build['gems']).map do |dep|
|
455
|
-
name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
|
456
|
-
versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
|
457
|
-
versions = ['>= 0'] if versions.empty?
|
458
|
-
dep = Gem::Dependency.new(name, versions)
|
459
|
-
Gem::SourceIndex.from_installed_gems.search(dep).last || dep
|
460
|
-
end
|
461
|
-
end
|
462
|
-
|
463
|
-
# Load artifact specs from the build.yaml file, making them available
|
464
|
-
# by name ( ruby symbols ).
|
465
|
-
def load_artifact_ns #:nodoc:
|
466
|
-
hash = settings.build['artifacts']
|
467
|
-
return unless hash
|
468
|
-
raise "Expected 'artifacts' element to be a hash" unless Hash === hash
|
469
|
-
# Currently we only use one artifact namespace to rule them all. (the root NS)
|
470
|
-
Buildr::ArtifactNamespace.load(:root => hash)
|
471
|
-
end
|
472
|
-
|
473
|
-
# Loads buildr.rb files from home/.buildr directory and project directory.
|
474
|
-
# Loads custom tasks from .rake files in tasks directory.
|
475
|
-
def load_tasks #:nodoc:
|
476
|
-
# TODO: this might need to be split up, look for deprecated features, better method name.
|
477
|
-
old = File.expand_path('buildr.rb', ENV['HOME'])
|
478
|
-
new = File.expand_path('buildr.rb', home_dir)
|
479
|
-
if File.exist?(old) && !File.exist?(new)
|
480
|
-
warn "Deprecated: Please move buildr.rb from your home directory to the .buildr directory in your home directory"
|
481
|
-
end
|
482
|
-
|
483
|
-
# Load home/.buildr/buildr.rb in preference
|
484
|
-
files = [ File.exist?(new) ? new : old, 'buildr.rb' ].select { |file| File.exist?(file) }
|
485
|
-
files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
|
486
|
-
select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
|
487
|
-
files += (options.rakelib || []).collect { |rlib| Dir["#{rlib}/*.rake"] }.flatten
|
488
|
-
|
489
|
-
# Load .buildr/_buildr.rb same directory as buildfile
|
490
|
-
%w{.buildr.rb _buildr.rb}.each do |f|
|
491
|
-
local_buildr = File.expand_path("#{File.dirname(Buildr.application.buildfile.to_s)}/#{f}")
|
492
|
-
files << local_buildr if File.exist?( local_buildr )
|
493
|
-
end
|
494
|
-
|
495
|
-
files.each do |file|
|
496
|
-
unless $LOADED_FEATURES.include?(file)
|
497
|
-
load file
|
498
|
-
$LOADED_FEATURES << file
|
499
|
-
end
|
500
|
-
end
|
501
|
-
buildfile.enhance files
|
502
|
-
true
|
503
|
-
end
|
504
|
-
|
505
|
-
def display_tasks_and_comments
|
506
|
-
displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern }
|
507
|
-
if options.full_description
|
508
|
-
displayable_tasks.each do |t|
|
509
|
-
puts "buildr #{t.name_with_args}"
|
510
|
-
t.full_comment.split("\n").each do |line|
|
511
|
-
puts " #{line}"
|
512
|
-
end
|
513
|
-
puts
|
514
|
-
end
|
515
|
-
else
|
516
|
-
width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
|
517
|
-
max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
|
518
|
-
displayable_tasks.each do |t|
|
519
|
-
printf "buildr %-#{width}s # %s\n",
|
520
|
-
t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
|
521
|
-
end
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
def display_prerequisites
|
526
|
-
displayable_tasks = tasks.select { |t| t.name =~ options.show_task_pattern }
|
527
|
-
displayable_tasks.each do |t|
|
528
|
-
puts "buildr #{t.name}"
|
529
|
-
t.prerequisites.each { |pre| puts " #{pre}" }
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
def standard_exception_handling # adds on_failure hook
|
534
|
-
begin
|
535
|
-
yield
|
536
|
-
rescue SystemExit => ex
|
537
|
-
# Exit silently with current status
|
538
|
-
exit(ex.status)
|
539
|
-
rescue OptionParser::ParseError => ex
|
540
|
-
$stderr.puts $terminal.color(ex.message, :red)
|
541
|
-
exit(1)
|
542
|
-
rescue Exception => ex
|
543
|
-
ex_msg = ex.class.name == "Exception" ? ex.message : "#{ex.class.name} : #{ex.message}"
|
544
|
-
title, message = "Your build failed with an error", "#{Dir.pwd}:\n#{ex_msg}"
|
545
|
-
build_failed(title, message, ex)
|
546
|
-
# Exit with error message
|
547
|
-
$stderr.puts "Buildr aborted!"
|
548
|
-
$stderr.puts $terminal.color(ex_msg, :red)
|
549
|
-
if options.trace
|
550
|
-
$stderr.puts ex.backtrace.join("\n")
|
551
|
-
else
|
552
|
-
$stderr.puts ex.backtrace.select { |str| str =~ /#{rakefile}/ }.map { |line| $terminal.color(line, :red) }.join("\n") if rakefile
|
553
|
-
$stderr.puts "(See full trace by running task with --trace)"
|
554
|
-
end
|
555
|
-
exit(1)
|
556
|
-
end
|
557
|
-
end
|
558
|
-
|
559
|
-
end
|
560
|
-
|
561
|
-
|
562
|
-
# This task stands for the buildfile and all its associated helper files (e.g., buildr.rb, build.yaml).
|
563
|
-
# By using this task as a prerequisite for other tasks, you can ensure these tasks will be needed
|
564
|
-
# whenever the buildfile changes.
|
565
|
-
class BuildfileTask < Rake::FileTask #:nodoc:
|
566
|
-
|
567
|
-
def timestamp
|
568
|
-
([name] + prerequisites).map { |f| File.stat(f).mtime }.max rescue Time.now
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
|
573
|
-
class << self
|
574
|
-
|
575
|
-
# Returns the Buildr::Application object.
|
576
|
-
def application
|
577
|
-
Rake.application
|
578
|
-
end
|
579
|
-
|
580
|
-
def application=(app) #:nodoc:
|
581
|
-
Rake.application = app
|
582
|
-
end
|
583
|
-
|
584
|
-
# Returns the Settings associated with this build.
|
585
|
-
def settings
|
586
|
-
Buildr.application.settings
|
587
|
-
end
|
588
|
-
|
589
|
-
# Copied from BUILD_ENV.
|
590
|
-
def environment
|
591
|
-
Buildr.application.environment
|
592
|
-
end
|
593
|
-
|
594
|
-
end
|
595
|
-
|
596
|
-
Buildr.application = Buildr::Application.new
|
597
|
-
|
598
|
-
end
|
599
|
-
|
600
|
-
|
601
|
-
# Add a touch of color when available and running in terminal.
|
602
|
-
HighLine.use_color = false
|
603
|
-
if $stdout.isatty
|
604
|
-
begin
|
605
|
-
require 'Win32/Console/ANSI' if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
606
|
-
HighLine.use_color = true
|
607
|
-
rescue LoadError
|
608
|
-
end
|
609
|
-
end
|
610
|
-
|
611
|
-
|
612
|
-
alias :warn_without_color :warn
|
613
|
-
|
614
|
-
# Show warning message.
|
615
|
-
def warn(message)
|
616
|
-
warn_without_color $terminal.color(message.to_s, :blue) if verbose
|
617
|
-
end
|
618
|
-
|
619
|
-
# Show error message. Use this when you need to show an error message and not throwing
|
620
|
-
# an exception that will stop the build.
|
621
|
-
def error(message)
|
622
|
-
puts $terminal.color(message.to_s, :red)
|
623
|
-
end
|
624
|
-
|
625
|
-
# Show optional information. The message is printed only when running in verbose
|
626
|
-
# mode (the default).
|
627
|
-
def info(message)
|
628
|
-
puts message if verbose
|
629
|
-
end
|
630
|
-
|
631
|
-
# Show message. The message is printed out only when running in trace mode.
|
632
|
-
def trace(message)
|
633
|
-
puts message if Buildr.application.options.trace
|
634
|
-
end
|
635
|
-
|
636
|
-
def trace?(*category)
|
637
|
-
options = Buildr.application.options
|
638
|
-
return options.trace if category.empty?
|
639
|
-
return true if options.trace_all
|
640
|
-
return false unless Buildr.application.options.trace_categories
|
641
|
-
options.trace_categories.include?(category.first)
|
642
|
-
end
|
643
|
-
|
644
|
-
module Rake #:nodoc
|
645
|
-
# Rake's circular dependency checks (InvocationChain) only applies to task prerequisites,
|
646
|
-
# all other cases result in the non too-descriptive thread sleeping error. This change can
|
647
|
-
# deal with circular dependencies that occur from direct task invocation, e.g:
|
648
|
-
# task 'foo'=>'bar'
|
649
|
-
# task 'bar' do
|
650
|
-
# task('foo').invoke
|
651
|
-
# end
|
652
|
-
class Task #:nodoc:
|
653
|
-
def invoke(*args)
|
654
|
-
task_args = TaskArguments.new(arg_names, args)
|
655
|
-
invoke_with_call_chain(task_args, Thread.current[:rake_chain] || InvocationChain::EMPTY)
|
656
|
-
end
|
657
|
-
|
658
|
-
def invoke_with_call_chain(task_args, invocation_chain)
|
659
|
-
new_chain = InvocationChain.append(self, invocation_chain)
|
660
|
-
@lock.synchronize do
|
661
|
-
if application.options.trace
|
662
|
-
puts "** Invoke #{name} #{format_trace_flags}"
|
663
|
-
end
|
664
|
-
return if @already_invoked
|
665
|
-
@already_invoked = true
|
666
|
-
begin
|
667
|
-
invoke_prerequisites(task_args, new_chain)
|
668
|
-
rescue
|
669
|
-
trace "Exception while invoking prerequisites of task #{self.inspect}"
|
670
|
-
raise
|
671
|
-
end
|
672
|
-
begin
|
673
|
-
old_chain, Thread.current[:rake_chain] = Thread.current[:rake_chain], new_chain
|
674
|
-
execute(task_args) if needed?
|
675
|
-
ensure
|
676
|
-
Thread.current[:rake_chain] = old_chain
|
677
|
-
end
|
678
|
-
end
|
679
|
-
end
|
680
|
-
end
|
681
|
-
end
|
682
|
-
|
683
|
-
|
684
|
-
module RakeFileUtils #:nodoc:
|
685
|
-
FileUtils::OPT_TABLE.each do |name, opts|
|
686
|
-
default_options = []
|
687
|
-
if opts.include?(:verbose) || opts.include?("verbose")
|
688
|
-
default_options << ':verbose => RakeFileUtils.verbose_flag == true'
|
689
|
-
end
|
690
|
-
next if default_options.empty?
|
691
|
-
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
692
|
-
def #{name}( *args, &block )
|
693
|
-
super(
|
694
|
-
*rake_merge_option(args,
|
695
|
-
#{default_options.join(', ')}
|
696
|
-
), &block)
|
697
|
-
end
|
698
|
-
EOS
|
699
|
-
end
|
700
|
-
end
|