您的位置:首页 > 运维架构 > Apache

Overview of Apache Ant Tasks

2011-08-28 21:48 323 查看

Overview of Apache Ant Tasks

Given the large number of tasks available with Ant, it may be difficult to get an overall view of what each task can do. The following tables provide a short description of each task and a link to the complete documentation.

Archive Tasks
Audit/Coverage Tasks
Compile Tasks
Deployment Tasks
Documentation Tasks
EJB Tasks
Execution Tasks
File Tasks
Java2 Extensions Tasks
Logging Tasks
Mail Tasks
Miscellaneous Tasks
Pre-process Tasks
Property Tasks
Remote Tasks
SCM Tasks
Testing Tasks

Archive Tasks[Back to top]
Task NameDescription
BUnzip2Expands a file packed using GZip or BZip2.

BZip2Packs a file using the GZip or BZip2 algorithm. This task does not do any dependency checking; the output file is always generated

CabCreates Microsoft CAB archive files. It is invoked similar to the Jar or Zip tasks. This task will work on Windows using the external cabarc tool
(provided by Microsoft), which must be located in your executable path.

EarAn extension of the Jar task with special treatment for files that should end up in an Enterprise Application archive.

GUnzipExpands a GZip file.

GZipGZips a set of files.

JarJars a set of files.

JlinkDeprecated. Use the 
zipfileset
 and 
zipgroupfileset
 attributes of the Jar or Zip tasks instead.

ManifestCreates a manifest file.

RpmInvokes the rpm executable to build a Linux installation file. This task currently only works on Linux or other Unix platforms with RPM support.

SignJarSigns a jar or zip file with the javasign command-line tool.

TarCreates a tar archive.

UnjarUnzips a jarfile.

UntarUntars a tarfile.

UnwarUnzips a warfile.

UnzipUnzips a zipfile.

WarAn extension of the Jar task with special treatment for files that should end up in the 
WEB-INF/lib
WEB-INF/classes
, or 
WEB-INF
 directories of the Web Application
Archive.

ZipCreates a zipfile.

Audit/Coverage Tasks[Back to top]
Task NameDescription
JDependInvokes the JDepend parser. This parser "traverses a set of Java source-file directories and generates design-quality metrics for each Java package".

Compile Tasks[Back to top]
Task NameDescription
DependDetermines which classfiles are out-of-date with respect to their source, removing the classfiles of any other classes that depend on the out-of-date classes, forcing the re-compile of the removed classfiles. Typically used in conjunction with the Javac task.

JavacCompiles the specified source file(s) within the running (Ant) VM, or in another VM if the 
fork
 attribute is specified.

AptRuns the annotation processor tool (apt), and then optionally compiles the original code, and any generated source code.

JspCRuns the JSP compiler. It can be used to precompile JSP pages for fast initial invocation of JSP pages, deployment on a server without the full JDK installed, or simply to syntax-check the pages without deploying them. The Javac task
can be used to compile the generated Java source. (For Weblogic JSP compiles, see the Wljspc task.)

NetRexxCCompiles a NetRexx source tree within the running (Ant) VM.

RmicRuns the rmic compiler on the specified file(s).

WljspcCompiles JSP pages using Weblogic's JSP compiler, weblogic.jspc. (For non-Weblogic JSP compiles, see the JspC task.

Deployment Tasks[Back to top]
Task NameDescription
ServerDeployTask to run a "hot" deployment tool for vendor-specific J2EE server.

Documentation Tasks[Back to top]
Task NameDescription
Javadoc/Javadoc2Generates code documentation using the javadoc tool. The Javadoc2 task is deprecated; use the Javadoc task instead.

EJB Tasks[Back to top]
Task NameDescription
EJB Tasks(See the documentation describing the EJB tasks.)

Execution Tasks[Back to top]
Task NameDescription
AntRuns Ant on a supplied buildfile, optionally passing properties (with possibly new values). This task can be used to build sub-projects.

AntCallRuns another target within the same buildfile, optionally passing properties (with possibly new values).

Apply/ExecOnExecutes a system command. When the 
os
 attribute is specified, the command is only executed when Ant is run on one of the specified operating systems.

DependsetThis task compares a set of source files with a set of target files. If any of the source files is newer than any of the target files, all the target files are removed.

ExecExecutes a system command. When the 
os
 attribute is specified, the command is only executed when Ant is run on one of the specified operating systems.

JavaExecutes a Java class within the running (Ant) VM, or in another VM if the 
fork
 attribute is specified.

ParallelA container task that can contain other Ant tasks. Each nested task specified within the 
<parallel>
 tag will be executed in its own thread.

SequentialA container task that can contain other Ant tasks. The nested tasks are simply executed in sequence. Its primary use is to support the sequential execution of a subset of tasks within the 
<parallel>
 tag.

