If you have complicated build files and have no clue what and how to refactor these files, check out the article I wrote at Javalobby called "Ant or Gant?".
This article explains the following in detail:
1. When to choose Gant?
2. What's Gant?
3. Getting Started with Gant.
Of course, you should know Groovy before you decide to runaway from Ant.