testing rake

R

Raphael Bauduin

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 ;-)

Thanks.

Raph
 
J

Jim Weirich

Raphael said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,364
Latest member
Stevanida

Latest Threads

Top