rake 0.9.2.2 → 13.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/History.rdoc +2403 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +64 -106
  5. data/doc/command_line_usage.rdoc +65 -21
  6. data/doc/glossary.rdoc +40 -49
  7. data/doc/jamis.rb +1 -0
  8. data/doc/rake.1 +156 -0
  9. data/doc/rakefile.rdoc +127 -62
  10. data/{bin → exe}/rake +1 -7
  11. data/lib/rake/application.rb +507 -271
  12. data/lib/rake/backtrace.rb +24 -0
  13. data/lib/rake/clean.rb +54 -8
  14. data/lib/rake/cloneable.rb +11 -19
  15. data/lib/rake/cpu_counter.rb +107 -0
  16. data/lib/rake/default_loader.rb +5 -0
  17. data/lib/rake/dsl_definition.rb +67 -48
  18. data/lib/rake/early_time.rb +5 -1
  19. data/lib/rake/ext/core.rb +5 -6
  20. data/lib/rake/ext/string.rb +61 -52
  21. data/lib/rake/file_creation_task.rb +4 -3
  22. data/lib/rake/file_list.rb +81 -49
  23. data/lib/rake/file_task.rb +15 -8
  24. data/lib/rake/file_utils.rb +63 -43
  25. data/lib/rake/file_utils_ext.rb +14 -25
  26. data/lib/rake/invocation_chain.rb +25 -19
  27. data/lib/rake/invocation_exception_mixin.rb +1 -0
  28. data/lib/rake/late_time.rb +18 -0
  29. data/lib/rake/linked_list.rb +112 -0
  30. data/lib/rake/loaders/makefile.rb +23 -9
  31. data/lib/rake/multi_task.rb +4 -6
  32. data/lib/rake/name_space.rb +36 -23
  33. data/lib/rake/packagetask.rb +71 -34
  34. data/lib/rake/phony.rb +16 -0
  35. data/lib/rake/private_reader.rb +21 -0
  36. data/lib/rake/promise.rb +100 -0
  37. data/lib/rake/pseudo_status.rb +8 -2
  38. data/lib/rake/rake_module.rb +41 -3
  39. data/lib/rake/rake_test_loader.rb +9 -4
  40. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  41. data/lib/rake/scope.rb +43 -0
  42. data/lib/rake/task.rb +186 -79
  43. data/lib/rake/task_argument_error.rb +1 -0
  44. data/lib/rake/task_arguments.rb +46 -15
  45. data/lib/rake/task_manager.rb +91 -67
  46. data/lib/rake/tasklib.rb +2 -12
  47. data/lib/rake/testtask.rb +61 -63
  48. data/lib/rake/thread_history_display.rb +49 -0
  49. data/lib/rake/thread_pool.rb +163 -0
  50. data/lib/rake/trace_output.rb +23 -0
  51. data/lib/rake/version.rb +5 -3
  52. data/lib/rake/win32.rb +14 -18
  53. data/lib/rake.rb +35 -33
  54. data/rake.gemspec +100 -0
  55. metadata +74 -176
  56. data/.gemtest +0 -0
  57. data/CHANGES +0 -522
  58. data/Rakefile +0 -369
  59. data/TODO +0 -20
  60. data/doc/rake.1.gz +0 -0
  61. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  62. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  63. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  64. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  65. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  66. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  67. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  68. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  69. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  70. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  71. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  72. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  73. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  74. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  75. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  76. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  77. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  78. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  79. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  80. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  81. data/install.rb +0 -90
  82. data/lib/rake/alt_system.rb +0 -109
  83. data/lib/rake/classic_namespace.rb +0 -11
  84. data/lib/rake/contrib/compositepublisher.rb +0 -21
  85. data/lib/rake/contrib/ftptools.rb +0 -150
  86. data/lib/rake/contrib/publisher.rb +0 -73
  87. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  88. data/lib/rake/contrib/sshpublisher.rb +0 -50
  89. data/lib/rake/contrib/sys.rb +0 -191
  90. data/lib/rake/ext/module.rb +0 -39
  91. data/lib/rake/ext/time.rb +0 -14
  92. data/lib/rake/gempackagetask.rb +0 -15
  93. data/lib/rake/pathmap.rb +0 -1
  94. data/lib/rake/rdoctask.rb +0 -234
  95. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  96. data/lib/rake/runtest.rb +0 -21
  97. data/test/file_creation.rb +0 -34
  98. data/test/helper.rb +0 -492
  99. data/test/test_rake.rb +0 -40
  100. data/test/test_rake_application.rb +0 -489
  101. data/test/test_rake_application_options.rb +0 -335
  102. data/test/test_rake_clean.rb +0 -14
  103. data/test/test_rake_definitions.rb +0 -80
  104. data/test/test_rake_directory_task.rb +0 -46
  105. data/test/test_rake_dsl.rb +0 -77
  106. data/test/test_rake_early_time.rb +0 -31
  107. data/test/test_rake_extension.rb +0 -59
  108. data/test/test_rake_file_creation_task.rb +0 -56
  109. data/test/test_rake_file_list.rb +0 -628
  110. data/test/test_rake_file_list_path_map.rb +0 -8
  111. data/test/test_rake_file_task.rb +0 -102
  112. data/test/test_rake_file_utils.rb +0 -305
  113. data/test/test_rake_ftp_file.rb +0 -59
  114. data/test/test_rake_functional.rb +0 -450
  115. data/test/test_rake_invocation_chain.rb +0 -52
  116. data/test/test_rake_makefile_loader.rb +0 -44
  117. data/test/test_rake_multi_task.rb +0 -51
  118. data/test/test_rake_name_space.rb +0 -43
  119. data/test/test_rake_package_task.rb +0 -79
  120. data/test/test_rake_path_map.rb +0 -157
  121. data/test/test_rake_path_map_explode.rb +0 -34
  122. data/test/test_rake_path_map_partial.rb +0 -18
  123. data/test/test_rake_pseudo_status.rb +0 -21
  124. data/test/test_rake_rake_test_loader.rb +0 -21
  125. data/test/test_rake_rdoc_task.rb +0 -83
  126. data/test/test_rake_require.rb +0 -40
  127. data/test/test_rake_rules.rb +0 -327
  128. data/test/test_rake_task.rb +0 -267
  129. data/test/test_rake_task_argument_parsing.rb +0 -103
  130. data/test/test_rake_task_arguments.rb +0 -88
  131. data/test/test_rake_task_lib.rb +0 -9
  132. data/test/test_rake_task_manager.rb +0 -157
  133. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  134. data/test/test_rake_task_with_arguments.rb +0 -173
  135. data/test/test_rake_test_task.rb +0 -120
  136. data/test/test_rake_top_level_functions.rb +0 -111
  137. data/test/test_rake_win32.rb +0 -72
  138. data/test/test_sys.rb +0 -20
