I think I solved my own problem.

I had forgotten that the path is expanded by the buildr version of the
file task
and I need to add path_to or _ before the dependency is added to the task

>    task task_name => path_to(html)

Here is the working code, for good measure.

def asciidoc_task task_name, file_list, options={}
  file_list.each do |src|
    html = src.pathmap('%d/target/%n.html')
    pdf = src.pathmap('%d/target/%n.pdf')
    file _(html) => _(src) do
      asciidoc src, html
      puts src
      if options[:pdf]
        wkpdf html, pdf
      end
    end
    task task_name => _(html)
  end
end

Regards
Anders


On Tue, Jan 19, 2010 at 9:10 PM, Anders Janmyr <anders.jan...@jayway.com> wrote:
> Hi again,
>
> I have a task and it works as expected in Rake, but it fails when I am
> using buildr.
>
> # This is the task defined in docs.rake
> def asciidoc from, to
>  system "asciidoc --unsafe --out-file=#{to} #{from}"
> end
>
> def wkpdf from, to
>  system "wkpdf --source #{from} --output #{to} --format A4"
> end
>
>
> # Generates a task for generating html with asciidoc
> # file_list:: A FileList
> # options:: pdf => true, generate a pdf from the generated html
> def asciidoc_task task_name, file_list, options={}
>  file_list.each do |src|
>    html = src.pathmap('%d/target/%n.html')
>    pdf = src.pathmap('%d/target/%n.pdf')
>    file html => src do
>      asciidoc src, html
>      puts src
>      if options[:pdf]
>        wkpdf html, pdf
>      end
>    end
>    task task_name => html
>  end
> end
>
> This is how I use it:
> asciidoc_task :doc, FileList['docs/*.txt']
>
>
> when I run
> rake doc
> it works fine
>
> But when I run
> buildr doc
> I get an error saying that the dependency is not satisfied.
>
> Don't know how to build task 'docs/target/applications_and_nodes.html'
>
> Can I not use the file task in this way with buildr?
>
> Thankful for any help, it looks correct when I am debugging.
>
> Anders
>
>
> --
> http://anders.janmyr.com/
>



-- 
http://anders.janmyr.com/

Reply via email to