Apache Ant

Apache Ant (English for ant ) is a program written in Java for automatically generating executable computer programs from source code.

It serves the same purpose as the very popular make utility, namely the automated creation of installable software packages from existing source code, libraries, and other files. Ant is open source, launched as part of the Jakarta project and is now an Apache top-level project. Ant is a Apronym and stands for "Another Neat Tool" (English for "Still a nice tool "). Developed the first version of James Duncan Davidson, the 1999, a tool such as make for Java needed, while he developed the first J2EE reference implementation. Davidson also considered the father of Jakarta Tomcat. For him, the name " Ant " that can afford as a small program, just like the little ants, Large.

Description

In contrast to make Ant is written in Java and thus requires to run a Java Runtime Environment ( JRE).

Terms

Ant is controlled by an XML file, called build file. They usually called build.xml. In the build file a project ( German "Project" ) is defined. This is the root element of the XML file. For a software project exactly a build file and thus exactly an Ant Project should include.

The Ant Project contains targets ( German "targets" ). These are similar to functions in programming languages ​​and can from the outside, for example by the developer via the command line or the development environment, are called targeted. The targets should cover all at work arising in connection with a software project activities in their entirety. Dependencies can be defined between the targets, in accordance with the requirements of the dependencies. When calling a target Ant resolves these dependencies and the target operates accordingly. If you have defined a target that directly or indirectly has dependencies on other targets, it is sufficient to invoke this Ant and then performs all the steps necessary in the correct order.

In Project, a target can be specified as the default target. This is usually the target, which performs in the raw state or an intermediate state of the software project, the respective steps required to produce a runnable state.

A target consists of calling tasks ( German " tasks "). They are similar to commands in programming languages.

Syntax and interfaces

Since it is an XML file in the build file, its meaning does not depend on a tab, space, or path separators that are defined differently on different operating systems. This is particularly an improvement over the use of make makefiles.

Ant is an open system with defined interfaces, which can be extended by self-created tasks, for example. Many Java tools support Ant In addition, it can also be in your own applications - such as installation programs - Embed to assume a wide variety of mostly batch -like tasks.

Frequently used tasks

Ant contains more than 150 tasks, where you can program your own tasks in Java itself. This list contains some built-in (English " built-in" ) Tasks of Ant

  • Javac to compile the source code.
  • Copy to copy files.
  • Delete to delete files or directories.
  • Mkdir to create directories.
  • Junit for automated ( JUnit ) tests.
  • Move to rename files or directories.
  • Exec to run system programs. Important: When using this task is often going into the function of an operating system!
  • Zip for zipping, so to compress files.
  • CVS to perform CVS operations.
  • Mail to send e -mails.
  • Replace to replace text in files.

Flexible use is also the predefined task xslt to transform an XML file into, for example, an HTML file using a given XSLT file.

Examples of targets

While tasks are implemented as Java classes, targets are defined in XML and call tasks on. It can also create your own tasks in the form of Java classes are created.

The following excerpt from a typical build file shows two targets: build creates a directory and compiled a set of Java classes into it. It depends on another target from clean, previously some directories and files deleted to eliminate remnants of previous calls.

72815
de