multiple rake build files? large rake files

Discussion in 'Ruby' started by thufir, Mar 28, 2008.

  1. thufir

    thufir Guest

    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
    thufir, Mar 28, 2008
    #1
    1. Advertising

  2. 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?
    Stef Richards, Mar 28, 2008
    #2
    1. Advertising

  3. thufir

    Thufir Guest

    Re: multiple rake build files? large rake files

    On Mar 28, 3:55=A0pm, Stef Richards <> 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, Mar 29, 2008
    #3
  4. thufir

    Thufir Guest

    Re: multiple rake build files? large rake files

    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
    Thufir, Apr 12, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Van Dyk
    Replies:
    2
    Views:
    93
    Damphyr
    Jan 31, 2006
  2. peppermonkey
    Replies:
    1
    Views:
    226
    Gregory Brown
    Feb 10, 2007
  3. Adam Anderson
    Replies:
    1
    Views:
    121
    Adam Anderson
    Sep 19, 2007
  4. James Mead
    Replies:
    0
    Views:
    136
    James Mead
    Jan 15, 2008
  5. John Feminella
    Replies:
    0
    Views:
    227
    John Feminella
    Apr 25, 2010
Loading...

Share This Page