15 April 2009

0 Running ANT

Command Line
If you've installed Ant as described in the Installing Ant section, running Ant from the command-line is simple: just type ant.

When no arguments are specified, Ant looks for a build.xml file in the current directory and, if found, uses that file as the build file and runs the target specified in the default attribute of the <project> tag. To make Ant use a build file other than build.xml, use the command-line option -buildfile file, where file is the name of the build file you want to use

If you use the -find [file] option, Ant will search for a build file first in the current directory, then in the parent directory, and so on, until either a build file is found or the root of the filesystem has been reached. By default, it will look for a build file called build.xml. To have it search for a build file other than build.xml, specify a file argument.

Note: If you include any other flags or arguments on the command line after the -find flag, you must include the file argument for the -find flag, even if the name of the build file you want to find is build.xml.

You can also set properties on the command line. This can be done with the -Dproperty=value option, where property is the name of the property, and value is the value for that property. If you specify a property that is also set in the build file (see the property task), the value specified on the command line will override the value specified in the build file. Defining properties on the command line can also be used to pass in the value of environment variables - just pass -DMYVAR=%MYVAR% (Windows) or -DMYVAR=$MYVAR (Unix) to Ant. You can then access these variables inside your build file as ${MYVAR}. You can also access environment variables using the property task's environment attribute.

Options that affect the amount of logging output by Ant are:
-quiet, which instructs Ant to print less information to the console;
-verbose, which causes Ant to print additional information to the console;
-debug, which causes Ant to print considerably more additional information.
It is also possible to specify one or more targets that should be executed. When omitted, the target that is specified in the default attribute of the project tag is used.
The -projecthelp option prints out a list of the build file's targets. Targets that include a description attribute are listed as "Main targets", those without a description are listed as "Subtargets", then the "Default" target is listed.

Command-line Options Summary
ant [options] [target [target2 [target3] ...]]

Options:

-help, -h

print this message

-projecthelp, -p

print project help information

-version

print the version information and exit

-diagnostics

print information that might be helpful to diagnose or report problems.

-quiet, -q

be extra quiet

-verbose, -v

be extra verbose

-debug, -d

print debugging information

-emacs, -e

produce logging information without adornments

-lib <path>

specifies a path to search for jars and classes

-logfile <file>

use given file for log

-l <file>

use given file for log

-logger <classname>

the class which is to perform logging

-listener <classname>

add an instance of class as a project listener

-noinput

do not allow interactive input

-buildfile <file>

use given buildfile

-file <file>

use given buildfile

-f <file>

use given buildfile

-D<property>=<value>

use value for given property

-keep-going, -k

execute all targets that do not depend on failed target(s)

-propertyfile <name>

load all properties from file with -D properties taking precedence

-inputhandler <class>

the class which will handle input requests

-find <file>

(s)earch for buildfile towards the root of

-s <file>

the filesystem and use it

Ant tasks

The following tables provide a short description of each task.

  • Archive Tasks (Jar, Ear, Tar, War, GZip, Zip etc.)
  • Audit/Coverage Tasks (JDepend, JPorbe, MMetrics, etc. )
  • Compile Tasks (javac, jspc, rmic etc.)
  • Deployment Tasks (ServerDeploy)
  • Documentation Tasks (Javadoc, Stylebook)
  • EJB Tasks
  • Execution Tasks (Ant, Antcall, Exec, Java, Sleep etc.)
  • File Tasks (Attrib, Copy, Copydir, delete, Mkdir etc.)
  • Java2 Extensions Tasks (Jarlib-available, Jarlib-display etc.)
  • Logging Tasks (Record)
  • Mail Tasks (Mail, MimeMail)
  • Miscellaneous Tasks (Echo, GenKey, Script, Sql etc.)
  • .NET Tasks
  • Pre-process Tasks (ANTLR, AntStructure, Import, Xslt/Style etc.)
  • Property Tasks (Available, Basename, BuildNumber, LoadFile etc.)
  • Remote Tasks (FTP, Telnet etc. )
  • SCM Tasks (Cvs, CvsChangeLog, CVSPass etc.)
  • Testing Tasks (Junit, JunitReport, Test)
  • Visual Age for Java Tasks

