Question

I think I'm going mad. Can anyone help?

I have the folder c:\project\bin I run the following to execute my rake script

cd C:\project
rake

In my rake script I have:

require 'rake/clean'
CLOBBER.include('bin')

task :default => [:compile]

task :compile do
    # do nothing
end

It doesn't delete the "bin" folder nor the contents of the "bin" folder. I'm running Ruby in Windows (1.86 or so) and installed rake using, gem install rake.

Have I missed something. I've tried --trace etc.. but get no feedback.

Was it helpful?

Solution

TL;DR: $ rake clobber


As the answer above said, they are not implicilty invoked. Here is an example, as you asked for.

~/deleteme$ cd project
total 8
-rw-r--r--@ 1 josh  staff  110 Jun 27 06:04 Rakefile


~/deleteme/project$ cat Rakefile
require 'rake/clean'
CLOBBER.include('bin')

task :default => ["compile"]

task :compile do
  mkdir 'bin'
end


~/deleteme/project$ rake
(in /Users/josh/deleteme/project)
mkdir bin


~/deleteme/project$ ls -l
total 8
-rw-r--r--@ 1 josh  staff  110 Jun 27 06:04 Rakefile
drwxr-xr-x  2 josh  staff   68 Jun 27 06:05 bin


~/deleteme/project$ rake -T
(in /Users/josh/deleteme/project)
rake clean    # Remove any temporary products.
rake clobber  # Remove any generated file.


~/deleteme/project$ rake clobber
(in /Users/josh/deleteme/project)
rm -r bin


~/deleteme/project$ ls -l
total 8
-rw-r--r--@ 1 josh  staff  110 Jun 27 06:04 Rakefile

OTHER TIPS

CLEAN nor CLOBBER are not implicit tasks - you must declare dependency or invoke them

For an easier way to do it, try

task :default => [:compile, :clobber]

instead of

task :default => ["compile"]

And then in your command-line you can just run

rake

Remember, in Ruby it is preferred to use Symbols instead of String literals

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top