ITWissen.info - Tech know how online

another neat tool (Ant)

Ant is a build tool from the ApacheSoftware Foundation, which is available as open source software - currently in version 1.8.1 - at the link below. Build tools are used, among other things, to simplify the processes for compilation, maintenance, testing and installation. The Java-based Ant organizes with the help of a configuration file in particular the Build process of Java projects, can be used platform-independently and uses with the XML notation a general form to generate the Build files.

With Ant it concerns an established Build Tool, which was developed originally already in the year 1998 for the Build process of the Tomcat server by James Duncan Davidson. The name "Ant" stands as an abbreviation for "Another Neat Tool" or also in analogy to the insect Ant, whose characteristics are to stand symbolically for the tool. By the independence of a certain platform Ant needs for the execution in any case a current Java runtime environment( JRE); better still a Java Development Kit( JDK), so that all functions of Ant can be used.

If one places Ant in the series of other build management tools, the comparison with GNU Make suggests itself at first. Make is however in contrast to Ant not platform-independent, and needs for its function some external programs from the Unix environment. Like Ant, another build tool - Maven 2 - is implemented entirely in Java and is therefore platform-independent. Maven 2 consistently integrates the concepts of Ant, but takes a much more abstract view of the build process than Ant, and provides a powerful set of additional functionality for this purpose.

The task range of Ant consists fundamentally of the specification of different files, in order to apply then to these certain commands and/or operations as for example the Java Compiler to call, files copy or install as well as the production of archives. Thus Ant can be used, in order to generate on basis of the given Java source code finally a complete and installable application. The configuration of a build process is defined in an XML-based build file (by default it is the build.xml file).

Structure of a Build file in Ant

Structure of a Build file in Ant

The figure here first gives a rough overview of the basic elements of the build tool Ant.

Project

A project is the comprehensive object that implements a runtime environment for commands and operations and is represented by an XML build file. In a more complex project, each subproject has a separate build file.

Target

A target forms a modulation unit of Ant, groups one or more so-called tasks, and provides the container for the actual operations that are executed with the tasks. For the clear identification targets have a name, with which then also a build file can be structured clearly. Different attributes of the tag such as depends, if and unless realize a flow control of the target. Static properties can be defined using the depend attribute. Finally, the description attribute documents the function of a target.

Task

The actual executable operations are called tasks. Ant already provides a number of predefined tasks
  • ,
e.g. for ,
  • creation of documentation with Javadoc
, files, directories,
  • operations on archives or
  • for sending emails
. If a specific task is needed, it can be programmed in the form of Java classes and Ant can be extended by this task. However a considerable number of task packages already exists.

Property

Placeholders for a value or a character string are called properties in Ant. The concrete assignment can take place with call of the Build file with appropriate parameters or directly in the Build file. Properties can be used similar to variables in programming languages, and they generate the concrete runtime environment of a build file. Properties can be maintained by the way also in an external file and then be read in in the actual Build process. Ant offers beyond that a wealth of extended functionalities. In connection with the quality assurance of software still the JUnit Testing is to be mentioned here. With the task, Ant offers the possibility of executing one or more JUnit test(s) . Thereby the test results are merged and presented in a desired form. The task allows a build to be aborted or continued if a test fails.

Informations:
Englisch: another neat tool - Ant
Updated at: 09.04.2012
#Words: 726
Links: tool, open source software (OSS), link, Java, configuration (CFG)
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024