简体   繁体   中英

Rake::Tasks sources missed

I just start using Rake instead of Make for building my projects, and would like to use some kind of "task template" for automating the building.

Consider the following snippets:

task :test1 => ['1', '2']
task :test2 => ['3', '4']
Rake::Tasks.each do |task|
    p task
    p task.sources
end

The output is:

$ rake
<Rake::Task test1 => [1, 2]>
[]
<Rake::Task test2 => [3, 4]>
[]

My question is why task.sources is [] , that is the prerequisites are missed? Thanks in advance.

The prerequisites of a task are accessed with task.prerequisites . task.sources and task.source is only used for tasks that are built from a rule as described in the rdocs: http://ruby-doc.org/stdlib-2.1.2/libdoc/rake/rdoc/Rake/Task.html#method-i-source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM