Apache Ant/Best Practices/Standard Targets

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Contents

[edit] Standard Targets

One of the things that you learn is that if you name things consistently between projects, it is much easier to find things you are looking for. When you work with other people, you also want to have targets that you both are familiar with.

[edit] build.xml

  1. Place your main build in a file called build.xml in the main directory of your project
  2. Do not put ANTreferences to local file systems (Windows C: etc) in your build file. Isolate these all in a local.properties file in the main directory

[edit] folder standards

  • src - the location of your source code
  • build - the output of a build process

[edit] standard ant targets

[edit] init

This target should create all temporary directories within the build folder

[edit] clean

This target should remove all compiled and intermediate files leaving only source files. It should remove anything that can be derived from other files. This would be run just prior to creating a zip file of the project.

[edit] build

This target should compile sources and perform transforms of raw data

[edit] install

The install target should be used to copy files to a testing or production system

[edit] Other Standards

Use the <description> element to describe what your target does.

If you have more than around 100 targets in your build file, it becomes unwieldy. You could consider calling a separate build file, but that adds other complications such as the dependancy between targets.