buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <alex.boisv...@gmail.com>
Subject Re: Layouts customized by project attributes
Date Sat, 20 Mar 2010 02:40:41 GMT
On Fri, Mar 19, 2010 at 4:49 PM, Peter Donald <peter@realityforge.org>wrote:

> Hi,
>
> My current usage of buildr has resulted in many subprojects. Some of
> these subprojects actually have no files as they simply repackaging
> jars as OSGi bundles (i.e. jars + more metadata). So I have decided to
> have a central "target" directory under which each project has a dir.
> i.e. The following snippet uses target/A and target/B as intermediate
> dirs of each project
>
> class CentralLayout < Layout::Default
>  def initialize(key, top_level = false)
>    super()
>    prefix = top_level ? '' : '../'
>    self[:target] = "#{prefix}target/#{key}"
>    self[:target, :main] = "#{prefix}target/#{key}"
>  end
> end
>
> define 'A', :layout => CentralLayout.new('A', true) do
>   ...
>   define 'B', :layout => CentralLayout.new('B') do
>      ...
>   end
> end
>
> Unfortunately I have to repeat the name of the project when
> constructing the layout. Is there any easy way to avoid this? The only
> way that I could think of is to make it an extension which is overkill
> atm (However I suspect by the time I reach the 20 or so subprojects it
> may be worthwhile).
>

Have you considered this simple solution?

def define_with_central_layout(name, &block)
  define(name, :layout => CentralLayout.new(name), &block)
end

alex

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