data/doc/rakefile.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Rakefile Format (as of version 0.8.7)
1
+ = Rakefile Format
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
@@ -30,9 +30,9 @@ parameter that is the name of the task.
30
30
  Any prerequisites are given as a list (enclosed in square brackets)
31
31
  following the name and an arrow (=>).
32
32
 
33
- task :name => [:prereq1, :prereq2]
33
+ task name: [:prereq1, :prereq2]
34
34
 
35
- <b>NOTE:</b> Although this syntax looks a little funky, it is legal
35
+ *NOTE:* Although this syntax looks a little funky, it is legal
36
36
  Ruby. We are constructing a hash where the key is :name and the value
37
37
  for that key is the list of prerequisites. It is equivalent to the
38
38
  following ...
@@ -41,13 +41,27 @@ following ...
41
41
  hash[:name] = [:prereq1, :prereq2]
42
42
  task(hash)
43
43
 
44
+ You can also use strings for task names and prerequisites, rake doesn't care.
45
+ This is the same task definition:
46
+
47
+ task 'name' => %w[prereq1 prereq2]
48
+
49
+ As is this:
50
+
51
+ task name: %w[prereq1 prereq2]
52
+
53
+ We'll prefer this style for regular tasks with prerequisites throughout the
54
+ rest of the document. Using an array of strings for the prerequisites means
55
+ you will need to make fewer changes if you need to move tasks into namespaces
56
+ or perform other refactorings.
57
+
44
58
  === Tasks with Actions
45
59
 
46
60
  Actions are defined by passing a block to the +task+ method. Any Ruby
47
61
  code can be placed in the block. The block may reference the task
48
62
  object via the block parameter.
49
63
 
50
- task :name => [:prereq1, :prereq2] do |t|
64
+ task name: [:prereq1, :prereq2] do |t|
51
65
  # actions (may reference t)
52
66
  end
53
67
 
@@ -62,8 +76,8 @@ For example, the following is equivalent to the single task
62
76
  specification given above.
63
77
 
64
78
  task :name
65
- task :name => [:prereq1]
66
- task :name => [:prereq2]
79
+ task name: :prereq1
80
+ task name: %w[prereq2]
67
81
  task :name do |t|
68
82
  # actions
69
83
  end
