Raphael Bauduin wrote:
> I'm testing rake. I found it promising, but I've got I problem with 
> defining a rule.
> 
> I take the example of the website but get an error. Here is what I do:
> 
> rb@bidibule:~/test$ rake -V
> rake, version 0.3.1
> 
> rb@bidibule:~/test$ cat rakefile
> rule '.java' => [
>   proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') }
> ] do |t|
>   puts "source = #{t.source}"
> end
> 
> rb@bidibule:~/test$ rake gf.java
> (in /home/rb/test)
> rake aborted!
> Don't know how to rake gf.java
> 
> 
> Shouldn't it print something like
> source = gf
> 
> 
> Hoping I didn't miss something obvious in the docs ;-)

No, the docs are wrong.  There was a typo in the rule.  It should state 
that the class files are dependent on the source files, not that the 
source file is dependent on the source file (duh).

The following works for me ...

   JAVASRC = FileList['src/**/*.java']
   JAVACLASSES = JAVASRC.gsub(/java$/, 'class').gsub(/^src/, 'classes')

   task :default => JAVACLASSES

   rule '.class' => [
     proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') }
   ] do |t|
       puts "source = #{t.source}, target=#{t.name}"
   end

Where did you see that in the docs?  I'll correct it.

-- 
-- Jim Weirich       jweirich / one.net      http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)