Triggering rails server, console and tasks

I would like to use something like FileUtils.uptodate?('last-update', 'pom.xml') to trigger an action like 'mvn dependency:copy-dependencies' before some rails commands like server, console, runner and tasks.

This would copy the Maven dependencies in a JRuby on Rails project whenever the dependencies are changed. This wouldn't work for SNAPSHOT changes but that is ok for me, since I would have another specific task for this.

But the question is: how to trigger those actions? I instantly thought in putting this in Gemfile, but maybe there is a better way for dealing with this situation in Rails 3. Is there?

Thanks in advance,

Rodrigo.