@@ -79,8 +93,8 @@ method). In addition, file tasks are usually named with a string
79
93
  rather than a symbol.
80
94
 
81
95
  The following file task creates a executable program (named +prog+)
82
- given two object files name <tt>a.o</tt> and <tt>b.o</tt>. The tasks
83
- for creating <tt>a.o</tt> and <tt>b.o</tt> are not shown.
96
+ given two object files named +a.o+ and +b.o+. The tasks
97
+ for creating +a.o+ and +b.o+ are not shown.
84
98
 
85
99
  file "prog" => ["a.o", "b.o"] do |t|
86
100
  sh "cc -o #{t.name} #{t.prerequisites.join(' ')}"
@@ -97,9 +111,9 @@ that creates the directory. For example, the following declaration
97
111
 
98
112
  is equivalent to ...
99
113
 
100
- file "testdata" do |t| mkdir t.name end
101
- file "testdata/examples" do |t| mkdir t.name end
102
- file "testdata/examples/doc" do |t| mkdir t.name end
114
+ file "testdata" do |t| mkdir t.name end
115
+ file "testdata/examples" => ["testdata"] do |t| mkdir t.name end
116
+ file "testdata/examples/doc" => ["testdata/examples"] do |t| mkdir t.name end
103
117
 
104
118
  The +directory+ method does not accept prerequisites or actions, but
105
119
  both prerequisites and actions can be added later. For example ...
@@ -114,7 +128,7 @@ both prerequisites and actions can be added later. For example ...
114
128
 
115
129
  Rake allows parallel execution of prerequisites using the following syntax:
116
130
 
117
- multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do
131
+ multitask copy_files: %w[copy_src copy_doc copy_bin] do
118
132
  puts "All Copies Complete"
119
133
  end
120
134
 
@@ -133,9 +147,9 @@ until the common prerequisites have been run.
133
147
  For example, if the <tt>copy_<em>xxx</em></tt> tasks have the
134
148
  following prerequisites:
135
149
 
136
- task :copy_src => [:prep_for_copy]
137
- task :copy_bin => [:prep_for_copy]
138
- task :copy_doc => [:prep_for_copy]
150
+ task copy_src: :prep_for_copy
151
+ task copy_bin: :prep_for_copy
152
+ task copy_doc: :prep_for_copy
139
153
 
140
154
  Then the +prep_for_copy+ task is run before starting all the copies in
141
155
  parallel. Once +prep_for_copy+ is complete, +copy_src+, +copy_bin+,
@@ -175,7 +189,7 @@ arguments can be passed by separating them with a comma, for example:
175
189
 
176
190
  Just a few words of caution. The rake task name and its arguments
177
191
  need to be a single command line argument to rake. This generally
178
- means no spaces. If spaces are needed, then the entire rake +
192
+ means no spaces. If spaces are needed, then the entire name +
179
193
  argument string should be quoted. Something like this:
180
194
 
181
195
  rake "name[billy bob, smith]"
@@ -183,22 +197,6 @@ argument string should be quoted. Something like this:
183
197
  (Quoting rules vary between operating systems and shells, so make sure
184
198
  you consult the proper docs for your OS/shell).
185
199
 
186
- === Tasks Arguments and the Environment
187
-
188
- Task argument values can also be picked up from the environment. For
189
- example, if the "release" task expected a parameter named
190
- "release_version", then either
191
-
192
- rake release[0.8.2]
193
-
194
- or
195
-
196
- RELEASE_VERSION rake release
197
-
198
- will work. Environment variable names must either match the task
199
- parameter exactly, or match an all-uppercase version of the task
200
- parameter.
201
-
202
200
  === Tasks that Expect Parameters
203
201
 
204
202
  Parameters are only given to tasks that are setup to expect them. In
@@ -225,9 +223,7 @@ behaviour can now accept a second parameter:
225
223
  The first argument of the block "t" is always bound to the current
226
224
  task object. The second argument "args" is an open-struct like object
227
225
  that allows access to the task arguments. Extra command line
228
- arguments to a task are ignored. Missing command line arguments are
229
- picked up from matching environment variables. If there are no
230
- matching environment variables, they are given the nil value.
226
+ arguments to a task are ignored.
231
227
 
232
228
  If you wish to specify default values for the arguments, you can use
233
229
  the with_defaults method in the task body. Here is the above example
@@ -251,6 +247,25 @@ for tasks with arguments. For example:
251
247
  puts "Last name is #{args.last_name}"
252
248
  end
253
249
 
