buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <boisv...@intalio.com>
Subject Re: How to define a task for all subprojects
Date Sun, 14 Jun 2009 00:03:25 GMT
Try Buildr::ant() instead of just ant()

alex


On Sat, Jun 13, 2009 at 3:22 PM, Martin Grotzke <
martin.grotzke@javakaffee.de> wrote:

> Hi Daniel,
>
> On Fri, 2009-06-12 at 10:36 -0500, Daniel Spiewak wrote:
> > In order to define a project-aware task which affects more than one
> project,
> > you will need to use the extension API.
> Ok, so I'll try that road.
>
> Can you help me with the issue regarding ant('foo')? As I wrote in my
> email:
> I'm already trying to create a Checkstyle extension that uses ant
> internally (ant('checkstyle') do |ant| ant.taskdef ...), but with this
> buildr complains about "undefined method `ant'"...
>
> I asume this is because ant() is an instance method on Buildr, and my
> extension does not have such an instance.
>
> My extension basically looks like
>
> ====================================================================
> require 'buildr/java'
> require 'buildr/java/ant'
>
> module CheckstyleAnt include Buildr::Extension
>
>  first_time do
>    # Define task not specific to any projet.
>    desc 'Check code conventions in current project'
>    Project.local_task('checkstyle')
>  end
>
>  before_define do |project|
>    # Define the loc task for this particular project.
>    task :checkstyle do |task|
>      ant('checkstyle') do |ant|
>          # define checkstyle task and target / execute
>      end
>
>    end
>  end
>
>  after_define do |project|
>  end
>
>  def checkstyle()
>    task('checkstyle')
>  end
>
> end
>
> class Buildr::Project
>  include CheckstyleAnt
> end
> ====================================================================
>
> And I just require this extension in my buildfile...
>
> What can I do to have ant() available in the extension?
>
> Thanx in advance,
> cheers,
> Martin
>
>
>
> >   Effectively, you will be triggering
> > the re-definition of that same task every time a new project is created.
> > You can embed the extension within your buildfile, so it really isn't a
> real
> > hardship.  To eliminate the project-name prefix (e.g. `buildr
> > myproject:checkstyle` as opposed to `buildr checkstyle` in the
> appropriate
> > directory), you must use the following invocation:
> >
> >   Project.local_task :checkstyle
> >
> > That should do the trick!
> >
> > Daniel
> >
> > On Fri, Jun 12, 2009 at 10:00 AM, Martin Grotzke <
> > martin.grotzke@javakaffee.de> wrote:
> >
> > > Hi,
> > >
> > > is it possible to define a task project wide, so that it's available to
> > > each submodule?
> > >
> > > In my case I want to define checkstyle once and have it available in
> > > each submodule. It would be great if I could invoke
> > >  buildr checkstyle
> > > directly in the submodule.
> > >
> > > Is this possible without creating an extension?
> > >
> > > I'm already trying to create a Checkstyle extension that uses ant
> > > internally (ant('checkstyle') do |ant| ant.taskdef ...), but with this
> > > buildr complains about "undefined method `ant'"...
> > >
> > > Thanx for your help,
> > > cheers,
> > > Martin
> > >
> > >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message