rake 0.7.3 → 0.8.7
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/CHANGES +126 -1
- data/README +86 -132
- data/Rakefile +111 -64
- data/TODO +1 -0
- data/bin/rake +24 -0
- data/doc/command_line_usage.rdoc +102 -0
- data/doc/rakefile.rdoc +126 -3
- data/doc/release_notes/rake-0.7.3.rdoc +0 -0
- data/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/doc/release_notes/rake-0.8.4.rdoc +147 -0
- data/doc/release_notes/rake-0.8.5.rdoc +53 -0
- data/doc/release_notes/rake-0.8.6.rdoc +55 -0
- data/doc/release_notes/rake-0.8.7.rdoc +55 -0
- data/lib/rake/alt_system.rb +108 -0
- data/lib/rake/contrib/ftptools.rb +24 -10
- data/lib/rake/contrib/publisher.rb +1 -1
- data/lib/rake/contrib/sys.rb +5 -2
- data/lib/rake/gempackagetask.rb +2 -6
- data/lib/rake/loaders/makefile.rb +17 -15
- data/lib/rake/rdoctask.rb +83 -21
- data/lib/rake/ruby182_test_unit_fix.rb +0 -0
- data/lib/rake/tasklib.rb +8 -3
- data/lib/rake/testtask.rb +1 -1
- data/lib/rake/win32.rb +55 -0
- data/lib/rake.rb +861 -386
- data/test/check_expansion.rb +5 -0
- data/test/check_no_expansion.rb +5 -0
- data/test/data/file_creation_task/Rakefile +4 -1
- data/test/data/multidesc/Rakefile +3 -0
- data/test/data/sample.mf +6 -1
- data/test/data/statusreturn/Rakefile +8 -0
- data/test/filecreation.rb +0 -2
- data/test/functional.rb +3 -1
- data/test/in_environment.rb +30 -0
- data/test/rake_test_setup.rb +24 -0
- data/test/session_functional.rb +145 -24
- data/test/shellcommand.rb +0 -0
- data/test/test_application.rb +345 -95
- data/test/test_definitions.rb +4 -1
- data/test/test_earlytime.rb +2 -2
- data/test/test_extension.rb +63 -0
- data/test/test_file_task.rb +20 -16
- data/test/test_filelist.rb +59 -10
- data/test/test_fileutils.rb +59 -38
- data/test/test_ftp.rb +5 -1
- data/test/test_invocation_chain.rb +81 -0
- data/test/test_makefile_loader.rb +5 -2
- data/test/test_namespace.rb +37 -14
- data/test/test_package_task.rb +3 -15
- data/test/test_pathmap.rb +24 -2
- data/test/test_pseudo_status.rb +26 -0
- data/test/test_rake.rb +9 -2
- data/test/test_rdoc_task.rb +88 -0
- data/test/test_require.rb +3 -1
- data/test/test_rules.rb +56 -12
- data/test/test_task_arguments.rb +89 -0
- data/test/test_task_manager.rb +27 -2
- data/test/test_tasklib.rb +12 -0
- data/test/test_tasks.rb +248 -20
- data/test/test_test_task.rb +3 -2
- data/test/test_top_level_functions.rb +10 -3
- data/test/test_win32.rb +72 -0
- metadata +105 -69
- /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
data/Rakefile
CHANGED
|
@@ -16,14 +16,17 @@ require 'rake/clean'
|
|
|
16
16
|
require 'rake/testtask'
|
|
17
17
|
require 'rake/rdoctask'
|
|
18
18
|
|
|
19
|
-
CLEAN.include('**/*.o', '*.dot')
|
|
19
|
+
CLEAN.include('**/*.o', '*.dot', '**/.*.rbc')
|
|
20
20
|
CLOBBER.include('doc/example/main', 'testdata')
|
|
21
21
|
CLOBBER.include('test/data/**/temp_*')
|
|
22
22
|
CLOBBER.include('test/data/chains/play.*')
|
|
23
23
|
CLOBBER.include('test/data/file_creation_task/build')
|
|
24
24
|
CLOBBER.include('test/data/file_creation_task/src')
|
|
25
25
|
CLOBBER.include('TAGS')
|
|
26
|
-
CLOBBER.include('coverage')
|
|
26
|
+
CLOBBER.include('coverage', 'rcov_aggregate')
|
|
27
|
+
|
|
28
|
+
# Prevent OS X from including extended attribute junk in the tar output
|
|
29
|
+
ENV['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
|
|
27
30
|
|
|
28
31
|
def announce(msg='')
|
|
29
32
|
STDERR.puts msg
|
|
@@ -37,11 +40,7 @@ else
|
|
|
37
40
|
CURRENT_VERSION = "0.0.0"
|
|
38
41
|
end
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
PKG_VERSION = ENV['REL']
|
|
42
|
-
else
|
|
43
|
-
PKG_VERSION = CURRENT_VERSION
|
|
44
|
-
end
|
|
43
|
+
$package_version = CURRENT_VERSION
|
|
45
44
|
|
|
46
45
|
SRC_RB = FileList['lib/**/*.rb']
|
|
47
46
|
|
|
@@ -51,6 +50,9 @@ desc "Default Task"
|
|
|
51
50
|
task :default => :test_all
|
|
52
51
|
|
|
53
52
|
# Test Tasks ---------------------------------------------------------
|
|
53
|
+
task :dbg do |t|
|
|
54
|
+
puts "Arguments are: #{t.args.join(', ')}"
|
|
55
|
+
end
|
|
54
56
|
|
|
55
57
|
# Common Abbreviations ...
|
|
56
58
|
|
|
@@ -79,13 +81,13 @@ end
|
|
|
79
81
|
Rake::TestTask.new(:test_functional) do |t|
|
|
80
82
|
t.test_files = FileList['test/fun*.rb']
|
|
81
83
|
t.warning = true
|
|
82
|
-
t.
|
|
84
|
+
t.verbose = false
|
|
83
85
|
end
|
|
84
86
|
|
|
85
87
|
Rake::TestTask.new(:test_contribs) do |t|
|
|
86
88
|
t.test_files = FileList['test/contrib/test*.rb']
|
|
87
|
-
t.verbose = false
|
|
88
89
|
t.warning = true
|
|
90
|
+
t.verbose = false
|
|
89
91
|
end
|
|
90
92
|
|
|
91
93
|
begin
|
|
@@ -93,15 +95,21 @@ begin
|
|
|
93
95
|
|
|
94
96
|
Rcov::RcovTask.new do |t|
|
|
95
97
|
t.libs << "test"
|
|
96
|
-
|
|
98
|
+
dot_rakes =
|
|
99
|
+
t.rcov_opts = [
|
|
100
|
+
'-xRakefile', '-xrakefile', '-xpublish.rf',
|
|
101
|
+
'-xlib/rake/contrib', '-x/Library',
|
|
102
|
+
'--text-report',
|
|
103
|
+
'--sort coverage'
|
|
104
|
+
] + FileList['rakelib/*.rake'].pathmap("-x%p")
|
|
97
105
|
t.test_files = FileList[
|
|
98
|
-
'test/test*.rb',
|
|
99
|
-
'test/contrib/test*.rb'
|
|
106
|
+
'test/test*.rb', 'test/functional.rb'
|
|
100
107
|
]
|
|
108
|
+
t.output_dir = 'coverage'
|
|
101
109
|
t.verbose = true
|
|
102
110
|
end
|
|
103
111
|
rescue LoadError
|
|
104
|
-
|
|
112
|
+
puts "RCov is not available"
|
|
105
113
|
end
|
|
106
114
|
|
|
107
115
|
directory 'testdata'
|
|
@@ -120,19 +128,30 @@ end
|
|
|
120
128
|
|
|
121
129
|
# Create a task to build the RDOC documentation tree.
|
|
122
130
|
|
|
123
|
-
|
|
131
|
+
begin
|
|
132
|
+
require 'darkfish-rdoc'
|
|
133
|
+
DARKFISH_ENABLED = true
|
|
134
|
+
rescue LoadError => ex
|
|
135
|
+
DARKFISH_ENABLED = false
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
BASE_RDOC_OPTIONS = [
|
|
139
|
+
'--line-numbers',
|
|
140
|
+
'--main', 'README',
|
|
141
|
+
'--title', 'Rake -- Ruby Make',
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
rd = Rake::RDocTask.new("rdoc") do |rdoc|
|
|
124
145
|
rdoc.rdoc_dir = 'html'
|
|
125
|
-
# rdoc.template = 'kilmer'
|
|
126
|
-
# rdoc.template = 'css2'
|
|
127
146
|
rdoc.template = 'doc/jamis.rb'
|
|
128
147
|
rdoc.title = "Rake -- Ruby Make"
|
|
129
|
-
rdoc.options
|
|
130
|
-
|
|
131
|
-
|
|
148
|
+
rdoc.options = BASE_RDOC_OPTIONS.dup
|
|
149
|
+
rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED
|
|
150
|
+
|
|
132
151
|
rdoc.rdoc_files.include('README', 'MIT-LICENSE', 'TODO', 'CHANGES')
|
|
133
152
|
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
|
134
153
|
rdoc.rdoc_files.exclude(/\bcontrib\b/)
|
|
135
|
-
|
|
154
|
+
end
|
|
136
155
|
|
|
137
156
|
# ====================================================================
|
|
138
157
|
# Create a task that will package the Rake software into distributable
|
|
@@ -147,20 +166,22 @@ PKG_FILES = FileList[
|
|
|
147
166
|
'test/**/*.rf',
|
|
148
167
|
'test/**/*.mf',
|
|
149
168
|
'test/**/Rakefile',
|
|
169
|
+
'test/**/subdir',
|
|
150
170
|
'doc/**/*'
|
|
151
171
|
]
|
|
152
172
|
PKG_FILES.exclude('doc/example/*.o')
|
|
173
|
+
PKG_FILES.exclude('TAGS')
|
|
153
174
|
PKG_FILES.exclude(%r{doc/example/main$})
|
|
154
175
|
|
|
155
176
|
if ! defined?(Gem)
|
|
156
177
|
puts "Package Target requires RubyGEMs"
|
|
157
178
|
else
|
|
158
|
-
|
|
179
|
+
SPEC = Gem::Specification.new do |s|
|
|
159
180
|
|
|
160
181
|
#### Basic information.
|
|
161
182
|
|
|
162
183
|
s.name = 'rake'
|
|
163
|
-
s.version =
|
|
184
|
+
s.version = $package_version
|
|
164
185
|
s.summary = "Ruby based make-like utility."
|
|
165
186
|
s.description = <<-EOF
|
|
166
187
|
Rake is a Make-like program implemented in Ruby. Tasks
|
|
@@ -192,7 +213,7 @@ else
|
|
|
192
213
|
|
|
193
214
|
s.has_rdoc = true
|
|
194
215
|
s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
|
195
|
-
s.rdoc_options =
|
|
216
|
+
s.rdoc_options = BASE_RDOC_OPTIONS
|
|
196
217
|
|
|
197
218
|
#### Author and project details.
|
|
198
219
|
|
|
@@ -206,10 +227,18 @@ else
|
|
|
206
227
|
# end
|
|
207
228
|
end
|
|
208
229
|
|
|
209
|
-
package_task = Rake::GemPackageTask.new(
|
|
230
|
+
package_task = Rake::GemPackageTask.new(SPEC) do |pkg|
|
|
210
231
|
pkg.need_zip = true
|
|
211
232
|
pkg.need_tar = true
|
|
212
233
|
end
|
|
234
|
+
|
|
235
|
+
file "rake.gemspec" => ["Rakefile", "lib/rake.rb"] do |t|
|
|
236
|
+
require 'yaml'
|
|
237
|
+
open(t.name, "w") { |f| f.puts SPEC.to_yaml }
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
desc "Create a stand-alone gemspec"
|
|
241
|
+
task :gemspec => "rake.gemspec"
|
|
213
242
|
end
|
|
214
243
|
|
|
215
244
|
# Misc tasks =========================================================
|
|
@@ -246,12 +275,6 @@ task :lines do
|
|
|
246
275
|
show_line("TOTAL", total_lines, total_code)
|
|
247
276
|
end
|
|
248
277
|
|
|
249
|
-
ARCHIVEDIR = '/mnt/usb'
|
|
250
|
-
|
|
251
|
-
task :archive => [:package] do
|
|
252
|
-
cp FileList["pkg/*.tgz", "pkg/*.zip", "pkg/*.gem"], ARCHIVEDIR
|
|
253
|
-
end
|
|
254
|
-
|
|
255
278
|
# Define an optional publish target in an external file. If the
|
|
256
279
|
# publish.rf file is not found, the publish targets won't be defined.
|
|
257
280
|
|
|
@@ -259,86 +282,108 @@ load "publish.rf" if File.exist? "publish.rf"
|
|
|
259
282
|
|
|
260
283
|
# Support Tasks ------------------------------------------------------
|
|
261
284
|
|
|
285
|
+
RUBY_FILES = FileList['**/*.rb'].exclude('pkg')
|
|
286
|
+
|
|
262
287
|
desc "Look for TODO and FIXME tags in the code"
|
|
263
288
|
task :todo do
|
|
264
|
-
|
|
289
|
+
RUBY_FILES.egrep(/#.*(FIXME|TODO|TBD)/)
|
|
265
290
|
end
|
|
266
291
|
|
|
267
292
|
desc "Look for Debugging print lines"
|
|
268
293
|
task :dbg do
|
|
269
|
-
|
|
294
|
+
RUBY_FILES.egrep(/\bDBG|\bbreakpoint\b/)
|
|
270
295
|
end
|
|
271
296
|
|
|
272
297
|
desc "List all ruby files"
|
|
273
298
|
task :rubyfiles do
|
|
274
|
-
puts
|
|
275
|
-
puts
|
|
299
|
+
puts RUBY_FILES
|
|
300
|
+
puts FileList['bin/*'].exclude('bin/*.rb')
|
|
276
301
|
end
|
|
277
302
|
task :rf => :rubyfiles
|
|
278
303
|
|
|
304
|
+
desc "Create a TAGS file"
|
|
305
|
+
task :tags => "TAGS"
|
|
306
|
+
|
|
307
|
+
TAGS = 'xctags -e'
|
|
308
|
+
|
|
309
|
+
file "TAGS" => RUBY_FILES do
|
|
310
|
+
puts "Makings TAGS"
|
|
311
|
+
sh "#{TAGS} #{RUBY_FILES}", :verbose => false
|
|
312
|
+
end
|
|
313
|
+
|
|
279
314
|
# --------------------------------------------------------------------
|
|
280
315
|
# Creating a release
|
|
281
316
|
|
|
317
|
+
def plugin(plugin_name)
|
|
318
|
+
require "rake/plugins/#{plugin_name}"
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
task :noop
|
|
322
|
+
#plugin "release_manager"
|
|
323
|
+
|
|
282
324
|
desc "Make a new release"
|
|
283
|
-
task :release
|
|
284
|
-
:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
325
|
+
task :release, :rel, :reuse, :reltest,
|
|
326
|
+
:needs => [
|
|
327
|
+
:prerelease,
|
|
328
|
+
:clobber,
|
|
329
|
+
:test_all,
|
|
330
|
+
:update_version,
|
|
331
|
+
:package,
|
|
332
|
+
:tag
|
|
333
|
+
] do
|
|
291
334
|
announce
|
|
292
335
|
announce "**************************************************************"
|
|
293
|
-
announce "* Release #{
|
|
336
|
+
announce "* Release #{$package_version} Complete."
|
|
294
337
|
announce "* Packages ready to upload."
|
|
295
338
|
announce "**************************************************************"
|
|
296
339
|
announce
|
|
297
340
|
end
|
|
298
341
|
|
|
299
342
|
# Validate that everything is ready to go for a release.
|
|
300
|
-
task :prerelease do
|
|
343
|
+
task :prerelease, :rel, :reuse, :reltest do |t, args|
|
|
344
|
+
$package_version = args.rel
|
|
301
345
|
announce
|
|
302
346
|
announce "**************************************************************"
|
|
303
|
-
announce "* Making RubyGem Release #{
|
|
347
|
+
announce "* Making RubyGem Release #{$package_version}"
|
|
304
348
|
announce "* (current version #{CURRENT_VERSION})"
|
|
305
349
|
announce "**************************************************************"
|
|
306
350
|
announce
|
|
307
351
|
|
|
308
352
|
# Is a release number supplied?
|
|
309
|
-
unless
|
|
310
|
-
fail "Usage: rake release
|
|
353
|
+
unless args.rel
|
|
354
|
+
fail "Usage: rake release[X.Y.Z] [REUSE=tag_suffix]"
|
|
311
355
|
end
|
|
312
356
|
|
|
313
357
|
# Is the release different than the current release.
|
|
314
358
|
# (or is REUSE set?)
|
|
315
|
-
if
|
|
316
|
-
fail "Current version is #{
|
|
359
|
+
if $package_version == CURRENT_VERSION && ! args.reuse
|
|
360
|
+
fail "Current version is #{$package_version}, must specify REUSE=tag_suffix to reuse version"
|
|
317
361
|
end
|
|
318
362
|
|
|
319
363
|
# Are all source files checked in?
|
|
320
|
-
if
|
|
364
|
+
if args.reltest
|
|
321
365
|
announce "Release Task Testing, skipping checked-in file test"
|
|
322
366
|
else
|
|
323
367
|
announce "Checking for unchecked-in files..."
|
|
324
|
-
data = `
|
|
368
|
+
data = `svn st`
|
|
325
369
|
unless data =~ /^$/
|
|
326
|
-
|
|
370
|
+
abort "svn status is not clean ... do you have unchecked-in files?"
|
|
327
371
|
end
|
|
328
372
|
announce "No outstanding checkins found ... OK"
|
|
329
373
|
end
|
|
330
374
|
end
|
|
331
375
|
|
|
332
|
-
task :update_version
|
|
333
|
-
|
|
376
|
+
task :update_version, :rel, :reuse, :reltest,
|
|
377
|
+
:needs => [:prerelease] do |t, args|
|
|
378
|
+
if args.rel == CURRENT_VERSION
|
|
334
379
|
announce "No version change ... skipping version update"
|
|
335
380
|
else
|
|
336
|
-
announce "Updating Rake version to #{
|
|
381
|
+
announce "Updating Rake version to #{args.rel}"
|
|
337
382
|
open("lib/rake.rb") do |rakein|
|
|
338
383
|
open("lib/rake.rb.new", "w") do |rakeout|
|
|
339
384
|
rakein.each do |line|
|
|
340
385
|
if line =~ /^RAKEVERSION\s*=\s*/
|
|
341
|
-
rakeout.puts "RAKEVERSION = '#{
|
|
386
|
+
rakeout.puts "RAKEVERSION = '#{args.rel}'"
|
|
342
387
|
else
|
|
343
388
|
rakeout.puts line
|
|
344
389
|
end
|
|
@@ -346,23 +391,24 @@ task :update_version => [:prerelease] do
|
|
|
346
391
|
end
|
|
347
392
|
end
|
|
348
393
|
mv "lib/rake.rb.new", "lib/rake.rb"
|
|
349
|
-
if
|
|
394
|
+
if args.reltest
|
|
350
395
|
announce "Release Task Testing, skipping commiting of new version"
|
|
351
396
|
else
|
|
352
|
-
sh %{
|
|
397
|
+
sh %{svn commit -m "Updated to version #{args.rel}" lib/rake.rb} # "
|
|
353
398
|
end
|
|
354
399
|
end
|
|
355
400
|
end
|
|
356
401
|
|
|
357
402
|
desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
|
|
358
|
-
task :tag
|
|
359
|
-
|
|
360
|
-
reltag
|
|
361
|
-
|
|
362
|
-
|
|
403
|
+
task :tag, :rel, :reuse, :reltest,
|
|
404
|
+
:needs => [:prerelease] do |t, args|
|
|
405
|
+
reltag = "REL_#{args.rel.gsub(/\./, '_')}"
|
|
406
|
+
reltag << args.reuse.gsub(/\./, '_') if args.reuse
|
|
407
|
+
announce "Tagging Repository with [#{reltag}]"
|
|
408
|
+
if args.reltest
|
|
363
409
|
announce "Release Task Testing, skipping CVS tagging"
|
|
364
410
|
else
|
|
365
|
-
sh %{
|
|
411
|
+
sh %{svn copy svn+ssh://rubyforge.org/var/svn/rake/trunk svn+ssh://rubyforge.org/var/svn/rake/tags/#{reltag} -m 'Commiting release #{reltag}'} ###'
|
|
366
412
|
end
|
|
367
413
|
end
|
|
368
414
|
|
|
@@ -378,6 +424,7 @@ end
|
|
|
378
424
|
|
|
379
425
|
load 'xforge.rf' if File.exist?('xforge.rf')
|
|
380
426
|
|
|
427
|
+
desc "Where is the current directory. This task displays\nthe current rake directory"
|
|
381
428
|
task :where_am_i do
|
|
382
429
|
puts Rake.original_dir
|
|
383
430
|
end
|
data/TODO
CHANGED
|
@@ -4,6 +4,7 @@ Send suggestions for this list to mailto:jim@weirichhouse.org or on
|
|
|
4
4
|
the rake-devel@rubyforge.org mailing list.
|
|
5
5
|
|
|
6
6
|
=== To Do
|
|
7
|
+
* Need a nice API for accessing tasks in namespaces, namespaces in an app, etc.
|
|
7
8
|
* Provide a way to disable -w warning mode.
|
|
8
9
|
* Define a set of default rules that work in the absense of any Rakefile
|
|
9
10
|
* What about cyclic dependencies?
|
data/bin/rake
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
|
14
|
+
# all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
22
|
+
# IN THE SOFTWARE.
|
|
23
|
+
#++
|
|
24
|
+
|
|
1
25
|
begin
|
|
2
26
|
require 'rake'
|
|
3
27
|
rescue LoadError
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
= Rake Command Line Usage
|
|
2
|
+
|
|
3
|
+
Rake is invoked from the command line using:
|
|
4
|
+
|
|
5
|
+
% rake [<em>options</em> ...] [<em>VAR</em>=<em>VALUE</em>] [<em>targets</em> ...]
|
|
6
|
+
|
|
7
|
+
Options are:
|
|
8
|
+
|
|
9
|
+
[<tt><em>name</em>=<em>value</em></tt>]
|
|
10
|
+
Set the environment variable <em>name</em> to <em>value</em>
|
|
11
|
+
during the execution of the <b>rake</b> command. You can access
|
|
12
|
+
the value by using ENV['<em>name</em>'].
|
|
13
|
+
|
|
14
|
+
[<tt>--classic-namespace</tt> (-n)]
|
|
15
|
+
Import the Task, FileTask, and FileCreateTask into the top-level
|
|
16
|
+
scope to be compatible with older versions of Rake. Alternatively
|
|
17
|
+
you can include the line <code>require
|
|
18
|
+
'rake/classic_namespace'</code> in your Rakefile to get the
|
|
19
|
+
classic behavior.
|
|
20
|
+
|
|
21
|
+
[<tt>--describe</tt> _pattern_ (-D)]
|
|
22
|
+
Describe the tasks (matching optional PATTERN), then exit.
|
|
23
|
+
|
|
24
|
+
[<tt>--dry-run</tt> (-n)]
|
|
25
|
+
Do a dry run. Print the tasks invoked and executed, but do not
|
|
26
|
+
actually execute any of the actions.
|
|
27
|
+
|
|
28
|
+
[<tt>--execute</tt> _code_ (-e)]
|
|
29
|
+
Execute some Ruby code and exit.
|
|
30
|
+
|
|
31
|
+
[<tt>--execute-print</tt> _code_ (-p)]
|
|
32
|
+
Execute some Ruby code, print the result, and exit.
|
|
33
|
+
|
|
34
|
+
[<tt>--execute-continue</tt> _code_ (-p)]
|
|
35
|
+
Execute some Ruby code, then continue with normal task processing.
|
|
36
|
+
|
|
37
|
+
[<tt>--help</tt> (-H)]
|
|
38
|
+
Display some help text and exit.
|
|
39
|
+
|
|
40
|
+
[<tt>--libdir</tt> _directory_ (-I)]
|
|
41
|
+
Add _directory_ to the list of directories searched for require.
|
|
42
|
+
|
|
43
|
+
[<tt>--nosearch</tt> (-N)]
|
|
44
|
+
Do not search for a Rakefile in parent directories.
|
|
45
|
+
|
|
46
|
+
[<tt>--prereqs</tt> (-P)]
|
|
47
|
+
Display a list of all tasks and their immediate prerequisites.
|
|
48
|
+
|
|
49
|
+
[<tt>--quiet</tt> (-q)]
|
|
50
|
+
Do not echo commands from FileUtils.
|
|
51
|
+
|
|
52
|
+
[<tt>--rakefile</tt> _filename_ (-f)]
|
|
53
|
+
Use _filename_ as the name of the rakefile. The default rakefile
|
|
54
|
+
names are +rakefile+ and +Rakefile+ (with +rakefile+ taking
|
|
55
|
+
precedence). If the rakefile is not found in the current
|
|
56
|
+
directory, +rake+ will search parent directories for a match. The
|
|
57
|
+
directory where the Rakefile is found will become the current
|
|
58
|
+
directory for the actions executed in the Rakefile.
|
|
59
|
+
|
|
60
|
+
[<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
|
|
61
|
+
Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
|
|
62
|
+
|
|
63
|
+
[<tt>--require</tt> _name_ (-r)]
|
|
64
|
+
Require _name_ before executing the Rakefile.
|
|
65
|
+
|
|
66
|
+
[<tt>--rules</tt>]
|
|
67
|
+
Trace the rules resolution.
|
|
68
|
+
|
|
69
|
+
[<tt>--silent (-s)</tt>]
|
|
70
|
+
Like --quiet, but also suppresses the 'in directory' announcement.
|
|
71
|
+
|
|
72
|
+
[<tt>--system</tt> (-g)]
|
|
73
|
+
Use the system wide (global) rakefiles. The project Rakefile is
|
|
74
|
+
ignored. By default, the system wide rakefiles are used only if no
|
|
75
|
+
project Rakefile is found. On Unix-like system, the system wide
|
|
76
|
+
rake files are located in $HOME/.rake. On a windows system they
|
|
77
|
+
are stored in $APPDATA/Rake.
|
|
78
|
+
|
|
79
|
+
[<tt>--no-system</tt> (-G)]
|
|
80
|
+
Use the project level Rakefile, ignoring the system-wide (global)
|
|
81
|
+
rakefiles.
|
|
82
|
+
|
|
83
|
+
[<tt>--tasks</tt> (-T)]
|
|
84
|
+
Display a list of the major tasks and their comments. Comments
|
|
85
|
+
are defined using the "desc" command.
|
|
86
|
+
|
|
87
|
+
[<tt>--trace</tt> (-t)]
|
|
88
|
+
Turn on invoke/execute tracing. Also enable full backtrace on
|
|
89
|
+
errors.
|
|
90
|
+
|
|
91
|
+
[<tt>--usage</tt> (-h)]
|
|
92
|
+
Display a usage message and exit.
|
|
93
|
+
|
|
94
|
+
[<tt>--verbose</tt> (-v)]
|
|
95
|
+
Echo the Sys commands to standard output.
|
|
96
|
+
|
|
97
|
+
[<tt>--version</tt> (-V)]
|
|
98
|
+
Display the program version and exit.
|
|
99
|
+
|
|
100
|
+
In addition, any command line option of the form
|
|
101
|
+
<em>VAR</em>=<em>VALUE</em> will be added to the environment hash
|
|
102
|
+
<tt>ENV</tt> and may be tested in the Rakefile.
|
data/doc/rakefile.rdoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
= Rakefile Format
|
|
1
|
+
= Rakefile Format (as of version 0.8.3)
|
|
2
2
|
|
|
3
3
|
First of all, there is no special format for a Rakefile. A Rakefile
|
|
4
4
|
contains executable Ruby code. Anything legal in a ruby script is
|
|
@@ -150,6 +150,131 @@ to do extra synchronization for Rake's benefit. However, if there are
|
|
|
150
150
|
user data structures shared between the parallel prerequisites, the
|
|
151
151
|
user must do whatever is necessary to prevent race conditions.
|
|
152
152
|
|
|
153
|
+
== Tasks with Arguments
|
|
154
|
+
|
|
155
|
+
Prior to version 0.8.0, rake was only able to handle command line
|
|
156
|
+
arguments of the form NAME=VALUE that were passed into Rake via the
|
|
157
|
+
ENV hash. Many folks had asked for some kind of simple command line
|
|
158
|
+
arguments, perhaps using "--" to separate regular task names from
|
|
159
|
+
argument values on the command line. The problem is that there was no
|
|
160
|
+
easy way to associate positional arguments on the command line with
|
|
161
|
+
different tasks. Suppose both tasks :a and :b expect a command line
|
|
162
|
+
argument: does the first value go with :a? What if :b is run first?
|
|
163
|
+
Should it then get the first command line argument.
|
|
164
|
+
|
|
165
|
+
Rake 0.8.0 solves this problem by explicitly passing values directly
|
|
166
|
+
to the tasks that need them. For example, if I had a release task
|
|
167
|
+
that required a version number, I could say:
|
|
168
|
+
|
|
169
|
+
rake release[0.8.2]
|
|
170
|
+
|
|
171
|
+
And the string "0.8.2" will be passed to the :release task. Multiple
|
|
172
|
+
arguments can be passed by separating them with a comma, for example:
|
|
173
|
+
|
|
174
|
+
rake name[john,doe]
|
|
175
|
+
|
|
176
|
+
Just a few words of caution. The rake task name and its arguments
|
|
177
|
+
need to be a single command line argument to rake. This generally
|
|
178
|
+
means no spaces. If spaces are needed, then the entire rake +
|
|
179
|
+
argument string should be quoted. Something like this:
|
|
180
|
+
|
|
181
|
+
rake "name[billy bob, smith]"
|
|
182
|
+
|
|
183
|
+
(Quoting rules vary between operating systems and shells, so make sure
|
|
184
|
+
you consult the proper docs for your OS/shell).
|
|
185
|
+
|
|
186
|
+
=== Tasks that Expect Parameters
|
|
187
|
+
|
|
188
|
+
Parameters are only given to tasks that are setup to expect them. In
|
|
189
|
+
order to handle named parameters, the task declaration syntax for
|
|
190
|
+
tasks has been extended slightly.
|
|
191
|
+
|
|
192
|
+
For example, a task that needs a first name and last name might be
|
|
193
|
+
declared as:
|
|
194
|
+
|
|
195
|
+
task :name, [:first_name, :last_name]
|
|
196
|
+
|
|
197
|
+
The first argument is still the name of the task (:name in this case).
|
|
198
|
+
The next to argumements are the names of the parameters expected by
|
|
199
|
+
:name in an array (:first_name and :last_name in the example).
|
|
200
|
+
|
|
201
|
+
To access the values of the paramters, the block defining the task
|
|
202
|
+
behaviour can now accept a second parameter:
|
|
203
|
+
|
|
204
|
+
task :name, [:first_name, :last_name] do |t, args|
|
|
205
|
+
puts "First name is #{args.first_name}"
|
|
206
|
+
puts "Last name is #{args.last_name}"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
The first argument of the block "t" is always bound to the current
|
|
210
|
+
task object. The second argument "args" is an open-struct like object
|
|
211
|
+
that allows access to the task arguments. Extra command line
|
|
212
|
+
arguments to a task are ignored. Missing command line arguments are
|
|
213
|
+
given the nil value.
|
|
214
|
+
|
|
215
|
+
If you wish to specify default values for the arguments, you can use
|
|
216
|
+
the with_defaults method in the task body. Here is the above example
|
|
217
|
+
where we specify default values for the first and last names:
|
|
218
|
+
|
|
219
|
+
task :name, [:first_name, :last_name] do |t, args|
|
|
220
|
+
args.with_defaults(:first_name => "John", :last_name => "Dough")
|
|
221
|
+
puts "First name is #{args.first_name}"
|
|
222
|
+
puts "Last name is #{args.last_name}"
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
=== Tasks that Expect Parameters and Have Prerequisites
|
|
226
|
+
|
|
227
|
+
Tasks that use parameters have a slightly different format for
|
|
228
|
+
prerequisites. Use the arrow notation to indicate the prerequisites
|
|
229
|
+
for tasks with arguments. For example:
|
|
230
|
+
|
|
231
|
+
task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
|
|
232
|
+
args.with_defaults(:first_name => "John", :last_name => "Dough")
|
|
233
|
+
puts "First name is #{args.first_name}"
|
|
234
|
+
puts "Last name is #{args.last_name}"
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
=== Deprecated Task Parameters Format
|
|
238
|
+
|
|
239
|
+
There is an older format for declaring task parameters that omitted
|
|
240
|
+
the task argument array and used the :needs keyword to introduce the
|
|
241
|
+
dependencies. That format is still supported for compatibility, but
|
|
242
|
+
is not recommended for use.
|
|
243
|
+
|
|
244
|
+
== Accessing Task Programatically
|
|
245
|
+
|
|
246
|
+
Sometimes it is useful to manipulate tasks programatically in a
|
|
247
|
+
Rakefile. To find a task object, use the <tt>:[]</tt> operator on the
|
|
248
|
+
<tt>Rake::Task</tt>.
|
|
249
|
+
|
|
250
|
+
=== Programmatic Task Example
|
|
251
|
+
|
|
252
|
+
For example, the following Rakefile defines two tasks. The :doit task
|
|
253
|
+
simply prints a simple "DONE" message. The :dont class will lookup
|
|
254
|
+
the doit class and remove (clear) all of its prerequisites and
|
|
255
|
+
actions.
|
|
256
|
+
|
|
257
|
+
task :doit do
|
|
258
|
+
puts "DONE"
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
task :dont do
|
|
262
|
+
Rake::Task[:doit].clear
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
Running this example:
|
|
266
|
+
|
|
267
|
+
$ rake doit
|
|
268
|
+
(in /Users/jim/working/git/rake/x)
|
|
269
|
+
DONE
|
|
270
|
+
$ rake dont doit
|
|
271
|
+
(in /Users/jim/working/git/rake/x)
|
|
272
|
+
$
|
|
273
|
+
|
|
274
|
+
The ability to programmatically manipulate tasks gives rake very
|
|
275
|
+
powerful meta-programming capabilities w.r.t. task execution, but
|
|
276
|
+
should be used with cation.
|
|
277
|
+
|
|
153
278
|
== Rules
|
|
154
279
|
|
|
155
280
|
When a file is named as a prerequisite, but does not have a file task
|
|
@@ -372,8 +497,6 @@ Or give it a glob pattern:
|
|
|
372
497
|
|
|
373
498
|
fl = FileList['*.rb']
|
|
374
499
|
|
|
375
|
-
|
|
376
|
-
|
|
377
500
|
== Odds and Ends
|
|
378
501
|
|
|
379
502
|
=== do/end verses { }
|
|
File without changes
|