SleepA task for suspending execution for a specified period of time. Useful when a build or deployment process requires an interval between tasks.

SubantCalls a given target for all defined sub-builds. This is an extension of ant for bulk project execution.

WaitforBlocks execution until a set of specified conditions become true. This task is intended to be used with the Parallel task to synchronize a set of processes.

File Tasks[Back to top]
Task NameDescription
AttribChanges the permissions and/or attributes of a file or all files inside the specified directories. Currently, it has effect only under Windows.

ChecksumGenerates a checksum for a file or set of files. This task can also be used to perform checksum verifications.

ChgrpChanges the group ownership of a file or all files inside the specified directories. Currently, it has effect only under Unix.

ChmodChanges the permissions of a file or all files inside the specified directories. Currently, it has effect only under Unix. The permissions are also UNIX style, like the arguments for the chmod command.

ChownChanges the owner of a file or all files inside the specified directories. Currently, it has effect only under Unix.

ConcatConcatenates multiple files into a single one or to Ant's logging system.

CopyCopies a file or Fileset to a new file or directory.

CopydirDeprecated. Use the Copy task instead.

CopyfileDeprecated. Use the Copy task instead.

DeleteDeletes either a single file, all files and sub-directories in a specified directory, or a set of files specified by one or more FileSets.

DeltreeDeprecated. Use the Delete task instead.

FilterSets a token filter for this project, or reads multiple token filters from a specified file and sets these as filters. Token filters are used by all tasks that perform file-copying operations.

FixCRLFModifies a file to add or remove tabs, carriage returns, linefeeds, and EOF characters.

GetGets a file from a URL.

MkdirCreates a directory. Non-existent parent directories are created, when necessary.

MoveMoves a file to a new file or directory, or a set(s) of file(s) to a new directory.

PatchApplies a "diff" file to originals.

RenameDeprecated. Use the Move task instead.

RenameExtensionsDeprecated. Use the Move task with a glob mapper instead.

ReplaceReplace is a directory-based task for replacing the occurrence of a given string with another string in selected file.

ReplaceRegExpDirectory-based task for replacing the occurrence of a given regular expression with a substitution pattern in a file or set of files.

SyncSynchronize two directory trees.

TempfileGenerates a name for a new temporary file and sets the specified property to that name.

TouchChanges the modification time of a file and possibly creates it at the same time.

Java2 Extensions Tasks[Back to top]
Task NameDescription
Jarlib-availableCheck whether an extension is present in a FileSet or an ExtensionSet. If the extension is present, the specified property is set.

Jarlib-displayDisplay the "Optional Package" and "Package Specification" information contained within the specified jars.

Jarlib-manifestTask to generate a manifest that declares all the dependencies in manifest. The dependencies are determined by looking in the specified path and searching for Extension/"Optional Package" specifications in the manifests of the jars.

Jarlib-resolveTry to locate a jar to satisfy an extension, and place the location of the jar into the specified property.

Logging Tasks[Back to top]
Task NameDescription
RecordRuns a listener that records the logging output of the build-process events to a file. Several recorders can exist at the same time. Each recorder is associated with a file.

Mail Tasks[Back to top]
Task NameDescription
MailA task to send SMTP email.

MimeMailDeprecated. Use the Mail task instead.

Miscellaneous Tasks[Back to top]
Task NameDescription
DefaultexcludesModify the list of default exclude patterns from within your build file.

EchoEchoes text to 
System.out
 or to a file.

FailExits the current build by throwing a BuildException, optionally printing additional information.

GenKeyGenerates a key in keystore.

HostInfoSets properties related to the provided host, or to the host the process is run on.

InputAllows user interaction during the build process by displaying a message and reading a line of input from the console.

ScriptExecutes a script in a Apache BSF-supported language.

SoundPlays a sound file at the end of the build, according to whether the build failed or succeeded.

SplashDisplays a splash screen.

SqlExecutes a series of SQL statements via JDBC to a database. Statements can either be read in from a text file using the 
src
 attribute, or from between the enclosing SQL tags.

TaskdefAdds a task definition to the current project, such that this new task can be used in the current project.

TStampSets the 
DSTAMP
TSTAMP
, and 
TODAY
 properties in the current project, based on the current date and time.

TypedefAdds a data-type definition to the current project, such that this new type can be used in the current project.

XmlValidateChecks that XML files are valid (or only well-formed). This task uses the XML parser that is currently used by Ant by default, but any SAX1/2 parser can be specified, if needed.

Pre-process Tasks[Back to top]
Task NameDescription
ANTLRInvokes the ANTLR Translator generator on a grammar file.

AntStructureGenerates a DTD for Ant buildfiles that contains information about all tasks currently known to Ant.

ImportImport another build file and potentially override targets in it with targets of your own.

IncludeInclude another build file.

