# Recursive Rake

**URL:** <https://www.ruby-forum.com/t/recursive-rake/95454>\
**Category:** Ruby\
**Created:** [December 6, 2005, 5:16pm UTC](https://www.ruby-forum.com/t/recursive-rake/95454 "2005-12-06T17:16:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanner.burson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@tanner.burson](https://www.ruby-forum.com/u/tanner.burson)\
**Post date:** [December 6, 2005, 5:16pm UTC](https://www.ruby-forum.com/t/recursive-rake/95454/1 "2005-12-06T17:16:41Z")

</div>

Hello all,

I’m working on a very large set of build tasks for several .NET  
projects.  
I’ve come up with a fairly simple rake script that with slight  
modification  
(differing includes, resources, output type, etc) is able to build any  
of  
the projects individually.

The problem is that I’m now to the point of building the larger outer  
project, which will in turn need to build several of the inner library  
projects. I’m unsure of the best way with Rake to handle this.

I know that with Make you could effectively recurse the directories,  
each  
having their own make files and use those to build the individual  
dependencies. I could simulate this behavior in Rake, but I’m not sure  
it’s  
neccessarily the best way. I’d also wondered about including the  
rakefile  
from the inner projects and just use the tasks from those in the outer  
file. A

nyone who has experience with this, or just ideas on how to handle this,  
I  
would appreciate comments. Thanks!

---

<div class="post-metadata">

**Author:** ![tanner.burson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@tanner.burson](https://www.ruby-forum.com/u/tanner.burson)\
**Post date:** [December 6, 2005, 5:33pm UTC](https://www.ruby-forum.com/t/recursive-rake/95454/2 "2005-12-06T17:33:10Z")

</div>

From: Tanner B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Recursive Rake  
Date: Wed, 7 Dec 2005 01:14:39 +0900

Hi,

I use Rake to make HTMLs from RDs, to upload a package to the server,  
to do unit tests, to announce a new version of package to ML, and so  
on. I have my original Rake task libraries for common use and  
`require’ the Rake library.

> neccessarily the best way. I’d also wondered about including the rakefile  
> from the inner projects and just use the tasks from those in the outer  
> Simply `load’ the inner rakefile to include another rakefile.

---

<div class="post-metadata">

**Author:** ![tanner.burson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@tanner.burson](https://www.ruby-forum.com/u/tanner.burson)\
**Post date:** [December 6, 2005, 6:44pm UTC](https://www.ruby-forum.com/t/recursive-rake/95454/3 "2005-12-06T18:44:59Z")

</div>

tanner.burson wrote:

> Hello all,
> 
> I’m working on a very large set of build tasks for several .NET  
> projects.  
> I’ve come up with a fairly simple rake script that with slight  
> modification  
> (differing includes, resources, output type, etc) is able to build any  
> of  
> the projects individually.
> 
> The problem is that I’m now to the point of building the larger outer  
> project, which will in turn need to build several of the inner library  
> projects. I’m unsure of the best way with Rake to handle this.

There was a recent discussion about this on the Rake mailing list.  
Different folks approached it in different ways. In particular, one  
person in that thread supports a HUGE build system using Rake. See  
[http://rubyforge.org/pipermail/rake-devel/2005-December/thread.html](http://rubyforge.org/pipermail/rake-devel/2005-December/thread.html) for  
details.

– Jim W.

---

<div class="post-metadata">

**Author:** ![tanner.burson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@tanner.burson](https://www.ruby-forum.com/u/tanner.burson)\
**Post date:** [December 6, 2005, 9:09pm UTC](https://www.ruby-forum.com/t/recursive-rake/95454/4 "2005-12-06T21:09:38Z")

</div>

On 12/6/05, Jim W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > the projects individually.
> > 
> > The problem is that I’m now to the point of building the larger outer  
> > project, which will in turn need to build several of the inner library  
> > projects. I’m unsure of the best way with Rake to handle this.
> 
> There was a recent discussion about this on the Rake mailing list.  
> Different folks approached it in different ways. In particular, one  
> person in that thread supports a HUGE build system using Rake. See  
> [http://rubyforge.org/pipermail/rake-devel/2005-December/thread.html](http://rubyforge.org/pipermail/rake-devel/2005-December/thread.html) for  
> details.

Thanks for the information Jim. I would definitely like to see more  
information regarding your change for loading the entire dependency  
graph in  
at once, as that’s more or less what I’d like to do.

– Jim W.

---

<div class="post-metadata">

**Author:** ![tanner.burson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@tanner.burson](https://www.ruby-forum.com/u/tanner.burson)\
**Post date:** [December 6, 2005, 9:01pm UTC](https://www.ruby-forum.com/t/recursive-rake/95454/5 "2005-12-06T21:01:25Z")

</div>

On Tuesday 06 December 2005 17:14, Tanner B. wrote:

> handle this.
> 
> I know that with Make you could effectively recurse the  
> directories, each having their own make files and use those to  
> build the individual dependencies. I could simulate this behavior  
> in Rake, but I’m not sure it’s neccessarily the best way. I’d also  
> wondered about including the rakefile from the inner projects and  
> just use the tasks from those in the outer file. A
> 
> nyone who has experience with this, or just ideas on how to handle  
> this, I would appreciate comments. Thanks!

Perhaps you want to try Rant, which is an alternative to Rake.  
It has all features of Rake and more. Support for the problem  
you described is built in to some degree.

Assuming there is a directory that contains the “inner projects”,  
it could have an Rantfile looking like:

```
inner_dirs = ["inner_project_1", "inner_project_2"]

desc "Run tests for all inner projects."
task :test => inner_dirs.map { |n| "#{n}/test" }

# load Rantfiles of inner projects
subdirs inner_dirs

```

And all inner project directories have an Rantfile that defines  
a “test” task, e.g. inner\_project\_1/Rantfile contains:

```
task :test do
    sys "command to run tests for this inner project"
end

```

Then from the outer directory, you can type:

```
$ rant test

```

to run the tests for all projects. To run the tests only  
for inner\_project\_1:

```
$ rant inner_project_1/test

```

or:

```
$ cd inner_project_1
$ rant test

```

Rant homepage: [http://make.ruby-co.de](http://make.ruby-co.de)  
Feature comparison to rake:  
[http://make.rubyforge.org/files/doc/rant\_vs\_rake\_rdoc.html](http://make.rubyforge.org/files/doc/rant_vs_rake_rdoc.html)

Regards,  
Stefan
