multiple rake build files? large rake files

T

thufir

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
 
S

Stef Richards

thufir said:
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?
 
T

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

=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
 
T

Thufir

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top