JavaCCInvokes the JavaCC compiler-compiler on a grammar file.

JavahGenerates JNI headers from a Java class.

JJDocInvokes the JJDoc documentation generator for the JavaCC compiler-compiler. JJDoc takes a JavaCC parser specification and produces documentation for the BNF grammar. It can operate in three modes, determined by command
line options. This task only invokes JJDoc if the grammar file is newer than the generated BNF grammar documentation.

JJTreeInvokes the JJTree preprocessor for the JavaCC compiler-compiler. It inserts parse-tree building actions at various places in the JavaCC source that it generates. The output of JJTree is run through JavaCC to create
the parser. This task only invokes JJTree if the grammar file is newer than the generated JavaCC file.

MacrodefDefine a new task as a macro built-up upon other tasks.

Native2AsciiConverts files from native encodings to ASCII with escaped Unicode. A common usage is to convert source files maintained in a native operating system encoding to ASCII, prior to compilation.

PresetdefDefine a new task by instrumenting an existing task with default values for attributes or child elements.

TranslateIdentifies keys in files, delimited by special tokens, and translates them with values read from resource bundles.

XSLTProcesses a set of documents via XSLT.

Property Tasks[Back to top]
Task NameDescription
AvailableSets a property if a specified file, directory, class in the classpath, or JVM system resource is available at runtime.

BasenameSets a property to the last element of a specified path.

BuildNumberTask that can be used to track build numbers.

ConditionSets a property if a certain condition holds true; this is a generalization of Available and Uptodate.

DirnameSets a property to the value of the specified file up to, but not including, the last path element.

EchopropertiesLists the current properties.

LoadFileLoads a file into a property.

LoadPropertiesLoad a file's contents as Ant properties. This task is equivalent to using 
<property file="..."/>
 except that it supports nested 
<filterchain>
 elements, and it cannot be specified outside a target.

MakeURLCreates a URL (list) from a file/fileset or path

PathConvertConverts a nested path, path reference, filelist reference, or fileset reference to the form usable on a specified platform and/or to a list of items separated by the specified separator and stores the result in the specified property.

PropertySets a property (by name and value), or set of properties (from a file or resource) in the project.

PropertyFileCreates or modifies property files. Useful when wanting to make unattended modifications to configuration files for application servers and applications. Typically used for things such as automatically generating a build number and saving it to a build properties
file, or doing date manipulation.

UptodateSets a property if a given target file is newer than a set of source files.

WhichresourceFind a class or resource.

XmlPropertyLoads property values from a well-formed XML file.

Remote Tasks[Back to top]
Task NameDescription
FTPImplements a basic FTP client that can send, receive, list, and delete files, and create directories.

RexecTask to automate a remote rexec session.

ScpCopy files to or from a remote server using SSH.

setproxySets Java's web proxy properties, so that tasks and code run in the same JVM can have through-the-firewall access to remote web sites.

SshexecExecute a command on a remote server using SSH.

TelnetTask to automate a remote telnet session. This task uses nested 
<read>
 and 
<write>
 tags to indicate strings to wait for and specify text to send.

SCM Tasks[Back to top]
Task NameDescription
CvsHandles packages/modules retrieved from a CVS repository.

CvsChangeLogGenerates an XML report of the changes recorded in a CVS repository.

CVSPassAdds entries to a .cvspass file. Adding entries to this file has the same affect as a cvs login command.

CvsTagDiffGenerates an XML-formatted report file of the changes between two tags or dates recorded in a CVS repository.

ClearCaseTasks to perform the ClearCase cleartool checkin, checkout, uncheckout, update, lock, unlock, mklbtype, rmtype, mklabel, mkattr, mkdir, mkelem, and mkbl commands.

Continuus/SynergyTasks to perform the Continuus ccmcheckin, ccmcheckout, ccmcheckintask, ccmreconfigure, and ccmcreateTask commands.

Microsoft Visual SourceSafeTasks to perform the Visual SourceSafe vssget, vsslabel, vsshistory, vsscheckin, vsscheckout, vssadd, vsscp, and vsscreate commands.

PerforceTasks to perform the Perforce p4sync, p4change, p4edit, p4submit, p4have, p4label, p4counter, p4reopen, p4revert, and p4add commands.

PvcsAllows the user extract the latest edition of the source code from a PVCS repository.

SourceOffSiteTasks to perform the SourceOffSite sosget, soslabel, soscheckin, and soscheckout commands.

Testing Tasks[Back to top]
Task NameDescription
JunitRuns tests from the Junit testing framework. This task has been tested with JUnit 3.0 up to JUnit 3.7; it won't work with versions prior to JUnit 3.0.

JunitReportMerges the individual XML files generated by the Junit task and applies a stylesheet on the resulting merged document to provide a browsable report of the testcases results.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息