[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

multiple rake build files? large rake files

Thufir Hawat

3/28/2008 6:52:00 AM

I'm using rake to build small java applications and have hit the ceiling,
or my ceiling, for how "large" a single file should be. I want to break
my rake files into pieces somehow, and even have multiple rake files
dependant on each other, perhaps (or maybe independent).

It's arbitrary, but can I have Rakefile call Rakefile.rb? That seems
absurd and a total kludge, but can it be done? Should I be using modules?

I'm aware of other, and probably better, tools for building java code
with, but want to stick with rake for the time being.

Can I do something with namespaces?

Part of the requirement which I have in mind is to build one java package
into Foo.jar and then another package in Bar.java, as seperate actions,
and then maybe have Baz.jar import Foo.jar and Bar.jar as external jar
files. I envision this as three independent build processes calling for
three rake files with different particulars. I wouldn't want cram all
that into one rakefile.


thanks,

Thufir


3 Answers

Stef Richards

3/28/2008 11:55:00 PM

0

thufir wrote:
> I'm using rake to build small java applications and have hit the ceiling,
> or my ceiling, for how "large" a single file should be. I want to break
> my rake files into pieces somehow, and even have multiple rake files
> dependant on each other, perhaps (or maybe independent).
>
> It's arbitrary, but can I have Rakefile call Rakefile.rb? That seems
> absurd and a total kludge, but can it be done? Should I be using modules?
>
> I'm aware of other, and probably better, tools for building java code
> with, but want to stick with rake for the time being.
>
> Can I do something with namespaces?
>
> Part of the requirement which I have in mind is to build one java package
> into Foo.jar and then another package in Bar.java, as seperate actions,
> and then maybe have Baz.jar import Foo.jar and Bar.jar as external jar
> files. I envision this as three independent build processes calling for
> three rake files with different particulars. I wouldn't want cram all
> that into one rakefile.
>
>
> thanks,
>
> Thufir
>
>
The innards of a rake file (usually with an extension .rake by the way)
is just plain ruby, so you can break the code up as you want and just
require other files as and when you need them.

E.g. each task goes into a separate file

require 'this.rake'
require 'that.rake'
require 'the_other.rake'

desc 'do everything'
task :everything => [:this, :that, :the_other] do
normal ruby code
end


the files this.rake, that.rake, etc contain the task :this, :that

Alternitively, if they are not separate tasks, you can just call methods
which are defined in other files, and require the files before you call
the methods

require 'this.rake'
require 'that.rake
require 'the_other.rake'

desc 'do everything'
task :everything do
this
that
the_other
end

Or have I misunderstood the question?






Thufir Hawat

3/29/2008 9:29:00 PM

0

On Mar 28, 3:55=A0pm, Stef Richards <news.s.richa...@clara.net> wrote:
[...]
> The innards of a rake file (usually with an extension .rake by the way)
> is just plain ruby, so you can break the code up as you want and just
> require other files as and when you need them.
>
> E.g. each task goes into a separate file
>
> =A0 =A0 =A0require 'this.rake'
> =A0 =A0 =A0require 'that.rake'
> =A0 =A0 =A0require 'the_other.rake'
>
> =A0 =A0 =A0desc 'do everything'
> =A0 =A0 =A0task :everything =3D> [:this, :that, :the_other] do
> =A0 =A0 =A0 =A0 normal ruby code
> =A0 =A0 =A0end
>
> the files this.rake, that.rake, etc contain the task :this, :that
[...]
> Or have I misunderstood the question?


That was the question which you answered quite well :)


thanks,


Thufir

Thufir Hawat

4/12/2008 7:29:00 AM

0

Just for the record, here's the rake file:


thufir@arrakis:~/rake$
thufir@arrakis:~/rake$
thufir@arrakis:~/rake$ rake alc:all
(in /home/thufir/rake)
Purchased Vodka
Mixed Fuzzy Navel
Dood, everthing's blurry, can I halff noth'r drinnnk?
all
thufir@arrakis:~/rake$
thufir@arrakis:~/rake$ cat rakefile.rb
require 'alcoholic.rb'

namespace :alc do

task :all => :getSmashed do
puts "all"
end

end
thufir@arrakis:~/rake$
thufir@arrakis:~/rake$ cat alcoholic.rb
namespace :alc do

task :purchaseAlcohol do
puts "Purchased Vodka"
end

task :mixDrink => :purchaseAlcohol do
puts "Mixed Fuzzy Navel"
end

task :getSmashed => :mixDrink do
puts "Dood, everthing's blurry, can I halff noth'r drinnnk?"
end

end
thufir@arrakis:~/rake$
thufir@arrakis:~/rake$




-Thufir