With Rails you can create custom Rake tasks (I recommend reading RailsEnvy for a tutorial for rake tasks).
Once you've got your task you can use it in your Rails build by adding the following line to your Rakefile in the Rails base directory:
Easy enough, but took me long enough to find it! Now when you run 'rake' in your rails projects, your custom tasks will be executed. Cool eh? Good for copying dependences and such.