250
+ === Tasks that take Variable-length Parameters
251
+
252
+ Tasks that need to handle a list of values as a parameter can use the
253
+ extras method of the args variable. This allows for tasks that can
254
+ loop over a variable number of values, and its compatible with named
255
+ parameters as well:
256
+
257
+ task :email, [:message] do |t, args|
258
+ mail = Mail.new(args.message)
259
+ recipients = args.extras
260
+ recipients.each do |target|
261
+ mail.send_to(target)
262
+ end
263
+ end
264
+
265
+ There is also the convenience method to_a that returns all parameters
266
+ in the sequential order they were given, including those associated
267
+ with named parameters.
268
+
254
269
  === Deprecated Task Parameters Format
255
270
 
256
271
  There is an older format for declaring task parameters that omitted
@@ -262,8 +277,7 @@ versions of rake.
262
277
  == Accessing Task Programmatically
263
278
 
264
279
  Sometimes it is useful to manipulate tasks programmatically in a
265
- Rakefile. To find a task object, use the <tt>:[]</tt> operator on the
266
- <tt>Rake::Task</tt>.
280
+ Rakefile. To find a task object use Rake::Task.[].
267
281
 
268
282
  === Programmatic Task Example
269
283
 
@@ -291,7 +305,7 @@ Running this example:
291
305
 
292
306
  The ability to programmatically manipulate tasks gives rake very
293
307
  powerful meta-programming capabilities w.r.t. task execution, but
294
- should be used with cation.
308
+ should be used with caution.
295
309
 
296
310
  == Rules
297
311
 
@@ -332,18 +346,18 @@ The following rule is equivalent to the example above.
332
346
  sh "cc #{t.source} -c -o #{t.name}"
333
347
  end
334
348
 
335
- <b>NOTE:</b> Because of a _quirk_ in Ruby syntax, parenthesis are
349
+ *NOTE:* Because of a _quirk_ in Ruby syntax, parenthesis are
336
350
  required on *rule* when the first argument is a regular expression.
337
351
 
338
352
  The following rule might be used for Java files ...
339
353
 
