Using Ant to automate tasks

To support using Apache Ant with Java Platform, Enterprise Edition (Java EE) applications running on the application server, the product provides a copy of the Ant tool and a set of Ant tasks that extend the capabilities of Ant to include product-specific functions. Ant has become a very popular tool among Java programmers.

About this task

Apache Ant is a Java-based build tool. In theory, it is similar to Make, but Ant is different. Instead of a model in which it is extended with shell-based commands, Ant is extended using Java classes. Instead of writing shell commands, XML-based configuration files are used. These files reference a target tree in which various tasks are run. Each task is run by an object that implements a particular Task interface.
Avoid trouble Avoid trouble:
  • Calling the WebSphere_Ant (WsAnt) scripts outside of the ws_ant launcher is not supported or recommended.
  • When you invoke the Ant tool, do not pass empty strings in place of command arguments in ant script. The script will not work in the wsadmin environment. The <arg value> cannot be an empty string, such as shown in the following example:
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="proj" default="main">
    		<taskdef name="wsadmin" classname="com.ibm.websphere.ant.tasks.WsAdmin"/>
    		<target name="main">
    			<wsadmin,conntype="NONE" lang="jython" failonerror="true" script="&(basedir)/script.ph">
    					<arg value="blah" />
    					<arg value="" />
    			</wsadmin>
    			<!-- manaeapp action="blah" variation-number="0" -->
    		</target>
    </project>
  • [Updated in September 2012] In general, for ws_ant.sh scripts, use single quote for strings containing special characters:
    • For a string containing a single quote or a double quote, use the other character to quote the string. For example, if you specify bin/ws_ant.sh -f ant.xml -Dsystem.property='"a quoted String"', the property is set to "a quoted string". Similarly, if you specify bin/ws_ant.sh -f ant.xml -Dsystem.peoperty="'a quoted string'", the property is set to 'a quoted string'.

      You cannot include both single and double quotes in the same string.

    • For a string containing a back quote, use a single quotes surrounding the string and escape the back quote with backslash. For example, if you specify bin/ws_ant.sh -f ant.xml -Dsystem.property='\`a quoted string\`', the property is set to `a quoted string`.
    • For a string containing a backslash, surround the string with single quotes and escape it with a backslash. For example, if you specify bin/ws_ant.sh -f ant.xml -Dsystem.property='c:\\Program Files\\IBM'. the property is set to c:\Program Files\IBM.
    • For a string containing a dollar sign, surround the string with single quotes and escape it with a backslash. For example, if you specify bin/ws_ant.sh -f ant.xml -Dsystem.property='\$3.99', the property is set to $3.99.
    [Updated in September 2012]
    sep2012
gotcha
By combining the following tasks with those provided by Ant, you can create build scripts that compile, package, install, and test your application on the application server:
  • Install and uninstall applications
  • Start and stop servers in a base configuration
  • Run administrative scripts or commands
  • Run the Enterprise JavaBeans (EJB) deployment tool for EJB 1.x or 2.x modules
  • Run the JavaServer Pages (JSP) file precompilation tool

For more detailed information about Ant, refer to the Apache organization Web site.

Procedure




In this information ...


Related reference

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Jun 11, 2013 8:40:09 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v701sca&product=was-nd-mp&topic=tovr_ant
File name: tovr_ant.html