1

Does buildr have pre-defined variables, like capistrano, for directories like 'target', 'reports', etc? If not, rather than hard-coding the location of these directories, how else can we locate/determine these paths?

The end goal is to create a task that will on-the-fly create a file and insert it into the target directory.

tmore
  • 693
  • 1
  • 6
  • 6

3 Answers3

3

Buildr defines symbolic names for the special directories. The path_to (aka _) method accepts these symbolic names and automatically translates them into the paths for the current layout. E.g.,

define 'foo' do
  puts _(:target, :main, :classes)    # => /some/root/foo/target/classes
  puts path_to(:source, :main, :java) # => /some/root/foo/src/main/java
end

As Antoine noted in reply to another answer, there's a list of these symbolic names in the documentation.

Rhett Sutphin
  • 1,045
  • 8
  • 15
2

You can define a new layout and use it in your project.

The example of buildfile here:

my_layout = Layout.new
my_layout[:source, :main, :java] = 'java'
my_layout[:source, :main, :resources] = 'resources'
define 'foo', :layout=>my_layout do
    ...
end

Update
Link to Buildr's tutorial http://buildr.apache.org/extending.html#layouts

Radio Rogal
  • 462
  • 4
  • 9
  • 1
    With a link to Buildr's doc ? http://buildr.apache.org/extending.html#layouts As always, bug reports and enhancements are welcome, please help us refine the doc if things are missing. – Antoine Toulme Jul 12 '11 at 18:31
  • @Antoine Toulme: Thanks for the link. I originally didn't review that portion of the documentation since it fell under "Extending Buildr" and "Using Alternative Layouts" section headers, giving the impression that none of the content was related to using buildr's default conventions – tmore Jul 13 '11 at 20:43
0

As UR6LAD says, buildr stores all its paths in a per-project instance of Layout. This page describes the default layout. The target directory can be accessed using layout[:target].

jackrabbit
  • 5,525
  • 1
  • 27
  • 38