|
Apache Ant is a software tool for automating software build processes. It is similar to make but is written in the Java language and is primarily intended for use with Java. The most immediately noticeable difference between Ant and make is that Ant uses XML to describe the build process and its dependencies, whereas make has its Makefile format. By default the XML file is named build.xml.Ant is an Apache project. It is open source software, and is released under the Apache Software License.
History Ant was conceived by James Duncan Davidson while turning a product from Sun into open source. The product later became Apache Tomcat; it was Sun's reference JSP/Servlet engine. The closed source 'make' tool could be used to build it on the Solaris Operating Environment, but in the open source world there was no way of controlling which platform was used to build Tomcat. Ant was created as a simple tool to take an XML "build file" and use it to build Tomcat, regardless of which platform the developer was using. From this humble beginning, the tool has gone on to become more ubiquitous - and perhaps successful - than the Tomcat product for which it was created. Ant was first officially released as a stand-alone product on July 19, 2000, with Ant 1.1. It has come to be the underpinning of open source Java; developers expect a "build.xml" file with every project. Because it makes it trivial to integrate JUnit tests with the build process, Ant has made it easy for willing developers to adopt test-driven development, and even Extreme Programming. Other Java-based build tools include Maven and JavaMake *. The name is said to be an acronym for "Another Neat Tool". Coincidentally, the word "ant" was also used as an arbitrarily chosen project name in the paper Recursive Make Considered Harmful *, which described build-related problems that Apache Ant later proposed to resolve. Sample Below is listed a sample build.xml file for a simple Java "Hello, world" application. It defines three targets - clean, compile and jar, each of which has an associated description. The jar target lists the compile target as a dependency. This tells Ant that before it can start the jar target it must first complete the compile target. Within each target are the actions that Ant must take to build that target; these are performed using built-in tasks. For example, to build the compile target Ant must first create a directory called classes (Ant will only do so if it does not already exist) and then invoke the Java compiler. Therefore, the tasks used are mkdir and javac. These perform a similar task to the command-line utilities of the same name. Another task used in this example is named jar: This ant task has the same name as the common java command-line utility, but is really a call to the ant program's predefined library. Most likely, this function in turn then calls the command-line utility behind the scenes, as is true of many of ant's tasks. Extensions WOProject is just one of many examples of a task extension written for ant. These extensions are put to use by copying their jar files into ant's lib directory. Once this is done, these extension tasks can be invoked directly in the typical build.xml file. The WOProject extensions allow WebObjects developers to use ant in building their frameworks and applications, instead of using Apple's outdated XCode suite. Other task extensions exist for Perforce, .Net, EJB, filesystem manipulations, just to name a few. Portability One of the primary aims of Ant was to solve make's portability problems. In a Makefile the actions required to create a target are specified as shell commands which are specific to the current platform, usually a Unix shell. Ant solves this problem by providing a large amount of built-in functionality which it can then guarantee will behave (nearly) identically on all platforms. For example, in the sample build.xml file above the clean target deletes the classes directory and everything in it. In a Makefile this would typically be done with the command:rm -rf classes/ rm is a Unix specific command which will probably not be available if the Makefile is used in a non-Unix environment such as Microsoft Windows. In an Ant build file the same thing would be accomplished using a built in command:A common discrepancy between different platforms is the way in which directory paths are specified. Unix uses a forward slash (/) to delimit the components of a path, whereas Windows uses a backslash (). Ant build files let authors choose their favorite convention, forward slashes or back slashes for directories, semicolon or colon for path separators. It converts everything to the appropriate format for the current platform. Limitations See also | |||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||
![]() |
|
| |