< Apache Ant < Best Practices

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.

build.xml

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

Folder standards

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

Standard ant targets

init

This target should create all temporary directories within the build folder.

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, and in case of gremlins occurring during the build process.

build

This target should compile sources and perform transforms of raw data.

install

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

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 dependency between targets.

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.