340
- rule '.java' => [
354
+ rule '.class' => [
341
355
  proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') }
342
356
  ] do |t|
343
357
  java_compile(t.source, t.name)
344
358
  end
345
359
 
346
- <b>NOTE:</b> +java_compile+ is a hypothetical method that invokes the
360
+ *NOTE:* +java_compile+ is a hypothetical method that invokes the
347
361
  java compiler.
348
362
 
349
363
  == Importing Dependencies
@@ -354,23 +368,18 @@ required file are just added to the definitions already accumulated.
354
368
 
355
369
  Because the files are loaded _before_ the rake targets are evaluated,
356
370
  the loaded files must be "ready to go" when the rake command is
357
- invoked. This make generated dependency files difficult to use. By
371
+ invoked. This makes generated dependency files difficult to use. By
358
372
  the time rake gets around to updating the dependencies file, it is too
359
373
  late to load it.
360
374
 
361
- The +Rake.import+ command addresses this by specifying a file to be
362
- loaded _after_ the main rakefile is loaded, but _before_ any targets
363
- on the command line are invoked. In addition, if the file name
364
- matches an explicit task, that task is invoked before loading the
365
- file. This allows dependency files to be generated and used in a
366
- single rake command invocation.
367
-
368
- <b>NOTE:</b> Starting in Rake version 0.9.0, the top level +import+
369
- command is deprecated and we recommend using the scoped
370
- "+Rake.import+" command mentioned above. Future versions of Rake will
371
- drop support for the top level +import+ command.
375
+ The +import+ command addresses this by specifying a file to be loaded
376
+ _after_ the main rakefile is loaded, but _before_ any targets on the
377
+ command line are invoked. In addition, if the file name matches an
378
+ explicit task, that task is invoked before loading the file. This
379
+ allows dependency files to be generated and used in a single rake
380
+ command invocation.
372
381
 
373
- === Example:
382
+ Example:
374
383
 
375
384
  require 'rake/loaders/makefile'
376
385
 
@@ -378,7 +387,7 @@ drop support for the top level +import+ command.
378
387
  sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
379
388
  end
380
389
 
381
- Rake.import ".depends.mf"
390
+ import ".depends.mf"
382
391
 
383
392
  If ".depends" does not exist, or is out of date w.r.t. the source
384
393
  files, a new ".depends" file is generated using +makedepend+ before
@@ -391,17 +400,17 @@ legal in Ruby source code, including comments for tasks and rules.
391
400
  However, if you wish a task to be described using the "-T" switch,
392
401
  then you need to use the +desc+ command to describe the task.
393
402
 
394
- === Example:
403
+ Example:
395
404
 
396
405
  desc "Create a distribution package"
397
- task :package => [ ... ] do ... end
406
+ task package: %w[ ... ] do ... end
398
407
 
399
408
  The "-T" switch (or "--tasks" if you like to spell things out) will
400
409
  display a list of tasks that have a description. If you use +desc+ to
401
410
  describe your major tasks, you have a semi-automatic way of generating
402
411
  a summary of your Rake file.
403
412
 
404
- traken$ rake -T
413
+ $ rake -T
405
414
  (in /home/.../rake)
406
415
  rake clean # Remove any temporary products.
407
416
  rake clobber # Remove any generated file.
@@ -426,8 +435,7 @@ common for task names to begin to clash. For example, if you might
426
435
  have a main program and a set of sample programs built by a single
427
436
  Rakefile. By placing the tasks related to the main program in one
428
437
  namespace, and the tasks for building the sample programs in a
429
- different namespace, the task names will not will not interfere with
430
- each other.
438
+ different namespace, the task names will not interfere with each other.
431
439
 
432
440
  For example:
433
441
 
@@ -443,12 +451,12 @@ For example:
443
451
  end
444
452
  end
445
453
 
446
- task :build => ["main:build", "samples:build"]
454
+ task build: %w[main:build samples:build]
447
455
 
448
456
  Referencing a task in a separate namespace can be achieved by
449
457
  prefixing the task name with the namespace and a colon
450
458
  (e.g. "main:build" refers to the :build task in the +main+ namespace).
451
- Nested namespaces are supported, so
459
+ Nested namespaces are supported.
452
460
 
453
461
  Note that the name given in the +task+ command is always the unadorned
454
462
  task name without any namespace prefixes. The +task+ command always
@@ -550,6 +558,63 @@ This is the proper way to specify the task ...
550
558
  # Actions go here
551
559
  end
552
560
 
561
+ == Rakefile Path
562
+
563
+ When issuing the +rake+ command in a terminal, Rake will look
564
+ for a Rakefile in the current directory. If a Rakefile is not found,
565
+ it will search parent directories until one is found.
566
+
567
+ For example, if a Rakefile resides in the +project/+ directory,
568
+ moving deeper into the project's directory tree will not have an adverse
569
+ effect on rake tasks:
570
+
571
+ $ pwd
572
+ /home/user/project
573
+
574
+ $ cd lib/foo/bar
575
+ $ pwd
576
+ /home/user/project/lib/foo/bar
577
+
578
+ $ rake run_pwd
579
+ /home/user/project
580
+
581
+ As far as rake is concerned, all tasks are run from the directory in
582
+ which the Rakefile resides.
583
+
584
+ === Multiple Rake Files
585
+
586
+ Not all tasks need to be included in a single Rakefile. Additional
587
+ rake files (with the file extension "+.rake+") may be placed in
588
+ +rakelib+ directory located at the top level of a project (i.e.
589
+ the same directory that contains the main +Rakefile+).
590
+
591
+ Also, rails projects may include additional rake files in the
592
+ +lib/tasks+ directory.
593
+
594
+ === Clean and Clobber Tasks
595
+
596
+ Through <tt>require 'rake/clean'</tt> Rake provides +clean+ and +clobber+
597
+ tasks:
598
+
599
+ +clean+ ::
600
+ Clean up the project by deleting scratch files and backup files. Add files
601
+ to the +CLEAN+ FileList to have the +clean+ target handle them.
602
+
603
+ +clobber+ ::
604
+ Clobber all generated and non-source files in a project. The task depends
605
+ on +clean+, so all the +CLEAN+ files will be deleted as well as files in the
606
+ +CLOBBER+ FileList. The intent of this task is to return a project to its
607
+ pristine, just unpacked state.
608
+
609
+ You can add file names or glob patterns to both the +CLEAN+ and +CLOBBER+
610
+ lists.
611
+
612
+ === Phony Task
613
+
614
+ The phony task can be used as a dependency to allow file-based tasks to use
615
+ non-file-based-tasks as prerequisites without forcing them to rebuild. You
616
+ can <tt>require 'rake/phony'</tt> to add the +phony+ task.
617
+
553
618
  ----
554
619
 
555
620
  == See
data/{bin → exe}/rake RENAMED
@@ -22,12 +22,6 @@
22
22
  # IN THE SOFTWARE.
23
23
  #++
24
24
 
25
- begin
26
- require 'rubygems'
27
- gem 'rake'
28
- rescue LoadError
29
- end
30
-
31
- require 'rake'
25
+ require "rake"
32
26
 
33
27
  Rake.application.run