buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grotzke <martin.grot...@javakaffee.de>
Subject Re: How to generate sources for/before compile
Date Sat, 13 Jun 2009 22:05:25 GMT
On Fri, 2009-06-12 at 11:05 -0700, Alex Boisvert wrote:
> On Fri, Jun 12, 2009 at 6:12 AM, Martin Grotzke <
> martin.grotzke@javakaffee.de> wrote:
> 
> > I needed to wrap the ant project with the generate = task ..., as
> > otherwise (with just generate = ant('generate') do |ant| ...) the ant
> > project was directly executed (AFAICS with the loading of the buildfile)
> > and buildr complained with:
> >  Buildr aborted!
> >  Don't know how to build task 'Antwrap::AntProject[generate]'
> 
> 
> Ooops. I forgot ant() didn't yeld a task; it executes right away.
> 
> Do you think the stuff above is ok, so that we could push this to the
> > buildr howtos (wiki)? Or is there still room for improvement?
> 
> 
> I think the main improvement would be in wiring dependencies so the task
> only executes when needed.
> 
> Here's a revised version,
> 
> define "generate-sources-example" do
> 
>   # whatever you use to generate your sources
>   sources = Dir[_("src/main/yak") + "/**/*.yk"]
> 
>   generate = file(path_to(:target, "generated-source") => sources) do |dir|
>     mkdir_p dir.to_s # ensure directory is created
>     # generate sources
>     # e.g.
>     # ant('generate') do |ant|
>     #  ...
>     # end
>   end
> 
>   compile.from generate
> end
Thanx for this!

I have one question: What is "sources" for? From my understanding the
sources are generated _in_ (the body of) the generate task (a file task
in this case)?

Cheers,
Martin


> 
> I'm having issues creating the page in the wiki right now (confluence fails
> on me).  I'll create it when possible.
> 
> alex

Mime
View raw message