September 2011

Getting to know Ant: Part II

Assuming you read the last post, you should have a basic understanding of projects, targets and tasks. In this post, some different tasks, and try to make a slightly more practical ant script. Suppose our build requires a little bit more complexity than displaying "Hello World." In this case, it has to meet the following requirements:

  1. The file HelloWorld.java must be compiled
  2. HelloWorld.class should include debug symbols.
  3. HelloWorld.class must be zipped

Let's start by creating a basic project skeleton. For right now, we'll only include one target: "build". Remember to save your project in "build.xml".

  1. <project name="HelloBuilder" default="build">
  2. <target name="build">
  3. </target>
  4. </project>

At this point, you've doubtlessly realized that unless we learn new tasks, we will be doomed to writing useless ant scripts forever...