Use Ant buildfile or a script to build your Eclipse project

Writing by on Tuesday, 5 of March , 2013 at 6:44 am

Let’s say you have a buildfile build.xml that builds your project and deploys to say Tomcat. Wouldn’t it be great to have Eclipse do that for your when you build the project within eclipse? Eclipse has this concept called Builders as part of your project properties that let’s you do just that.

  • Right Click the Project -> Properties -> Builders
  • Select New
  • Select Ant Builder
  • In the Main tab
  • Buildfile -> Browse Workspace… and select the Buildfile
  • Base Directory -> Browse Workspace… and select the Base Directory
  • In the Refreshtab
  • Check Refresh resources upon completion (recommended in most cases)
  • Select The project containing the resource or the option that suits you
  • In the Targetstab, select the desired targets from the buildfile

When you build (Ctrl+B) in eclipse, the specified ant target will be run for you and in my case, my application will be deployed to Tomcat.
If you want to run a script, you can do so by selecting Program instead of Ant Builder.

Here’s a screenshot of my Ant Builder.

Did you know you could also debug your Ant Script within Eclipse.
Another great post on IBM Developer Works.

Leave a comment

Category: Eclipse,Java

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.