Ant Build Tool - XML

JWSDP includes a Java-based Ant tool, which is portable across different platforms. You can use the Ant tool, developed by the Apache Software Foundation, to deploy the Web services. The configuration files of the Ant tool are XML based. An object that implements the particular task interface runs each task in the object tree of XML. Because the Ant tool is Java based, you can execute it on any platform.

The Ant tool is installed as part of the JWSDP. You can use it to manage the compilation of Java code and determine the hierarchy of the deployed application. A build file, called build.xml, controls the tasks that the Ant tool performs. A sample build.xml is shown in the following code:

As you can see from the preceding code, you can use the build.xml file to perform the following tasks:

  • Create a build directory.
  • Compile server-side code.
  • Run the xrpcc tool.
  • Compile client-side code.
  • Build the WAR file.
  • Copy the WAR file to Catalina.
  • Run the client.

Some of the built-in tasks that the Ant tool performs are as follows:

  • Copy a file or a set of files to a new file or a directory.
  • Delete a file or a directory along with the files and subdirectories it encloses.
  • Create a directory.
  • Create a JAR file.
  • Compile Java files.
  • Execute Java files.
  • Create a zip file.

This is the syntax of the ant command:

ant [options] [target [ target2 [target 3] ..]...]

If no parameter is passed with the command, the Ant tool looks for a build.xml file in the current directory. To search for a build.xml file, you can use the -find option with the ant command. When you use the -find option, the Ant tool searches for a build.xml file in the parent directory. The Ant tool searches until the root directory of the file system is reached. The other command-line options used with the Ant tool are discussed in Table.

Command-Line Options Used with the Ant Tool

Command-Line Options Used with the Ant Tool

We will now discuss how to create a simple Web service and deploy it by using the Ant tool.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

XML Topics