您可以在这里快速查找:


 
您的位置: 编程学习 > java教程 > 200602
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

读书笔记——《Ant – The Definitive Guide,2nd Edition》

hopson

第一章:Getting Started

l         Ant默认的构建文件为build.xml

l         Ant构建文件中的根XML元素为projectproject可用属性为:

Attribute

Description

Required

name

Defines the project name

No

default

The target to invoke if no target is explicitly specified

Yes

basedir

The base directory from which all relative paths are resolved

No

 

 

l         Ant工程(project)中由若干个构建目标(target)组成,构建目标是一组相关任务(Tasks)的集合,如编译文件、创建目录、打包等,构建目标之间可以建立依赖关系,构建目标执行之前必须先执行所有所依赖的构建目标。Ant工程通过projectdefault属性指定默认的构建目标名称。构建目标的XML元素为target,其可用的属性为:

Attribute

Description

Required

name

Defines the target name

Yes

depends

Comma-separated list of targets to execute before this target

No

if

Name of a property needed to run this task

No

unless

Name of a property that can not be set before running this task

No

description

Description of this target´s purpose

No

 

 

l         构建任务(Tasks)是构建目标(target)的基本组成部分,是Ant构建的基本执行单元。Ant中存在很多内建的构建任务,如下表所示:

Task Name

Description

ant

Executes Ant

antcall

Executes a target from the current build file

antstructure

From a given build file, creates a DTD reflecting all of the tasks Ant currently knows about

apply [execon]

Invokes a native executable

available

Sets a Boolean value in a property according to the availability of desired resource

basename

Sets a property to the last element of a specified path in an effort to determine a file´s name without directory structure

buildnumber

Manages build numbers

bunzip2

Expands GZip or BZip2 archives

bzip2

Packs GZip or BZip2 archives

checksum

Creates checksums for one or more files

chmod

Modifies file permissions on Unix

concat

Concatenates multiple files

condition

Checks the result of a condition and sets the result to in a property

copy [copydir, copyfile]

Copies files

cvs

Interacts with a CVS repository

cvschangelog

Converts a series of CVS change logs into an XML report

cvspass

Adds entries to a .cvspass file

cvstagdiff

Creates an XML report highlighting the differences between tags

cvsversion

Finds the CVS software version

defaultexcludes

Modifies the list of default exclude patterns, affecting which files are automatically excluded from processing by file-related tasks

delete [deltree]

Delete files and folders

dependset

Deletes target files that are older than new source files

dirname

Assigns a file´s directory path to a property

ear

Extends the jar task to support handling files for an Enterprise Application archive (EAR)

echo

Echoes text to System.out or to a file

exec

Invokes a native executable

fail

Halts and exits a build by throwing a BuildException

filter

Sets a token filter that can be used by filter-related tasks such as copy

fixcrlf

Adds or remove tabs, carriage returns, linefeeds, and EOF characters from a set of files

genkey

Adds a new key to a given keystore

get

Retrieves files using FTP, HTTP, and more from a URL

gunzip

Unpacks a GZip file

gzip

Packs a GZip file

import

Allows the use of other Ant files

input

Displays a message and reads a line of input from the console, allowing for user input during the build process

jar

Creates a JAR archive similar to Java´s jar command

java

Executes the Java interpreter to run a class or application

javac

Compiles the specified source file(s)

javadoc [javadoc2]

Invokes the javadoc tool to create documentation

loadfile

Sets a property file to the entire contents of a text file

loadproperties

Loans an entire property file into Ant properties

macrodef

Defines a new task as a macro built-up upon other tasks

mail

Sends SMTP mail messages

manifest

Creates an archive´s manifest file

mkdir

Makes a new directory

move [rename]

Moves a file to another directory

parallel

Contains other Ant tasks that can be run simultaneously by multiple Java threads

patch

Uses the patch command (assuming it is on the path) to apply diff files to a source file (or files)

pathconvert

Converts paths between platforms

presetdef

Defines a new task based on an existing task with certain options preset as defaults

property

Sets one or more properties to new values

record

Runs a listener that records the logging output of the build process to a file

replace

Replaces a string with another in all files in a directory

rmic

Invokes the rmic compiler

sequential

A container task that can contain other Ant tasks and run them in sequence

signjar

Uses the JarSigner to securely sign ZIP and JAR archives

sleep

Suspends execution for a specified period of time

sql

Runs SQL statements against a database

subant

Runs Ant within all subdirectories of the project directory

sync

Synchronizes two directory trees

tar

Makes a new TAR archive

taskdef

Creates a new task definition and adds it to the current project

tempfile

Sets a temporary filename to an Ant property

tstamp

Sets time-based properties to the current time

typedef

Creates a new task or data type for use in the current project

unjar

Unpacks a JAR file

untar

Unpacks a TAR file

unwar

Unpacks a WAR file

unzip

Unpacks a ZIP file

uptodate

Sets a property value to true if a given target file is newer than a set of source files

waitfor

Halts a build and continues when specified conditions are met