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 Fri, 12 Jun 2009 13:12:26 GMT
Hi Alex,

On Thu, 2009-06-11 at 17:45 -0700, Alex Boisvert wrote:
> On Thu, Jun 11, 2009 at 4:25 PM, Martin Grotzke <
> martin.grotzke@javakaffee.de> wrote:
> 
> >
> > I'm just wondering what's the best way to generate sources before the
> > compile task is executed, whereas the generated sources shall also be
> > compiled.
> >
> > The additional sources are e.g. generated with an ant task:
> >
> > task :generatesources do
> >  ant('generate') do |ant|
> >    ant.taskdef :name=>'myTask', :classname=>'some.AntTask',
> > :classpath=>'path/to/jar.jar'
> >    ant.myTask :targetDir=>_('target/generated-sources'),
> > :someProp=>'some/path'
> >  end
> > end
> >
> 
> I think it would be something along these lines:
> 
> sources = # whatever you use to generate your sources
> 
> generate = ant('generate' => sources) do |ant|
>  # ...
> end
> 
> compile.from file(path_to(:target, "generated-source") => generate)

Now I have the following:

generate = task :generatesources do
  ant('generate') do |ant|
    ant.taskdef :name=>'myTask', :classname=>'some.AntTask', :classpath=>'path/to/jar.jar'
    ant.myTask :targetDir=>_('target/generated-sources'), :someProp=>_('src/main/resources/')
  end
end
    
compile.with( LIBS ).from( file( _('target/generated-sources') => generate ) )

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]'

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?

Cheers,
Martin


> 
> alex

Mime
View raw message