buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <>
Subject Re: confused with enhance
Date Fri, 08 Oct 2010 14:08:14 GMT
Simplest way to add extensions is to drop them into the "tasks" directory.
 That way, they are required automatically.   (This is the convention over
configuration part).

Otherwise, you can simply require the extension that the top of your
buildfile, whether it's a gem or a file on your filesystem (in source
control or not).

To create an extension, simply create a module, include the Extension module
and mix it in the Project class:

# Place this file under tasks directory (e.g. tasks/my_extension.rb)
module Buildr
  module CopyJars
    include Extension

    # called for each project
    after_define(:copy_jars => :compile) do |project|

  class Project
    include CopyJars

And you can do similarly for your Eclipse task.

Is that what you had in mind for your refactoring?


On Fri, Oct 8, 2010 at 2:33 AM, Nikos Maris <> wrote:

> Newbie question: I would like to extend the default behavior of the compile
> task.
> I currently enhance the compile task of all sub-projects with a function
> that takes a project as an argument in order to access methods like _() and
> fields like compile.dependencies :
> projects.each do |proj|
>  proj.compile.enhance do copy_jars_to_lib proj; end
> end
> I would like to refactor this code and be able to commit that (e.g. adding
> an extension at ~/.buildr is not an option).
> I would like also to refactor the following code:
> projects.each do |proj|
> task :eclipse do unboundVAR proj; end
> end
> thank you for your time,
> Nikos

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