New feature that just made it to SVN (for 1.3):

Buildr follows a common convention for project layouts: Java source files
appear in *src/main/java* and compile to *target/classes*, resources are
copied over from *src/main/resources * and so forth.  Not all projects
follow this convention, so it's now possible to specify an alternative
project layout.

The default layout is available in *Layout.default*, and all projects
inherit it.  You can set *Layout.default* to your own layout, or define a
project to have a particular layout (recommended) using the
*:layout*property.  Projects inherit the layout of the parent project.
 For example:

define 'foo', :layout=>my_layout do
  ...
end

A layout is an object that implements the *expand* method.  The easiest way
to create a custom layout is to create a new Layout object and specify
alternative mappings, for example:

my_layout = Layout.new
my_layout[:source, :main, :java] = 'java'
my_layout[:source, :main, :resources] = 'resources'

Paths are expanded recursively, so you can also specify the above layout
using:

my_layout = Layout.new
my_layout[:source, :main] = ''

If you need anything more complex, you can always subclass *Layout* and add
special handling in the *expand* method, you'll find one such example in the
API documentation.

The built-in tasks expand lists of symbols into relative paths, using the
following convention:

   - *:source, :main, <lang/usage>* --  Directory containing source files
   for a given language/usage, for example, *:java*, *:resources*, *
   :webapp*.
   - *:**source, :test, <lang/usage>* -- Directory containing test files
   for a given language/usage, for example, *:java*, *:resources*.
   - *:target, :generated* -- Target directory for generated code
   (typically source code).
   - *:target, :main, <lang/usage>* -- Target directory for compiled
   code, for example, *:classes*, *:resources *.
   - *:target, :test, <lang/usage>* -- Target directory for compile test
   cases, for example, *:classes*, *:resources*.
   - *:reports, <framework/usage>* -- Target directory for generated
   reports, for example, *:junit*, *:coverage*.

All tasks are encouraged to use the same convention, and whenever possible,
we recommend using the project's *path_to* method to expand a list of
symbols into a path, or use the appropriate path when available, for
example:

define 'bad' do
  # This may not be the real target.
  puts 'Compiling to ' + path_to('target/classes')
  # This will break with different layouts.
  package(:jar).include 'src/main/etc/*'
end

define 'good' do
  # This is always the compiler's target.
  puts 'Compiling to ' + compile.target.to_s
  # This will work with different layouts.
  package(:jar).include path_to(:source, :main, :etc, '*')
end

Assaf

Reply via email to