Core tasks

  • Ant
  • AntCall
  • AntStructure
  • Apply/ExecOn
  • Available
  • Basename
  • BuildNumber
  • BUnzip2
  • BZip2
  • Checksum
  • Chmod
  • Concat
  • Condition
  • Supported conditions
  • Copy
  • Copydir
  • Copyfile
  • Cvs
  • CvsChangeLog
  • CVSPass
  • CvsTagDiff
  • Defaultexcludes
  • Delete
  • Deltree
  • Dependset
  • Dirname
  • Ear
  • Echo
  • Exec
  • Fail
  • Filter
  • FixCRLF
  • GenKey
  • Get
  • GUnzip
  • GZip
  • Import
  • Input
  • Jar
  • Java
  • Javac
  • Javadoc/Javadoc2
  • LoadFile
  • LoadProperties
  • Mail
  • MacroDef
  • Manifest
  • Mkdir
  • Move
  • Parallel
  • Patch
  • PathConvert
  • PreSetDef
  • Property
  • Record
  • Rename
  • Replace
  • Rmic
  • Sequential
  • SignJar
  • Sleep
  • Sql
  • Style
  • Subant
  • Sync
  • Tar
  • Taskdef
  • Tempfile
  • Touch
  • TStamp
  • Typedef
  • Unjar
  • Untar
  • Unwar
  • Unzip
  • Uptodate
  • Waitfor
  • War
  • WhichResource
  • XmlProperty
  • Xslt
  • Zip

Ant command line arguments

Several tasks take arguments that will be passed to another process on the command line. To make it easier to specify arguments that contain space characters, nested arg elements can be used.

value - a single command-line argument; can contain space characters.
file - The name of a file as a single command-line argument; will be replaced with the absolute filename of the file.
path - A string that will be treated as a path-like string as a single command-line argument; you can use ; or : as path separators and Ant will convert it to the platform's local conventions.
pathref - Reference to a path defined elsewhere. Ant will convert it to the platform's local conventions.
line - a space-delimited list of command-line arguments.

It is highly recommended to avoid the line version when possible. Ant will try to split the command line in a way similar to what a (Unix) shell would do, but may create something that is very different from what you expect under some circumstances.

Examples
<arg value="-l -a"/>
is a single command-line argument containing a space character.
<arg line="-l -a"/>
represents two separate command-line arguments.
<arg path="/dir;/dir2:\dir3"/>
is a single command-line argument with the value \dir;\dir2;\dir3 on DOS-based systems and /dir:/dir2:/dir3 on Unix-like systems.

Command-line Options Summary
ant [options] [target [target2 [target3] ...]]

Options:

-help, -h

Displays help information describing the Ant command and its options

-projecthelp, -p

Print project help information

-version

Print the version information and exit

-diagnostics

Print information that might be helpful to diagnose or report problems.

-quiet, -q

Suppresses most messages not originated by an echo task in the buildfile

-verbose, -v

Displays detailed messages for every operation during a build.

-debug, -d

Print debugging information

-emacs, -e

Produce logging information without adornments

-lib <path>

Specifies a path to search for jars and classes

-logfile <file>

Use given file for log

-l <file>

Use given file for log

-logger <classname>

Specifies a class to handle Ant logging.

-listener <classname>

Add an instance of class as a project listener

-noinput

Do not allow interactive input

-buildfile <file>

Use given buildfile

-file <file>

Use given buildfile

-f <file>

Use given buildfile

-D<property>=<value>

Defines a property name-value pair on the command line.

-keep-going, -k

execute all targets that do not depend on failed target(s)

-propertyfile <name>

load all properties from file with -D properties taking precedence

-inputhandler <class>

the class which will handle input requests

-find <file>

Search for buildfile towards the root of the filesystem and use it



0 comments:

Feeds Comments

Please give your valuable comments.