diff --git a/manual/Tasks/BorlandEJBTasks.html b/manual/Tasks/BorlandEJBTasks.html index 4bf59763f..7b1c2a34d 100644 --- a/manual/Tasks/BorlandEJBTasks.html +++ b/manual/Tasks/BorlandEJBTasks.html @@ -107,8 +107,8 @@ target="_top">FAQ for this task at his homepage.

java2iiopParams - If filled, the params are added to the java2iiop command - (ex: -no_warn_missing_define) + If filled, the params are added to the java2iiop command + (ex: -no_warn_missing_define) No diff --git a/manual/Tasks/ant.html b/manual/Tasks/ant.html index 7830226d9..f417efd9a 100644 --- a/manual/Tasks/ant.html +++ b/manual/Tasks/ant.html @@ -281,7 +281,7 @@ omitted an even more complex situation arises:

the above table recursively.

If the basedir of the outermost build has been specified as a property on the command -line (i.e. -Dbasedir=some-value or a -propertyfile argument) the value +line (i.e. -Dbasedir=some-value or a -propertyfile argument) the value provided will get an even higher priority. For any <ant> task that doesn't specify a dir attribute, the new project's basedir will be the value specified on the command line—no matter how deeply nested into layers of build files the task may diff --git a/manual/Tasks/antlr.html b/manual/Tasks/antlr.html index b7783e5db..996809b03 100644 --- a/manual/Tasks/antlr.html +++ b/manual/Tasks/antlr.html @@ -38,7 +38,7 @@ the glib attribute) is newer than the generated files.

distribution. See Library Dependencies for more information.

Antlr 2.7.2 Note: You will need antlrall.jar that can be created by -the antlr-all.jar target of the Makefile provided with the download.

+the antlr-all.jar target of the Makefile provided with the download.

Parameters

diff --git a/manual/Tasks/antstructure.html b/manual/Tasks/antstructure.html index b90324448..4b2988b22 100644 --- a/manual/Tasks/antstructure.html +++ b/manual/Tasks/antstructure.html @@ -46,7 +46,7 @@ as #IMPLIED.

Since Ant 1.7 custom structure printers can be used instead of the one that emits a DTD. In order to plug in your own structure, you have to implement the -interface org.apache.tools.ant.taskdefs.AntStructure.StructurePrinter +interface org.apache.tools.ant.taskdefs.AntStructure.StructurePrinter and <typedef> your class and use the new type as a nested element of this task—see the example below. diff --git a/manual/Tasks/apply.html b/manual/Tasks/apply.html index 24d03aa83..d508c87b4 100644 --- a/manual/Tasks/apply.html +++ b/manual/Tasks/apply.html @@ -47,7 +47,7 @@ the input and inputstring attributes.

Running Ant as a background process on Unix(-like) systems

-

If you run Ant as a background process (like ant &) and use +

If you run Ant as a background process (like ant &) and use the <apply> task with spawn set to false, you must provide explicit input to the forked process or Ant will be suspended because it tries to read from the standard input.

@@ -214,7 +214,7 @@ standard input.

@@ -277,8 +263,7 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
vmlauncher Run command using the JVM's execution facilities where available. If set to false the - underlying OS's shell, either directly or through the antRun scripts, will be + underlying OS's shell, either directly or through the antRun scripts, will be used. Under some operating systems, this gives access to facilities not normally available through JVM including, under Windows, being able to execute scripts, rather than their associated interpreter. If you want to specify the name of the executable as a relative path @@ -360,9 +360,9 @@ of exec.

</fileset> <fileset refid="other.files"/> </apply> -

invokes ls -l, adding the absolute filenames of all files below /tmp -not ending in .txt and all files of the FileSet -with id other.files to the command line.

+

invokes ls -l, adding the absolute filenames of all files below /tmp not +ending in .txt and all files of the FileSet with id other.files +to the command line.

 <apply executable="somecommand" parallel="false">
   <arg value="arg1"/>
@@ -384,7 +384,7 @@ with the absolute filenames of all files separated by spaces.

<fileset dir="src/C" includes="*.c"/> <mapper type="glob" from="*.c" to="*.o"/> </apply>
-

invokes cc -c -o TARGETFILE SOURCEFILE for each .c file that is newer +

invokes cc -c -o TARGETFILE SOURCEFILE for each .c file that is newer than the corresponding .o, replacing TARGETFILE with the absolute filename of the .o and SOURCEFILE with the absolute name of the .c file.

@@ -400,7 +400,7 @@ file.

<outputmapper refid="out"/> </redirector> </apply> -

Applies the fictitious processfile executable to all files +

Applies the fictitious processfile executable to all files matching *.file in the src directory. The out <mapper> has been set up to map *.file to *.out, then this <mapper> is used to @@ -416,7 +416,7 @@ dependency checking against output files—the target files in this case.

-

Applies the ls executable to all directories in the PATH, effectively +

Applies the ls executable to all directories in the PATH, effectively listing all executables that are available on the PATH.

@@ -431,7 +431,7 @@ listing all executables that are available on the PATH.

<outputmapper id="out" type="glob" from="*.js" to="dest/*.js"/> </redirector> </apply>
-

Conversion of the command jsmin < src/a.js > dest/a.js but for all files in +

Conversion of the command jsmin < src/a.js > dest/a.js but for all files in the src directory. Because the filename itself should not be passed to the jsmin program, the addsourcefile is set to false.

diff --git a/manual/Tasks/attrib.html b/manual/Tasks/attrib.html index 1051644fe..07e59897a 100644 --- a/manual/Tasks/attrib.html +++ b/manual/Tasks/attrib.html @@ -104,7 +104,7 @@ alternative.

+<!-- Convert path to URL format --> <pathconvert dirsep="/" property="xsd.file"> <path> <pathelement location="xml/doc.xsd"/> diff --git a/manual/Tasks/zip.html b/manual/Tasks/zip.html index 28fc209e2..c83a28c90 100644 --- a/manual/Tasks/zip.html +++ b/manual/Tasks/zip.html @@ -82,8 +82,8 @@ see below

(see description of the filemode and dirmode attributes for <zipfileset>). Unfortunately there is no portable way to store these permissions. Ant uses the algorithm used by Info-Zip's implementation of the zip and unzip -commands—these are the default versions of zip and unzip for many +target="_top">Info-Zip's implementation of the zip and unzip +commands—these are the default versions of zip and unzip for many Unix(-like) systems.

Please note that the zip format allows multiple files of the same fully-qualified name to @@ -264,8 +264,8 @@ extract an Ant generated ZIP archive.

sufficient for many international character sets.

Over time different archivers have chosen different ways to work around the -limitation—the java.util.zip packages simply uses UTF-8 as its encoding for -example.

+limitation—the java.util.zip packages simply uses UTF-8 as its +encoding for example.

Ant has been offering the encoding attribute of the zip and unzip task as a way to explicitly specify the encoding to use (or expect) since @@ -307,13 +307,13 @@ ZIP archives. Below are some test results which may be superseded with later ve tool.

    -
  • The java.util.zip package used by the jar executable or to read jars - from your CLASSPATH reads and writes UTF-8 names, it doesn't set or recognize any - flags or unicode extra fields.
  • -
  • Since Java 7, java.util.zip writes UTF-8 by default and uses the language - encoding flag. It is possible to specify a different encoding when reading/writing ZIPs via new - constructors. The package now recognizes the language encoding flag when reading and ignores - the Unicode extra fields.
  • +
  • The java.util.zip package used by the jar executable or + to read jars from your CLASSPATH reads and writes UTF-8 names, it doesn't set or + recognize any flags or unicode extra fields.
  • +
  • Since Java 7, java.util.zip writes UTF-8 by default and uses the + language encoding flag. It is possible to specify a different encoding when reading/writing + ZIPs via new constructors. The package now recognizes the language encoding flag when reading + and ignores the Unicode extra fields.
  • 7Zip writes CodePage 437 by default but uses UTF-8 and the language encoding flag when writing entries that cannot be encoded as CodePage 437 (similar to the zip task with fallbacktoUTF8 set to true). It recognizes the language encoding flag @@ -332,16 +332,16 @@ tool.

    So, what to do?

    -

    If you are creating jars, then java.util.zip is your main consumer. We recommend -you set the encoding to UTF-8 and keep the language encoding flag enabled. The flag won't help or -hurt java.util.zip prior to Java 7 but archivers that support it will show the correct -file names.

    +

    If you are creating jars, then java.util.zip is your main consumer. We +recommend you set the encoding to UTF-8 and keep the language encoding flag enabled. The flag won't +help or hurt java.util.zip prior to Java 7 but archivers that support it +will show the correct file names.

    For maximum interoparability it is probably best to set the encoding to UTF-8, enable the language encoding flag and create Unicode extra fields when writing ZIPs. Such archives should be -extracted correctly by java.util.zip, 7Zip, WinZIP, PKWARE tools and most likely -InfoZIP tools. They will be unusable with Windows' "compressed folders" feature and bigger than -archives without the Unicode extra fields, though.

    +extracted correctly by java.util.zip, 7Zip, WinZIP, PKWARE tools and most +likely InfoZIP tools. They will be unusable with Windows' "compressed folders" feature and bigger +than archives without the Unicode extra fields, though.

    If Windows' "compressed folders" is your primary consumer, then your best option is to explicitly set the encoding to the target platform. You may want to enable creation of Unicode extra fields so @@ -376,9 +376,9 @@ the zip family of tasks. It supports three values: limits of traditional zip files but don't want to waste too much space (the Zip64 extensions take up extra space). Unfortunately some ZIP implementations don't understand Zip64 extra fields or fail to parse archives with extra fields in local file headers that are not present in the central -directory, one such implementation is the java.util.zip package of Java 5, that's why -the jar tasks default to never. Archives created with as-needed can be -read without problems with Java 6 and later.

    +directory, one such implementation is the java.util.zip package of Java 5, +that's why the jar tasks default to never. Archives created +with as-needed can be read without problems with Java 6 and later.

    Parameters specified as nested elements

    diff --git a/manual/Types/antlib.html b/manual/Types/antlib.html index bafc2f9ad..515e39ff4 100644 --- a/manual/Types/antlib.html +++ b/manual/Types/antlib.html @@ -27,10 +27,10 @@

    Description

    - An antlib file is an xml file with a root element of antlib. Antlib's - elements are Apache Ant definition - tasks—like Taskdef or any Ant task that - extends org.apache.tools.ant.taskdefs.AntlibDefinition. + An antlib file is an xml file with a root element of antlib. Antlib's elements + are Apache Ant definition tasks—like Taskdef or any + Ant task that + extends org.apache.tools.ant.taskdefs.AntlibDefinition.

    The current set of declarations bundled with Ant that do this are: diff --git a/manual/Types/classfileset.html b/manual/Types/classfileset.html index f394b2dcc..eaf4a1608 100644 --- a/manual/Types/classfileset.html +++ b/manual/Types/classfileset.html @@ -77,11 +77,11 @@ may be used

    RootFileSet

    -A root fileset is used to add a set of root classes from a fileset. In this case the entries in -the fileset are expected to be Java class files. The name of the Java class is determined by the +A root fileset is used to add a set of root classes from a fileset. In this case the entries in the +fileset are expected to be Java class files. The name of the Java class is determined by the relative location of the classfile in the fileset. So, the file org/apache/tools/ant/Project.class corresponds to the Java -class org.apache.tools.ant.Project.

    +class org.apache.tools.ant.Project.

    Examples

    @@ -90,8 +90,8 @@ class org.apache.tools.ant.Project.

    </classfileset>

    This example creates a fileset containing all the class files upon which -the org.apache.tools.ant.Project class depends. This fileset could then be used to -create a jar. +the org.apache.tools.ant.Project class depends. This fileset could then be +used to create a jar.

    @@ -104,8 +104,9 @@ create a jar.
       <rootfileset dir="${classes.dir}" includes="org/apache/tools/ant/Project*.class"/>
     </classfileset>

    -This example constructs the classfileset using all the class with names starting with Project in -the org.apache.tools.ant package. +This example constructs the classfileset using all the class with names starting +with Project in the org.apache.tools.ant +package.

    diff --git a/manual/Types/custom-programming.html b/manual/Types/custom-programming.html index ba743c14c..1d233feda 100644 --- a/manual/Types/custom-programming.html +++ b/manual/Types/custom-programming.html @@ -24,18 +24,16 @@

    Custom Components

    Overview

    - Custom components are conditions, selectors, filters and other objects - that are defined outside Apache Ant core. + Custom components are conditions, selectors, filters and other objects that are defined + outside Apache Ant core.

    - In Ant 1.6 custom conditions, selectors and filters has been - overhauled. + In Ant 1.6 custom conditions, selectors and filters has been overhauled.

    - It is now possible to define custom conditions, selectors and filters - that behave like Ant Core components. This is achieved by allowing - datatypes defined in build scripts to be used as custom components if - the class of the datatype is compatible, or has been adapted by an + It is now possible to define custom conditions, selectors and filters that behave like Ant + Core components. This is achieved by allowing datatypes defined in build scripts to be used + as custom components if the class of the datatype is compatible, or has been adapted by an adapter class.

    @@ -43,15 +41,13 @@

    Definition and Use

    - A custom component is a normal Java class that implements a particular - interface or extends a particular class, or has been adapted to the - interface or class. + A custom component is a normal Java class that implements a particular interface or extends a + particular class, or has been adapted to the interface or class.

    - It is exactly like writing - a custom task. One - defines attributes and nested elements by writing setter - methods and add methods. + It is exactly like writing a custom task. One + defines attributes and nested elements by writing setter methods and add + methods.

    After the class has been written, it is added to the ant system by @@ -60,9 +56,9 @@

    Custom Conditions

    Custom conditions are datatypes that - implement org.apache.tools.ant.taskdefs.condition.Condition. - For example a custom condition that returns true if a string is all - upper case could be written as: + implement org.apache.tools.ant.taskdefs.condition.Condition. For + example a custom condition that returns true if a string is all upper case could be written + as:

     package com.mydomain;
    @@ -104,13 +100,12 @@ public class AllUpperCaseCondition implements Condition {
         

    Custom Selectors

    Custom selectors are datatypes that - implement org.apache.tools.ant.types.selectors.FileSelector. + implement org.apache.tools.ant.types.selectors.FileSelector.

    - There is only one method required, public boolean - isSelected(File basedir, String filename, File file). It - returns true or false depending on whether the given file should be - selected or not. + There is only one method required, public boolean isSelected(File basedir, + String filename, File file). It returns true or false depending on whether the given + file should be selected or not.

    An example of a custom selection that selects filenames ending @@ -134,8 +129,7 @@ public class JavaSelector implements FileSelector { classname="com.mydomain.JavaSelector" classpath="${mydomain.classes}"/>

    - This selector can now be used wherever a Core Ant selector is used, - for example: + This selector can now be used wherever a Core Ant selector is used, for example:

     <copy todir="to">
    @@ -144,34 +138,30 @@ public class JavaSelector implements FileSelector {
         </fileset>
     </copy>

    - One may - use org.apache.tools.ant.types.selectors.BaseSelector, a - convenience class that provides reasonable default behaviour. It has - some predefined behaviours you can take advantage of. Any time you - encounter a problem when setting attributes or adding tags, you can - call setError(String errmsg) and the class will know that - there is a problem. Then, at the top of your isSelected() - method call validate() and a BuildException will be - thrown with the contents of your error - message. The validate() method also gives you a last - chance to check your settings for consistency because it - calls verifySettings(). Override this method and - call setError() within it if you detect any problems in - how your selector is set up. + One may use org.apache.tools.ant.types.selectors.BaseSelector, a + convenience class that provides reasonable default behaviour. It has some predefined + behaviours you can take advantage of. Any time you encounter a problem when setting attributes + or adding tags, you can call setError(String errmsg) and the class + will know that there is a problem. Then, at the top of + your isSelected() method call validate() + and a BuildException will be thrown with the contents of your error + message. The validate() method also gives you a last chance to check + your settings for consistency because it + calls verifySettings(). Override this method and + call setError() within it if you detect any problems in how your + selector is set up.

    To write custom selector containers one should - extend org.apache.tools.ant.types.selectors.BaseSelectorContainer. - Implement the public boolean isSelected(File baseDir, String - filename, File file) method to do the right thing. Chances are - you'll want to iterate over the selectors under you, so - use selectorElements() to get an iterator that will do - that. + extend org.apache.tools.ant.types.selectors.BaseSelectorContainer. + Implement the public boolean isSelected(File baseDir, String filename, File + file) method to do the right thing. Chances are you'll want to iterate over the + selectors under you, so use selectorElements() to get an iterator + that will do that.

    - For example to create a selector container that will select files if a - certain number of contained selectors select, one could write a - selector as follows: + For example to create a selector container that will select files if a certain number of + contained selectors select, one could write a selector as follows:

     public class MatchNumberSelectors extends BaseSelectorContainer {
    @@ -214,28 +204,24 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
           The custom selector
         

    - The custom selector was the pre Ant 1.6 way of defining custom - selectors. This method is still supported for backward compatibility. + The custom selector was the pre Ant 1.6 way of defining custom selectors. This method is + still supported for backward compatibility.

    - You can write your own selectors and use them within the selector - containers by specifying them within the <custom> - tag. + You can write your own selectors and use them within the selector containers by specifying + them within the <custom> tag.

    To create a new Custom Selector, you have to create a class that - implements org.apache.tools.ant.types.selectors.ExtendFileSelector. + implements org.apache.tools.ant.types.selectors.ExtendFileSelector. The easiest way to do that is through the convenience base - class org.apache.tools.ant.types.selectors.BaseExtendSelector, - which provides all of the methods for - supporting <param> tags. First, override - the isSelected() method, and optionally - the verifySettings() method. If your custom selector - requires parameters to be set, you can also override - the setParameters() method and interpret the parameters - that are passed in any way you like. Several of the core selectors - demonstrate how to do that because they can also be used as custom - selectors. + class org.apache.tools.ant.types.selectors.BaseExtendSelector, which + provides all of the methods for supporting <param> tags. First, override + the isSelected() method, and optionally + the verifySettings() method. If your custom selector requires + parameters to be set, you can also override the setParameters() + method and interpret the parameters that are passed in any way you like. Several of the core + selectors demonstrate how to do that because they can also be used as custom selectors.

    Once that is written, you include it in your build file by using @@ -252,7 +238,7 @@ public class MatchNumberSelectors extends BaseSelectorContainer {

classname The name of your class that - implements org.apache.tools.ant.types.selectors.FileSelector. + implements org.apache.tools.ant.types.selectors.FileSelector. Yes

- Here is how you use <custom> to use your class as a - selector: + Here is how you use <custom> to use your class as a selector:

 <fileset dir="${mydir}" includes="**/*">
@@ -290,20 +275,20 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
 
     
 
     

- Here is the example from the Depth Selector section rewritten to use - the selector through <custom>. + Here is the example from the Depth Selector section rewritten to use the selector + through <custom>.

 <fileset dir="${doc.path}" includes="**/*">
@@ -316,16 +301,14 @@ public class MatchNumberSelectors extends BaseSelectorContainer {
     

Custom Filter Readers

Custom filter readers selectors are datatypes that - implement org.apache.tools.ant.types.filters.ChainableReader. + implement org.apache.tools.ant.types.filters.ChainableReader.

- There is only one method required. Reader chain(Reader - reader). This returns a reader that filters input from the - specified reader. + There is only one method required, Reader chain(Reader reader). + This returns a reader that filters input from the specified reader.

- For example a filterreader that removes every second character could - be: + For example a filterreader that removes every second character could be:

 public class RemoveOddCharacters implements ChainableReader {
@@ -349,8 +332,8 @@ public class RemoveOddCharacters implements ChainableReader {
 }

For line oriented filters it may be easier to - extend ChainableFilterReader an inner class - of org.apache.tools.ant.filters.TokenFilter. + extend ChainableFilterReader an inner class + of org.apache.tools.ant.filters.TokenFilter.

For example a filter that appends the line number could be diff --git a/manual/Types/description.html b/manual/Types/description.html index f5cf02cd9..448aa633b 100644 --- a/manual/Types/description.html +++ b/manual/Types/description.html @@ -27,7 +27,7 @@

Description

Description

Allows for a description of the project to be specified that will be -included in the output of the ant -projecthelp command.

+included in the output of the ant -projecthelp command.

Parameters

(none)

diff --git a/manual/Types/fileset.html b/manual/Types/fileset.html index ea05ec5d6..1bc674e04 100644 --- a/manual/Types/fileset.html +++ b/manual/Types/fileset.html @@ -28,7 +28,7 @@

A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors.

-

PatternSets can be specified as nested q<patternset> elements. In +

PatternSets can be specified as nested <patternset> elements. In addition, FileSet holds an implicit PatternSet and supports the nested <include>, <includesfile>, <exclude> and <excludesfile> elements of PatternSet directly, as well as PatternSet's diff --git a/manual/Types/filterchain.html b/manual/Types/filterchain.html index cf5b090b1..f5266e5d5 100644 --- a/manual/Types/filterchain.html +++ b/manual/Types/filterchain.html @@ -27,7 +27,7 @@ that contained the string blee from the first 10 lines of a text file foo (you wouldn't want to filter a binary file) to a file bar, you would do something like:

-
cat foo|head -n10|grep blee > bar
+
cat foo|head -n10|grep blee > bar

Apache Ant was not flexible enough. There was no way for the <copy> task to do something similar. If you wanted the <copy> task to get the first 10 lines, you would have had to create special attributes:

@@ -42,8 +42,8 @@ and plug them in.

The solution was to refactor data transformation oriented tasks to support FilterChains. A FilterChain is a group of ordered FilterReaders. Users can define their own FilterReaders by just -extending the java.io.FilterReader class. Such custom FilterReaders can be easily -plugged in as nested elements of <filterchain> by +extending the java.io.FilterReader class. Such custom FilterReaders can +be easily plugged in as nested elements of <filterchain> by using <filterreader> elements.

Example:

@@ -119,8 +119,9 @@ elements are defined in the build file using this.  Please note that built in fi
 also be defined using this syntax.

A FilterReader element must be supplied with a class name as an attribute value. The class -resolved by this name must extend java.io.FilterReader. If the custom filter reader -needs to be parameterized, it must implement org.apache.tools.type.Parameterizable.

+resolved by this name must extend java.io.FilterReader. If the custom +filter reader needs to be parameterized, it must +implement org.apache.tools.type.Parameterizable.

@@ -206,8 +207,8 @@ is substituted with the property's actual value.

Example

-

This results in the property modifiedmessage holding the value "All these -moments will be lost in time, like teardrops in the rain"

+

This results in the property modifiedmessage holding the value All these moments +will be lost in time, like teardrops in the rain

 <echo message="All these moments will be lost in time, like teardrops in the ${weather}"
       file="loadfile1.tmp"/>
@@ -955,8 +956,8 @@ extracted)

Since Ant 1.8.0

The sort filter reads all lines and sorts them. The sort order can be reversed and it is -possible to specify a custom implementation of the java.util.Comparator interface -to get even more control.

+possible to specify a custom implementation of the java.util.Comparator +interface to get even more control.

@@ -972,8 +973,8 @@ to get even more control.

- +
comparatorClass name of a class that implements java.util.Comparator for Strings. - This class will be used to determine the sort order of lines.Class name of a class that implements java.util.Comparator for + Strings. This class will be used to determine the sort order of lines. No
@@ -1023,12 +1024,12 @@ them into build location.

Sort all files *.txt from src location using as sorting -criterium EvenFirstCmp class, that sorts the file lines putting even lines first -then odd lines for example. The modified files are copied into build -location. The EvenFirstCmp, has to an instanciable class -via Class.newInstance(), therefore in case of inner class has to -be static. It also has to implement java.util.Comparator interface, for -example: +criterium EvenFirstCmp class, that sorts the file lines putting even lines +first then odd lines for example. The modified files are copied into build +location. The EvenFirstCmp has to an instanciable class +via Class.newInstance(), therefore in case of inner class has to +be static. It also has to implement java.util.Comparator +interface, for example:

@@ -1166,9 +1167,9 @@ this on very large input.

</tokenfilter>

StringTokenizer

-

This tokenizer is based on java.util.StringTokenizer. It splits up the input -into strings separated by white space, or by a specified list of delimiting characters. If the -stream starts with delimiter characters, the first token will be the empty string (unless +

This tokenizer is based on java.util.StringTokenizer. It splits up the +input into strings separated by white space, or by a specified list of delimiting characters. If +the stream starts with delimiter characters, the first token will be the empty string (unless the delimsaretokens attribute is used).

@@ -1430,8 +1431,7 @@ the native2ascii task.

- +
reverseReverse the sense of the conversion, - i.e. convert from ASCII to native.Reverse the sense of the conversion, i.e. convert from ASCII to native. No
@@ -1456,9 +1456,10 @@ See the Script task for an explanation of scr dependencies.

-The script is provided with an object self that has getToken() -and setToken(String) methods. The getToken() method returns the current -token. The setToken(String) method replaces the current token. +The script is provided with an object self that +has getToken() and setToken(String) methods. +The getToken() method returns the current +token. The setToken(String) method replaces the current token.

This filter may be used directly within a filterchain. @@ -1538,8 +1539,8 @@ the script task on how to use this element.

Custom tokenizers and string filters

Custom string filters and tokenizers may be plugged in by extending the -interfaces org.apache.tools.ant.filters.TokenFilter.Filter -and org.apache.tools.ant.util.Tokenizer respectly.

+interfaces org.apache.tools.ant.filters.TokenFilter.Filter +and org.apache.tools.ant.util.Tokenizer respectly.

They are defined in the build file using <typedef/>. For example, a string filter that capitalizes words may be declared as:

diff --git a/manual/Types/mapper.html b/manual/Types/mapper.html index a4e014b40..bf8a10a0b 100644 --- a/manual/Types/mapper.html +++ b/manual/Types/mapper.html @@ -32,9 +32,10 @@ may want to specify the target files, either to help Apache Ant or to get an ext functionality.

While source files are usually specified as filesets, you don't specify target files directly—instead, you tell Ant how to find the target file(s) for one -source file. An instance of org.apache.tools.ant.util.FileNameMapper is responsible for -this. It constructs target file names based on rules that can be parameterized with from -and to attributes—the exact meaning of which is implementation-dependent.

+source file. An instance of org.apache.tools.ant.util.FileNameMapper is +responsible for this. It constructs target file names based on rules that can be parameterized +with from and to attributes—the exact meaning of which is +implementation-dependent.

These instances are defined in <mapper> elements with the following attributes:

@@ -88,16 +89,16 @@ is, a path-like structure.

Since Ant 1.7.0, nested File Mappers can be supplied via either <mapper> elements or <typedef>'d implementations -of org.apache.tools.ant.util.FileNameMapper. If nested File Mappers are specified by -either means, the mapper will be implicitly configured as a composite -mapper.

+of org.apache.tools.ant.util.FileNameMapper. If nested File Mappers are +specified by either means, the mapper will be implicitly configured as +a composite mapper.

The built-in mapper types

All built-in mappers are case-sensitive.

Since Ant 1.7.0, each of the built-in mapper implementation types is directly accessible using a specific tagname. This makes it possible for filename mappers to support attributes in -addition to the generally available to and from.
The <mapper -type|classname="..."> usage form remains valid for reasons of backward -compatibility.

+addition to the generally available to and from.
+The <mapper type|classname="..."> usage form +remains valid for reasons of backward compatibility.

@@ -330,10 +331,10 @@ case).

Note that you need to escape a dollar-sign ($) with another dollar-sign in Ant.

The regexp mapper needs a supporting library and an implementation -of org.apache.tools.ant.util.regexp.RegexpMatcher that hides the specifics of the -library. Since Ant 1.8.0, Java 1.4 or later is required, so the implementation based on -the java.util.regex package is always be available. You can still use the now retired -Jakarta ORO or Jakarta Regex instead if your provide the corresponding jar in +of org.apache.tools.ant.util.regexp.RegexpMatcher that hides the specifics +of the library. Since Ant 1.8.0, Java 1.4 or later is required, so the implementation based +on the java.util.regex package is always be available. You can still use +the now retired Jakarta ORO or Jakarta Regex instead if your provide the corresponding jar in your CLASSPATH.

For information about using your mileage may vary with different regexp engines.

If you want to use one of the regular expression libraries other than java.util.regex you need to also use the -corresponding ant-[apache-oro, apache-regexp].jar from the Ant release you are using. +corresponding ant-[apache-oro, apache-regexp].jar from the Ant release you are using. Make sure that both will be loaded from the same classpath, that is either put them into your CLASSPATH, ANT_HOME/lib directory or a nested <classpath> element of the mapper—you cannot -have ant-[apache-oro, apache-regexp].jar in ANT_HOME/lib and the library +have ant-[apache-oro, apache-regexp].jar in ANT_HOME/lib and the library in a nested <classpath>.

Ant will choose the regular expression library based on the following algorithm:

  • If the system property ant.regexp.matcherimpl has been set, it is taken as the name -of the class implementing org.apache.tools.ant.util.regexp.RegexpMatcher that should be -used.
  • +of the class implementing org.apache.tools.ant.util.regexp.RegexpMatcher +that should be used.
  • If it has not been set, uses the JDK 1.4 classes.
@@ -590,7 +591,7 @@ mappers; prior to Ant 1.8.0 the order has been undefined.

foo.bar.A
-

The composite mapper has no corresponding <mapper type> +

The composite mapper has no corresponding <mapper> type attribute.

@@ -633,7 +634,7 @@ operation. The to and from attributes are ignored.

new/path/B.java2 -

The chained mapper has no corresponding <mapper type> +

The chained mapper has no corresponding <mapper> type attribute.

@@ -678,9 +679,7 @@ file name.

-

The filtermapper has no corresponding - <mapper type> attribute. -

+

The filtermapper has no corresponding <mapper> type attribute.

@@ -742,8 +741,7 @@ dependencies.

This filename mapper can take a nested <classpath> element. See -the script task on how to use this element. -

+the script task on how to use this element.

Example
@@ -793,7 +791,7 @@ every source file, with the list of mapped names reset after every invocation.
 
 
-

The scriptmapper has no corresponding <mapper type> attribute.

+

The scriptmapper has no corresponding <mapper> type attribute.

firstmatchmapper

Since Ant 1.8.0

@@ -822,7 +820,7 @@ collects the results of all matching children.

-

The firstmatchmapper has no corresponding <mapper type> +

The firstmatchmapper has no corresponding <mapper> type attribute.

cutdirsmapper

@@ -843,7 +841,7 @@ attribute.

-

The cutdirsmapper has no corresponding <mapper type> attribute.

+

The cutdirsmapper has no corresponding <mapper> type attribute.

diff --git a/manual/Types/namespace.html b/manual/Types/namespace.html index d6711bef3..a9ece1c25 100644 --- a/manual/Types/namespace.html +++ b/manual/Types/namespace.html @@ -184,17 +184,17 @@

Mixing Elements from Different Namespaces

- Now comes the difficult part: elements from different namespaces can be woven together - under certain circumstances. This has a lot to do with the Ant - 1.6 add type introspection rules: Ant types and - tasks are now free to accept arbitrary named types as nested elements, as long as the - concrete type implements the interface expected by the task/type. The most obvious example - for this is the <condition> task, which supports various nested - conditions, all of which extend the interface Condition. To integrate a - custom condition in Ant, you can now simply <typedef> the condition, - and then use it anywhere nested conditions are allowed (assuming the containing element - has a generic add(Condition) or addConfigured(Condition) - method): + Now comes the difficult part: elements from different namespaces can be woven together under + certain circumstances. This has a lot to do with the Ant + 1.6 add type introspection rules: Ant types and tasks + are now free to accept arbitrary named types as nested elements, as long as the concrete type + implements the interface expected by the task/type. The most obvious example for this is + the <condition> task, which supports various nested conditions, all of + which extend the interface Condition. To integrate a custom + condition in Ant, you can now simply <typedef> the condition, and then use + it anywhere nested conditions are allowed (assuming the containing element has a + generic add(Condition) + or addConfigured(Condition) method):

 <typedef resource="org/example/conditions.properties" uri="http://example.org/conditions"/>
diff --git a/manual/Types/permissions.html b/manual/Types/permissions.html
index 1032d3781..4986f3f9d 100644
--- a/manual/Types/permissions.html
+++ b/manual/Types/permissions.html
@@ -134,9 +134,9 @@ are revoked.  If the actions are left empty all actions match, and ar
   <grant class="java.util.PropertyPermission" name="user.home" action="read,write"/>
 </permissions>
 
-

Grants the base set of permissions with the addition of a SocketPermission to -connect to foo.bar.com and the permission to read and write -the user.home system property.

+

Grants the base set of permissions with the addition of +a SocketPermission to connect to foo.bar.com and the +permission to read and write the user.home system property.

diff --git a/manual/Types/regexp.html b/manual/Types/regexp.html index 48d387054..88bd69ba7 100644 --- a/manual/Types/regexp.html +++ b/manual/Types/regexp.html @@ -57,12 +57,12 @@ dependencies concerning the supporting libraries.

The property ant.regexp.regexpimpl governs which regular expression implementation will be chosen. Possible values for this property are:

    -
  • org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
  • -
  • org.apache.tools.ant.util.regexp.JakartaOroRegexp
  • -
  • org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
  • +
  • org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
  • +
  • org.apache.tools.ant.util.regexp.JakartaOroRegexp
  • +
  • org.apache.tools.ant.util.regexp.JakartaRegexpRegexp

It can also be another implementation of the -interface org.apache.tools.ant.util.regexp.Regexp. +interface org.apache.tools.ant.util.regexp.Regexp. If ant.regexp.regexpimpl is not defined, Ant uses Jdk14Regexp as this is always available.

diff --git a/manual/Types/resources.html b/manual/Types/resources.html index 62277cc93..f78d6ce09 100644 --- a/manual/Types/resources.html +++ b/manual/Types/resources.html @@ -1015,11 +1015,11 @@ collection.

A single resource collection is required.

tokens

-

Includes the string tokens gathered from a nested resource -collection. Uses the same tokenizers supported by +

Includes the string tokens gathered from a nested resource collection. Uses +the same tokenizers supported by the TokenFilter. Imaginative use of this resource -collection can implement equivalents for such Unix functions as sort, grep --c, wc and wc -l.

+collection can implement equivalents for such Unix functions as sort, grep +-c, wc and wc -l.

@@ -1056,7 +1056,7 @@ collection can implement equivalents for such Unix functions as sort -

Implements Unix sort -u against resource collection input.

+

Implements Unix sort -u against resource collection input.

Set operations

The following resource collections implement set operations:

diff --git a/manual/Types/selectors-program.html b/manual/Types/selectors-program.html index 6f415edc5..55c3c9ac1 100644 --- a/manual/Types/selectors-program.html +++ b/manual/Types/selectors-program.html @@ -45,15 +45,15 @@ example.

To create a new Custom Selector, you have to create a class that - implements org.apache.tools.ant.types.selectors.ExtendFileSelector. The - easiest way to do that is through the convenience base - class org.apache.tools.ant.types.selectors.BaseExtendSelector, which - provides all of the methods for supporting <param> tags. First, - override the isSelected() method, and optionally - the verifySettings() method. If your custom selector requires parameters to - be set, you can also override the setParameters() method and interpret the - parameters that are passed in any way you like. Several of the core selectors - demonstrate how to do that because they can also be used as custom selectors.

+ implements org.apache.tools.ant.types.selectors.ExtendFileSelector. + The easiest way to do that is through the convenience base + class org.apache.tools.ant.types.selectors.BaseExtendSelector, + which provides all of the methods for supporting <param> tags. First, + override the isSelected() method, and optionally + the verifySettings() method. If your custom selector requires + parameters to be set, you can also override the setParameters() + method and interpret the parameters that are passed in any way you like. Several of the core + selectors demonstrate how to do that because they can also be used as custom selectors.

  • Core Selectors @@ -62,37 +62,40 @@
    • First, create a class that - implements org.apache.tools.ant.types.selectors.FileSelector. You can - either choose to implement all methods yourself from scratch, or you can - extend org.apache.tools.ant.types.selectors.BaseSelector instead, a - convenience class that provides reasonable default behaviour for many methods.

      - -

      There is only one method required. public boolean isSelected(File basedir, - String filename, File file) is the real purpose of the whole exercise. It - returns true or false depending on whether the given file should be - selected from the list or not.

      - -

      If you are using org.apache.tools.ant.types.selectors.BaseSelector - there are also some predefined behaviours you can take advantage of. Any time you - encounter a problem when setting attributes or adding tags, you can - call setError(String errmsg) and the class will know that there is a - problem. Then, at the top of your isSelected() method - call validate() and a BuildException will be thrown with the contents - of your error message. The validate() method also gives you a last - chance to check your settings for consistency because it - calls verifySettings(). Override this method and - call setError() within it if you detect any problems in how your - selector is set up.

      - -

      You may also want to override toString().

    • - -
    • Put an add method for your selector - in org.apache.tools.ant.types.selectors.SelectorContainer. This is an - interface, so you will also have to add an implementation for the method in the - classes which implement it, - namely org.apache.tools.ant.types.AbstractFileSet, org.apache.tools.ant.taskdefs.MatchingTask - and org.apache.tools.ant.types.selectors.BaseSelectorContainer. Once - it is in there, it will be available everywhere that core selectors are + implements org.apache.tools.ant.types.selectors.FileSelector. + You can either choose to implement all methods yourself from scratch, or you can + extend org.apache.tools.ant.types.selectors.BaseSelector + instead, a convenience class that provides reasonable default behaviour for many + methods.

      + +

      There is only one method required. public boolean isSelected(File + basedir, String filename, File file) is the real purpose of the whole + exercise. It returns true or false depending on whether the given file + should be selected from the list or not.

      + +

      If you are + using org.apache.tools.ant.types.selectors.BaseSelector there + are also some predefined behaviours you can take advantage of. Any time you encounter a + problem when setting attributes or adding tags, you can + call setError(String errmsg) and the class will know that + there is a problem. Then, at the top of your isSelected() + method call validate() and a BuildException will + be thrown with the contents of your error + message. The validate() method also gives you a last chance to + check your settings for consistency because it + calls verifySettings(). Override this method and + call setError() within it if you detect any problems in how + your selector is set up.

      + +

      You may also want to override toString().

    • + +
    • Put an add() method for your selector + in org.apache.tools.ant.types.selectors.SelectorContainer. + This is an interface, so you will also have to add an implementation for the method in + the classes which implement it, + namely org.apache.tools.ant.types.AbstractFileSet, org.apache.tools.ant.taskdefs.MatchingTask + and org.apache.tools.ant.types.selectors.BaseSelectorContainer. + Once it is in there, it will be available everywhere that core selectors are appropriate.
    @@ -100,18 +103,18 @@

    Got an idea for a new Selector Container? Creating a new one is no problem:

    • Create a new class that - implements org.apache.tools.ant.types.selectors.SelectorContainer. + implements org.apache.tools.ant.types.selectors.SelectorContainer. This will ensure that your new Container can access any new selectors that come along. Again, there is a convenience class available for you - called org.apache.tools.ant.types.selectors.BaseSelectorContainer.
    • -
    • Implement the public boolean isSelected(String filename, File file) - method to do the right thing. Chances are you'll want to iterate over the selectors - under you, so use selectorElements() to get an iterator that will do - that.
    • -
    • Again, put an add method for your container - in org.apache.tools.ant.types.selectors.SelectorContainer and its - implementations org.apache.tools.ant.types.AbstractFileSet - and org.apache.tools.ant.types.selectors.BaseSelectorContainer.
    • + called org.apache.tools.ant.types.selectors.BaseSelectorContainer. +
    • Implement the public boolean isSelected(String filename, File + file) method to do the right thing. Chances are you'll want to iterate over the + selectors under you, so use selectorElements() to get an + iterator that will do that.
    • +
    • Again, put an add() method for your container + in org.apache.tools.ant.types.selectors.SelectorContainer and + its implementations org.apache.tools.ant.types.AbstractFileSet + and org.apache.tools.ant.types.selectors.BaseSelectorContainer.
    @@ -119,16 +122,16 @@

    For a robust component (and selectors are (Project)Components) tests are necessary. For testing Tasks we use JUnit Tests and Rules—more - specific org.apache.tools.ant.BuildFileRule extends - org.junit.rules.ExternalResource. Some of its features like configure the (test) - project by reading its buildfile and execute targets we need for selector tests - also. Therefore we use that BuildFileRule. But testing selectors requires some more work: - having a set of files, instantiate and configure the selector, check the selection work and - more. Because we usually extend BaseExtendSelector its features have to be - tested also (e.g. setError()).

    + specific org.apache.tools.ant.BuildFileRule extends + org.junit.rules.ExternalResource. Some of its features like configure the (test) project + by reading its buildfile and execute targets we need for selector tests also. Therefore we use + that BuildFileRule. But testing selectors requires some more work: having a set of files, + instantiate and configure the selector, check the selection work and more. Because we usually + extend BaseExtendSelector its features have to be tested also + (e.g. setError()).

    That's why we have a test rule for doing our selector - tests: org.apache.tools.ant.types.selectors.BaseSelectorRule.

    + tests: org.apache.tools.ant.types.selectors.BaseSelectorRule.

    This class extends ExternalResource and therefore can included in the set of Ant's unit tests. It holds an instance of preconfigured BuildFileRule. Configuration is done by parsing @@ -180,32 +183,32 @@ public class MySelectorTest { [junit] at junit.framework.Assert.assertEquals(Assert.java:81) [junit] at org.apache.tools.ant.types.selectors.BaseSelectorTest.performTest(BaseSelectorTest.java:194) -

    Described above the test class should provide a getInstance() method. But - that isn't used here. The used getSelector() method is implemented in the base - class and gives an instance of an Ant Project to the selector. This is usually done inside - normal build file runs, but not inside this special environment, so this method gives the - selector the ability to use its own Project object (getProject()), for example - for logging.

    +

    Described above the test class should provide a getInstance() + method. But that isn't used here. The used getSelector() method is + implemented in the base class and gives an instance of an Ant Project to the selector. This is + usually done inside normal build file runs, but not inside this special environment, so this + method gives the selector the ability to use its own Project object + (getProject()), for example for logging.

    Logging

    -

    During development and maybe later you sometimes need the output of information. - Therefore Logging is needed. Because the selector extends BaseExtendSelector or directly - BaseSelector it is an Ant DataType and therefore - a ProjectComponent.
    That means that you have access to the project object - and its logging capability. ProjectComponent itself - provides log() methods which will do the access to the project +

    During development and maybe later you sometimes need the output of information. Therefore + Logging is needed. Because the selector extends BaseExtendSelector or directly BaseSelector it + is an Ant DataType and therefore + a ProjectComponent.
    That means that you have access to the + project object and its logging capability. ProjectComponent itself + provides log() methods which will do the access to the project instance. Logging is therefore done simply with:

    log("message");

    or

    log("message", loglevel);

    where the loglevel is one of the values

      -
    • org.apache.tools.ant.Project.MSG_ERR
    • -
    • org.apache.tools.ant.Project.MSG_WARN
    • -
    • org.apache.tools.ant.Project.MSG_INFO (default)
    • -
    • org.apache.tools.ant.Project.MSG_VERBOSE
    • -
    • org.apache.tools.ant.Project.MSG_DEBUG
    • +
    • org.apache.tools.ant.Project.MSG_ERR
    • +
    • org.apache.tools.ant.Project.MSG_WARN
    • +
    • org.apache.tools.ant.Project.MSG_INFO (default)
    • +
    • org.apache.tools.ant.Project.MSG_VERBOSE
    • +
    • org.apache.tools.ant.Project.MSG_DEBUG
    diff --git a/manual/Types/selectors.html b/manual/Types/selectors.html index 2c59d5955..f8a2631f1 100644 --- a/manual/Types/selectors.html +++ b/manual/Types/selectors.html @@ -34,10 +34,10 @@ any target by using the <selector> tag and then using it as a reference.

    Different selectors have different attributes. Some selectors can contain other selectors, - and these are called Selector Containers. There is - also a category of selectors that allow user-defined extensions, - called Custom Selectors. The ones built in to Apache - Ant are called Core Selectors.

    + and these are called Selector Containers. There is also + a category of selectors that allow user-defined extensions, + called Custom Selectors. The ones built in to Apache Ant are + called Core Selectors.

    Core Selectors

    @@ -877,36 +877,36 @@

    Readable Selector

    The <readable> selector selects only files that are readable. Ant only - invokes java.io.File#canRead so if a file is unreadable but JVM cannot detect this - state, this selector will still select the file.

    + invokes java.io.File#canRead so if a file is unreadable but JVM cannot + detect this state, this selector will still select the file.

    Writable Selector

    The <writable> selector selects only files that are writable. Ant only - invokes java.io.File#canWrite so if a file is nonwritable but JVM cannot detect - this state, this selector will still select the file.

    + invokes java.io.File#canWrite so if a file is nonwritable but JVM + cannot detect this state, this selector will still select the file.

    Executable Selector

    The <executable> selector selects only files that are executable. Ant - only invokes java.nio.file.Files#isExecutable so if a file is not executable but - JVM cannot detect this state, this selector will still select the file.

    + only invokes java.nio.file.Files#isExecutable so if a file is not + executable but JVM cannot detect this state, this selector will still select the file.

    Since Ant 1.10.0

    The <symlink> selector selects only files that are symbolic links. Ant - only invokes java.nio.file.Files#isSymbolicLink so if a file is a symbolic link but - JVM cannot detect this state, this selector will not select the file.

    + only invokes java.nio.file.Files#isSymbolicLink so if a file is a + symbolic link but JVM cannot detect this state, this selector will not select the file.

    Since Ant 1.10.0

    OwnedBy Selector

    The <ownedBy> selector selects only files that are owned by the given - user. Ant only invokes java.nio.file.Files#getOwner so if a file system doesn't - support the operation this selector will not select the file.

    + user. Ant only invokes java.nio.file.Files#getOwner so if a file + system doesn't support the operation this selector will not select the file.

    Since Ant 1.10.0

    @@ -1312,9 +1312,9 @@

    First, you have to write your selector class in Java. The only requirement it must meet in order to be a selector is that it implements - the org.apache.tools.ant.types.selectors.FileSelector interface, which contains a - single method. See Programming Selectors in Ant for more - information.

    + the org.apache.tools.ant.types.selectors.FileSelector interface, which + contains a single method. See Programming Selectors in Ant + for more information.

    Once that is written, you include it in your build file by using the <custom> tag.

    @@ -1328,7 +1328,7 @@
  • @@ -1362,15 +1362,15 @@
    • Contains Selector with - classname org.apache.tools.ant.types.selectors.ContainsSelector + classname org.apache.tools.ant.types.selectors.ContainsSelector
    • Date Selector with - classname org.apache.tools.ant.types.selectors.DateSelector + classname org.apache.tools.ant.types.selectors.DateSelector
    • Depth Selector with - classname org.apache.tools.ant.types.selectors.DepthSelector + classname org.apache.tools.ant.types.selectors.DepthSelector
    • Filename Selector with - classname org.apache.tools.ant.types.selectors.FilenameSelector + classname org.apache.tools.ant.types.selectors.FilenameSelector
    • Size Selector with - classname org.apache.tools.ant.types.selectors.SizeSelector + classname org.apache.tools.ant.types.selectors.SizeSelector

    Here is the example from the Depth Selector section rewritten to use the selector diff --git a/manual/Types/xmlcatalog.html b/manual/Types/xmlcatalog.html index 371ec0718..edc27fae4 100644 --- a/manual/Types/xmlcatalog.html +++ b/manual/Types/xmlcatalog.html @@ -38,8 +38,9 @@ Dependencies for more information.

    This data type provides a catalog of resource locations based on the OASIS XML Catalog standard. The catalog entries are used both for Entity -resolution and URI resolution, in accordance with the org.xml.sax.EntityResolver -and javax.xml.transform.URIResolver interfaces as defined in +resolution and URI resolution, in accordance with +the org.xml.sax.EntityResolver +and javax.xml.transform.URIResolver interfaces as defined in the Java API for XML Processing (JAXP) Specification.

    For example, in a web.xml file, the DTD is referenced as:

    @@ -193,21 +194,18 @@ warning will be logged.

    Set up an XMLCatalog with a single DTD referenced locally in a user's home directory:

     <xmlcatalog>
    -    <dtd
    -        publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
    -        location="/home/dion/downloads/docbook/docbookx.dtd"/>
    +    <dtd publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
    +         location="/home/dion/downloads/docbook/docbookx.dtd"/>
     </xmlcatalog>

    Set up an XMLCatalog with a multiple DTDs to be found either in the filesystem (relative to the Ant project basedir) or in the classpath:

     <xmlcatalog id="commonDTDs">
    -    <dtd
    -        publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
    -        location="docbook/docbookx.dtd"/>
    -    <dtd
    -        publicId="-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    -        location="web-app_2_2.dtd"/>
    +    <dtd publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
    +         location="docbook/docbookx.dtd"/>
    +    <dtd publicId="-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    +         location="web-app_2_2.dtd"/>
     </xmlcatalog>

    Set up an XMLCatalog with a combination of DTDs and entities as well as a nested XMLCatalog @@ -215,21 +213,17 @@ and external catalog files in both formats:

     <xmlcatalog id="allcatalogs">
    -    <dtd
    -        publicId="-//ArielPartners//DTD XML Article V1.0//EN"
    -        location="com/arielpartners/knowledgebase/dtd/article.dtd"/>
    -    <entity
    -        publicId="LargeLogo"
    -        location="com/arielpartners/images/ariel-logo-large.gif"/>
    +    <dtd publicId="-//ArielPartners//DTD XML Article V1.0//EN"
    +         location="com/arielpartners/knowledgebase/dtd/article.dtd"/>
    +    <entity publicId="LargeLogo"
    +            location="com/arielpartners/images/ariel-logo-large.gif"/>
         <xmlcatalog refid="commonDTDs"/>
             <catalogpath>
                 <pathelement location="/etc/sgml/catalog"/>
    -            <fileset
    -                dir="/anetwork/drive"
    -                includes="**/catalog"/>
    -            <fileset
    -                dir="/my/catalogs"
    -                includes="**/catalog.xml"/>
    +            <fileset dir="/anetwork/drive"
    +                     includes="**/catalog"/>
    +            <fileset dir="/my/catalogs"
    +                     includes="**/catalog.xml"/>
             </catalogpath>
         </xmlcatalog>
     </xmlcatalog>
    diff --git a/manual/argumentprocessor.html b/manual/argumentprocessor.html index 848ffe8dd..0d8c2c2d3 100644 --- a/manual/argumentprocessor.html +++ b/manual/argumentprocessor.html @@ -28,48 +28,42 @@

    What is an ArgumentProcessor?

    -An ArgumentProcessor is a parser of command line argument which is -then call before and after the build file is being parsed. Third party -libraries may then be able to have custom argument line argument which modify -Ant behaviour. +An ArgumentProcessor is a parser of command line argument which is then +call before and after the build file is being parsed. Third party libraries may then be able to have +custom argument line argument which modify Ant behaviour.

    -An ArgumentProcessor is called each time Ant parse an unknown -argument, an ArgumentProcessor doesn't take precedence over Ant to -parse already supported options. It is then recommended to third -party ArgumentProcessor implementation to chose specific 'enough' -argument name, avoiding for instance one letter arguments. +An ArgumentProcessor is called each time Ant parse an unknown argument, +an ArgumentProcessor doesn't take precedence over Ant to parse already +supported options. It is then recommended to third party ArgumentProcessor +implementation to chose specific 'enough' argument name, avoiding for instance one letter arguments.

    -It is also called at the different phases so different behaviour can be -implemented. It is called just after every arguments are parsed, just -before the project is being configured (the build file being parsed), -and just after. Some of the methods to be implemented return a boolean: -if true is returned, Ant will terminate immediately, without -error. +It is also called at the different phases so different behaviour can be implemented. It is called +just after every arguments are parsed, just before the project is being configured (the build file +being parsed), and just after. Some of the methods to be implemented return a boolean: +if true is returned, Ant will terminate immediately, without error.

    -Being called during all these phases, an ArgumentProcessor -can just print some specific system properties and quit -(like -diagnose), or print some specific properties of a -project after being parsed and quit (like -projectHelp), -or just set some custom properties on the project and let it run. +Being called during all these phases, an ArgumentProcessor can just print +some specific system properties and quit (like -diagnose), or print some specific +properties of a project after being parsed and quit (like -projectHelp), or just set some +custom properties on the project and let it run.

    How to register it's own ArgumentProcessor

    -

    First, the ArgumentProcessor must be an implementation of -org.apache.tools.ant.ArgumentProcessor. +

    First, the ArgumentProcessor must be an implementation +of org.apache.tools.ant.ArgumentProcessor.

    Then to declare it: create a -file META-INF/services/org.apache.tools.ant.ArgumentProcessor -which contains only one line the fully qualified name of the class of the -implementation. This file together with the implementation class need then to -be found in Ant's classpath. +file META-INF/services/org.apache.tools.ant.ArgumentProcessor which contains only one +line the fully qualified name of the class of the implementation. This file together with the +implementation class need then to be found in Ant's classpath.

    diff --git a/manual/cover.html b/manual/cover.html index 8ba4d6fee..bbadd5b88 100644 --- a/manual/cover.html +++ b/manual/cover.html @@ -26,7 +26,7 @@

    Apache Ant™ 1.10.3 Manual

    This is the manual for version 1.10.3 of Apache Ant. If your - version of Ant (as verified with ant -version) is older or newer than this version then this is not the + version of Ant (as verified with ant -version) is older or newer than this version then this is not the correct manual set. Please use the documentation appropriate to your current version. Also, if you are using a version older than the most recent release, we recommend an upgrade to fix bugs as well as provide new functionality.

    diff --git a/manual/develop.html b/manual/develop.html index 254e1f8a9..6806ced98 100644 --- a/manual/develop.html +++ b/manual/develop.html @@ -28,25 +28,25 @@

    Writing Your Own Task

    It is very easy to write your own task:

      -
    1. Create a Java class that extends org.apache.tools.ant.Task +
    2. Create a Java class that extends org.apache.tools.ant.Task or another class that was designed to be extended.
    3. For each attribute, write a setter method. The setter method must be a public void method that takes a single argument. The name of the method must begin with set, followed by the attribute name, with the first character of - the name in uppercase, and the rest in lowercase*. That - is, to support an attribute named file you create a method setFile. - Depending on the type of the argument, Ant will perform some conversions for you, - see below.
    4. + the name in uppercase, and the rest in lowercase*. That + is, to support an attribute named file you create a + method setFile. Depending on the type of the argument, Ant will + perform some conversions for you, see below.
    5. If your task shall contain other tasks as nested elements (like parallel), your class must implement the - interface org.apache.tools.ant.TaskContainer. If you do so, your task can not - support any other nested elements. See below.
    6. + interface org.apache.tools.ant.TaskContainer. If you do so, your task + can not support any other nested elements. See below.
    7. If the task should support character data (text nested between the start and end tags), write - a public void addText(String) method. Note that Ant does not - expand properties on the text it passes to the task.
    8. + a public void addText(String) method. Note that Ant + does not expand properties on the text it passes to the task.
    9. For each nested element, write a create, add or addConfigured method. A create method must be a public method that takes no arguments and returns @@ -57,7 +57,7 @@ (addConfigured), followed by the element name. For a more complete discussion see below.
    10. -
    11. Write a public void execute method, with no arguments, that throws +
    12. Write a public void execute() method, with no arguments, that throws a BuildException. This method implements the task itself.
    @@ -68,13 +68,14 @@ one doesn't really matter to Ant, using all lower case is a good convention, tho

    The Life-cycle of a Task

    1. The xml element that contains the tag corresponding to the task gets converted to - an UnknownElement at parse time. This UnknownElement gets placed in a - list within a target object, or recursively within another UnknownElement. + an UnknownElement at parse time. + This UnknownElement gets placed in a list within a target object, or + recursively within another UnknownElement.
    2. -
    3. When the target is executed, each UnknownElement is invoked using - an perform() method. This instantiates the task. This means that tasks only gets - instantiated at run time. +
    4. When the target is executed, each UnknownElement is invoked using + an perform() method. This instantiates the task. This means that tasks + only gets instantiated at run time.
    5. The task gets references to its project and location inside the buildfile via its @@ -86,29 +87,29 @@ one doesn't really matter to Ant, using all lower case is a good convention, tho
    6. The task gets a reference to the target it belongs to via its inherited target variable.
    7. -
    8. init() is called at run time.
    9. +
    10. init() is called at run time.
    11. All child elements of the XML element corresponding to this task are created via this - task's createXXX() methods or instantiated and added to this task via - its addXXX() methods, at run time. Child elements corresponding - to addConfiguredXXX() are created at this point but the - actual addConfigured method is not called.
    12. + task's createXXX() methods or instantiated and added to this task via + its addXXX() methods, at run time. Child elements corresponding + to addConfiguredXXX() are created at this point but the + actual addConfigured method is not called. -
    13. All attributes of this task get set via their corresponding setXXX methods, at - runtime.
    14. +
    15. All attributes of this task get set via their corresponding setXXX() + methods, at runtime.
    16. The content character data sections inside the XML element corresponding to this task is added - to the task via its addText method, at runtime.
    17. + to the task via its addText() method, at runtime. -
    18. All attributes of all child elements get set via their corresponding setXXX - methods, at runtime.
    19. +
    20. All attributes of all child elements get set via their + corresponding setXXX() methods, at runtime.
    21. If child elements of the XML element corresponding to this task have been created - for addConfiguredXXX() methods, those methods get invoked now.
    22. + for addConfiguredXXX() methods, those methods get invoked now. -
    23. execute() is called at runtime. If target1 - and target2 both depend on target3, then running 'ant target1 - target2' will run all tasks in target3 twice.
    24. +
    25. execute() is called at runtime. If target1 + and target2 both depend on target3, then running ant target1 target2 + will run all tasks in target3 twice.

    Conversions Ant will perform for attributes

    @@ -120,93 +121,98 @@ string containing a single property reference. These will be assigned directly v matching type. Since it requires some beyond-the-basics intervention to enable this behavior, it may be a good idea to flag attributes intended to permit this usage paradigm.

    -

    The most common way to write an attribute setter is to use a java.lang.String -argument. In this case Ant will pass the literal value (after property expansion) to your task. -But there is more! If the argument of you setter method is

    +

    The most common way to write an attribute setter is to use +a java.lang.String argument. In this case Ant will pass the literal value +(after property expansion) to your task. But there is more! If the argument of you setter method +is

      -
    • boolean, your method will be passed the value true if the value - specified in the build file is one of true, yes, or on - and false otherwise.
    • +
    • boolean, your method will be passed the value true if the value specified + in the build file is one of true, yes, or on and false + otherwise.
    • -
    • char or java.lang.Character, your method will be passed the first - character of the value specified in the build file.
    • +
    • char or java.lang.Character, your method will be passed + the first character of the value specified in the build file.
    • -
    • any other primitive type (int, short and so on), Ant will convert - the value of the attribute into this type, thus making sure that you'll never receive input that - is not a number for that attribute.
    • +
    • any other primitive type (int, short and + so on), Ant will convert the value of the attribute into this type, thus making sure that you'll + never receive input that is not a number for that attribute.
    • -
    • java.io.File, Ant will first determine whether the value given in the build file - represents an absolute path name. If not, Ant will interpret the value as a path name relative - to the project's basedir.
    • +
    • java.io.File, Ant will first determine whether the value given in + the build file represents an absolute path name. If not, Ant will interpret the value as a path + name relative to the project's basedir.
    • -
    • org.apache.tools.ant.types.Resource, Ant will resolve the string as - a java.io.File as above, then pass in as - a org.apache.tools.ant.types.resources.FileResource. Since Ant 1.8
    • +
    • org.apache.tools.ant.types.Resource, Ant will resolve the string as + a java.io.File as above, then pass in as + a org.apache.tools.ant.types.resources.FileResource. Since Ant + 1.8
    • -
    • org.apache.tools.ant.types.Path, Ant will tokenize the value specified in the - build file, accepting : and ; as path separators. Relative path names will be - interpreted as relative to the project's basedir.
    • +
    • org.apache.tools.ant.types.Path, Ant will tokenize the value + specified in the build file, accepting : and ; as path separators. Relative path + names will be interpreted as relative to the project's basedir.
    • -
    • java.lang.Class, Ant will interpret the value given in the build file as a Java - class name and load the named class from the system class loader.
    • +
    • java.lang.Class, Ant will interpret the value given in the build + file as a Java class name and load the named class from the system class loader.
    • -
    • any other type that has a constructor with a single String argument, Ant will use - this constructor to create a new instance from the value given in the build file.
    • +
    • any other type that has a constructor with a single String argument, + Ant will use this constructor to create a new instance from the value given in the build + file.
    • -
    • A subclass of org.apache.tools.ant.types.EnumeratedAttribute, Ant will invoke - this classes setValue method. Use this if your task should support enumerated - attributes (attributes with values that must be part of a predefined set of values). - See org/apache/tools/ant/taskdefs/FixCRLF.java and the - inner AddAsisRemove class used in setCr for an example.
    • +
    • A subclass of org.apache.tools.ant.types.EnumeratedAttribute, Ant + will invoke this class's setValue method. Use this if your task + should support enumerated attributes (attributes with values that must be part of a predefined + set of values). See org/apache/tools/ant/taskdefs/FixCRLF.java and the + inner AddAsisRemove class used in setCr for + an example.
    • A (Java 5) enumeration, Ant will call the setter with the enum constant matching the value - given in the build file. This is easier than using EnumeratedAttribute and can - result in cleaner code, but of course your task will not run on JDK 1.4 or earlier. Note that - any override of toString() in the enumeration is ignored; the build file must use - the declared name (see Enum.getName()). You may wish to use lowercase enum constant - names, in contrast to usual Java style, to look better in build files. Since Ant - 1.7.0
    • + given in the build file. This is easier than using EnumeratedAttribute + and can result in cleaner code, but of course your task will not run on JDK 1.4 or earlier. Note + that any override of toString() in the enumeration is ignored; the + build file must use the declared name (see Enum.getName()). You may wish to use + lowercase enum constant names, in contrast to usual Java style, to look better in build + files. Since Ant 1.7.0

    What happens if more than one setter method is present for a given attribute? A method taking -a String argument will always lose against the more specific methods. If there are -still more setters Ant could chose from, only one of them will be called, but we don't know which, -this depends on the implementation of your Java virtual machine.

    +a String argument will always lose against the more specific methods. If +there are still more setters Ant could chose from, only one of them will be called, but we don't +know which, this depends on the implementation of your Java virtual machine.

    Supporting nested elements

    Let's assume your task shall support nested elements with the name inner. First of all, you need a class that represents this nested element. Often you simply want to use one of -Ant's classes like org.apache.tools.ant.types.FileSet to support +Ant's classes like org.apache.tools.ant.types.FileSet to support nested fileset elements.

    Attributes of the nested elements or nested child elements of them will be handled using the same -mechanism used for tasks (i.e. setter methods for attributes, addText for nested text and -create/add/addConfigured methods for child elements).

    +mechanism used for tasks (i.e. setter methods for +attributes, addText() for nested text +and create/add/addConfigured methods for child elements).

    -

    Now you have a class NestedElement that is supposed to be used for your +

    Now you have a class NestedElement that is supposed to be used for your nested <inner> elements, you have three options:

      -
    1. public NestedElement createInner()
    2. -
    3. public void addInner(NestedElement anInner)
    4. -
    5. public void addConfiguredInner(NestedElement anInner)
    6. +
    7. public NestedElement createInner()
    8. +
    9. public void addInner(NestedElement anInner)
    10. +
    11. public void addConfiguredInner(NestedElement anInner)

    What is the difference?

    -

    Option 1 makes the task create the instance of NestedElement, there are no -restrictions on the type. For the options 2 and 3, Ant has to create an instance -of NestedInner before it can pass it to the task, this means, NestedInner -must have a public no-arg constructor or a public one-arg constructor -taking a Project class as a parameter. This is the only difference between options 1 -and 2.

    +

    Option 1 makes the task create the instance of NestedElement, there are +no restrictions on the type. For the options 2 and 3, Ant has to create an instance +of NestedInner before it can pass it to the task, this +means, NestedInner must have a public no-arg constructor or +a public one-arg constructor taking a Project class as a +parameter. This is the only difference between options 1 and 2.

    The difference between 2 and 3 is what Ant has done to the object before it passes it to the -method. addInner will receive an object directly after the constructor has been -called, while addConfiguredInner gets the object after the attributes and -nested children for this new object have been handled.

    +method. addInner() will receive an object directly after the constructor +has been called, while addConfiguredInner() gets the object after +the attributes and nested children for this new object have been handled.

    What happens if you use more than one of the options? Only one of the methods will be called, but we don't know which, this depends on the implementation of your JVM.

    @@ -215,12 +221,13 @@ but we don't know which, this depends on the implementation of your JVM.

    If your task needs to nest an arbitrary type that has been defined using <typedef> you have two options.

      -
    1. public void add(Type type)
    2. -
    3. public void addConfigured(Type type)
    4. +
    5. public void add(Type type)
    6. +
    7. public void addConfigured(Type type)

    The difference between 1 and 2 is the same as between 2 and 3 in the previous section.

    For example suppose one wanted to handle objects object of -type org.apache.tools.ant.taskdefs.condition.Condition, one may have a class:

    +type org.apache.tools.ant.taskdefs.condition.Condition, one may have a +class:

     public class MyTask extends Task {
         private List conditions = new ArrayList();
    @@ -270,8 +277,8 @@ public class Sample {
         }
     }

    This class defines a number of static classes that -implement/extend Path, MyFileSelector and MyInterface. These -may be defined and used as follows:

    +implement/extend Path, MyFileSelector +and MyInterface. These may be defined and used as follows:

     <typedef name="myfileselector" classname="Sample$MyFileSelector"
              classpath="classes" loaderref="classes"/>
    @@ -292,17 +299,19 @@ may be defined and used as follows:

    TaskContainer

    -

    The TaskContainer consists of a single method, addTask that basically -is the same as an add method for nested elements. The task instances -will be configured (their attributes and nested elements have been handled) when your -task's execute method gets invoked, but not before that.

    +

    The TaskContainer consists of a single +method, addTask that basically is the same as +an add method for nested elements. The task instances will be +configured (their attributes and nested elements have been handled) when your +task's execute method gets invoked, but not before that.

    -

    When we said execute would be called, we lied ;-). In fact, -Ant will call the perform method in org.apache.tools.ant.Task, which in -turn calls execute. This method makes sure that Build +

    When we said execute would be called, we lied +;-). In fact, Ant will call the perform method +in org.apache.tools.ant.Task, which in turn +calls execute. This method makes sure that Build Events will be triggered. If you execute the task instances nested into your task, you should -also invoke perform on these instances instead of -execute.

    +also invoke perform on these instances instead +of execute.

    Example

    Let's write our own task, which prints a message on the System.out stream. The task @@ -378,17 +387,19 @@ just been compiled.

    </project>

    Another way to add a task (more permanently) is to add the task name and implementing class name -to the default.properties file in the org.apache.tools.ant.taskdefs -package. Then you can use it as if it were a built-in task.

    +to the default.properties file in +the org.apache.tools.ant.taskdefs package. Then you can use it as if it +were a built-in task.


    Build Events

    Ant is capable of generating build events as it performs the tasks necessary to build a project. Listeners can be attached to Ant to receive these events. This capability could be used, for example, to connect Ant to a GUI or to integrate Ant with an IDE.

    -

    To use build events you need to create an ant Project object. You can then call -the addBuildListener method to add your listener to the project. Your listener must -implement the org.apache.tools.antBuildListener interface. The listener will receive +

    To use build events you need to create an ant Project object. You can +then call the addBuildListener method to add your listener to the +project. Your listener must implement +the org.apache.tools.antBuildListener interface. The listener will receive BuildEvents for the following events

    -Running ant -diagnostics is a good way to check that Ant is installed. It is also a first step towards +Running ant -diagnostics is a good way to check that Ant is installed. It is also a first step towards self-diagnosis of any problem. Any configuration problem reported to the user mailing list will probably result ins someone asking you to run the command and show the results, so save time by using it yourself.

    diff --git a/manual/javacprops.html b/manual/javacprops.html index 5593f2218..dc3e22bc2 100644 --- a/manual/javacprops.html +++ b/manual/javacprops.html @@ -26,7 +26,7 @@

    The source and target attributes of <javac> don't have any default values for -historical reasons. Since the underlying javac +historical reasons. Since the underlying javac compiler defaults depends on the JDK you use, you may encounter build files that don't explicitly set those attributes and that will no longer compile using a newer JDK. If you cannot change the build diff --git a/manual/listeners.html b/manual/listeners.html index 7677b81da..346e2056a 100644 --- a/manual/listeners.html +++ b/manual/listeners.html @@ -45,7 +45,7 @@ loggers.

    These are used internally for various recording and housekeeping operations, however new -listeners may registered on the command line through the -listener argument.

    +listeners may registered on the command line through the -listener argument.

    Loggers

    @@ -53,8 +53,8 @@ listeners may registered on the command line through the -listener
    • Receives a handle to the standard output and error print streams and therefore can log - information to the console or the -logfile specified file.
    • -
    • Logging level (-quiet, -verbose, -debug) aware
    • + information to the console or the -logfile specified file. +
    • Logging level (-quiet, -verbose, -debug) aware
    • Emacs-mode aware
    @@ -68,7 +68,7 @@ listeners may registered on the command line through the -listener
    - @@ -127,12 +127,12 @@ listeners may registered on the command line through the -listener

    DefaultLogger

    Simply run Ant normally, or:

    -
    ant -logger org.apache.tools.ant.DefaultLogger
    +
    ant -logger org.apache.tools.ant.DefaultLogger

    NoBannerLogger

    Removes output of empty target output.

    -
    ant -logger org.apache.tools.ant.NoBannerLogger
    +
    ant -logger org.apache.tools.ant.NoBannerLogger

    MailLogger

    The MailLogger captures all output logged through DefaultLogger (standard Ant output) and will @@ -266,7 +266,7 @@ failure messages individually.

    Attribute
    classname The name of your class that - implements org.apache.tools.ant.types.selectors.FileSelector. + implements org.apache.tools.ant.types.selectors.FileSelector. Yes
    org.apache.tools.ant.DefaultLoggerThe logger used implicitly unless overridden with the -logger command-line + The logger used implicitly unless overridden with the -logger command-line switch. BuildLogger
    -
    ant -logger org.apache.tools.ant.listener.MailLogger
    +
    ant -logger org.apache.tools.ant.listener.MailLogger

    AnsiColorLogger

    @@ -275,13 +275,13 @@ code escape sequences to it. It is just an extension of
    /path/to/your/file to +the ANT_OPTS environment variable. Ant's launching script recognizes this flag and will +pass it to the java command appropriately.

    Format:

     AnsiColorLogger.*=Attribute;Foreground;Background
    @@ -332,7 +332,7 @@ Background is one of the following:
     46 → Cyan
     47 → White
    -
    ant -logger org.apache.tools.ant.listener.AnsiColorLogger
    +
    ant -logger org.apache.tools.ant.listener.AnsiColorLogger

    Log4jListener

    Deprecated: Apache Log4j (1) is not developed any more. Last release is 1.2.17 @@ -340,8 +340,8 @@ from 26 May 2012 and contains vulnerability issues.

    Passes build events to Log4j, using the full classname's of the generator of each build event as the category:

      -
    • build started / build finished—org.apache.tools.ant.Project
    • -
    • target started / target finished—org.apache.tools.ant.Target
    • +
    • build started / build finished—org.apache.tools.ant.Project
    • +
    • target started / target finished—org.apache.tools.ant.Target
    • task started / task finished—the fully qualified classname of the task
    • message logged—the classname of one of the above, so if a task logs a message, its classname is the category used, and so on.
    • @@ -350,13 +350,13 @@ the category:

      on whether the build failed during that stage. Message events are logged according to their Ant logging level, mapping directly to a corresponding Log4j level.

      -
      ant -listener org.apache.tools.ant.listener.Log4jListener
      +
      ant -listener org.apache.tools.ant.listener.Log4jListener

      To use Log4j you will need the Log4j JAR file and a log4j.properties configuration file. Both should be placed somewhere in your Ant classpath. If the log4j.properties -is in your project root folder you can add this with -lib option:

      +is in your project root folder you can add this with -lib option:

      -
      ant -listener org.apache.tools.ant.listener.Log4jListener -lib .
      +
      ant -listener org.apache.tools.ant.listener.Log4jListener -lib .

      If, for example, you wanted to capture the same information output to the console by the DefaultLogger and send it to a file named build.log, you could use the following @@ -387,7 +387,7 @@ want to use the Log4j 2.x runtime. For using the bridge with Ant you have to ad

    • log4j-core-${log4j.version}.jar
    • log4j2.xml
    -

    to your classpath, e.g. via the -lib option. (For using the bridge, Ant +

    to your classpath, e.g. via the -lib option. (For using the bridge, Ant 1.9.10/1.10.2 or higher is required.) Translating the 1.x properties file into the 2.x XML syntax would result in

    @@ -414,7 +414,7 @@ would result in

    XmlLogger

    Writes all build information out to an XML file named log.xml, or the value of the XmlLogger.file property if present, when used as a listener. When used as a logger, -it writes all output to either the console or to the value of -logfile. Whether used as +it writes all output to either the console or to the value of -logfile. Whether used as a listener or logger, the output is not generated until the build is complete, as it buffers the information in order to provide timing information for task, targets, and the project.

    By default the XML file creates a reference to an XSLT file log.xsl in the current @@ -423,16 +423,16 @@ property ant.XmlLogger.stylesheet.uri to provide a URI to a style s relative or absolute file path, or an HTTP URL. If you set the property to the empty string, , no XSLT transform is declared at all.

    -
    ant -listener org.apache.tools.ant.XmlLogger
    +
    ant -listener org.apache.tools.ant.XmlLogger
     ant -logger org.apache.tools.ant.XmlLogger -verbose -logfile build_log.xml

    TimestampedLogger

    Acts like the default logger, except that the final success/failure message also includes the time that the build completed. For example:

    -
    BUILD SUCCESSFUL - at 16/08/05 16:24
    +
    BUILD SUCCESSFUL - at 16/08/05 16:24

    To use this listener, use the command:

    -
    ant  -logger org.apache.tools.ant.listener.TimestampedLogger
    +
    ant -logger org.apache.tools.ant.listener.TimestampedLogger

    BigProjectLogger

    This logger is designed to make examining the logs of a big build easier, especially those run @@ -447,7 +447,7 @@ under continuous integration tools. It

    This is useful when using <subant> to build a large project from many smaller projects—the output shows which particular project is building. Here is an example in which "clean" is being called on all a number of child projects, only some of which perform work:

    -
    +
     ======================================================================
     Entering project "xunit"
     In /home/ant/components/xunit
    @@ -474,13 +474,13 @@ Exiting project "junit"
     testing many child components, the messages are reduced to becoming clear delimiters of where
     different projects are in charge—or, more importantly, which project is failing.

    To use this listener, use the command:

    -
    ant -logger org.apache.tools.ant.listener.BigProjectLogger
    +
    ant -logger org.apache.tools.ant.listener.BigProjectLogger

    SimpleBigProjectLogger

    Since Ant 1.8.1

    Like BigProjectLogger, project-qualified target names are printed, useful for big builds with subprojects. Otherwise it is as quiet as NoBannerLogger:

    -
    +
     Buildfile: /sources/myapp/build.xml
     
     myapp-lib.compile:
    @@ -500,7 +500,7 @@ Building jar: /sources/myapp/build/myapp.jar
     BUILD SUCCESSFUL
     Total time: 1 second

    To use this listener, use the command:

    -
    ant -logger org.apache.tools.ant.listener.SimpleBigProjectLogger
    +
    ant -logger org.apache.tools.ant.listener.SimpleBigProjectLogger

    ProfileLogger

    @@ -522,9 +522,9 @@ Having that buildfile <echo>another-echo-task</echo> </target> </project>
    -

    and executing with ant -logger org.apache.tools.ant.listener.ProfileLogger -anotherTarget gives that output (with other timestamps and duration of course ;-):

    -
    +

    and executing with ant -logger org.apache.tools.ant.listener.ProfileLogger +anotherTarget gives that output (with other timestamps and duration of course ;-):

    +
     Buildfile: ...\build.xml
     
     Target aTarget: started Thu Jan 22 09:01:00 CET 2009
    @@ -562,23 +562,23 @@ Total time: 2 seconds
    • A listener or logger should not write to standard output or error in - the messageLogged() method; Ant captures these internally and it will trigger an - infinite loop. + the messageLogged() method; Ant captures these internally and it will + trigger an infinite loop.
    • Logging is synchronous; all listeners and loggers are called one after the other, with the build blocking until the output is processed. Slow logging means a slow build.
    • -
    • When a build is started, and BuildListener.buildStarted(BuildEvent event) is - called, the project is not fully functional. The build has started, yes, and - the event.getProject() method call returns the Project instance, but that project - is initialized with JVM and Ant properties, nor has it parsed the build file yet. You cannot - call Project.getProperty() for property lookup, or - Project.getName() to get the project name (it will return null). +
    • When a build is started, and BuildListener.buildStarted(BuildEvent + event) is called, the project is not fully functional. The build has started, yes, and + the event.getProject() method call returns the Project instance, but + that project is initialized with JVM and Ant properties, nor has it parsed the build file + yet. You cannot call Project.getProperty() for property lookup, or + Project.getName() to get the project name (it will return null).
    • - Classes that implement org.apache.tools.ant.SubBuildListener receive notifications - when child projects start and stop. + Classes that implement org.apache.tools.ant.SubBuildListener receive + notifications when child projects start and stop.
    diff --git a/manual/platform.html b/manual/platform.html index f1ee98fef..c9a89b0d5 100644 --- a/manual/platform.html +++ b/manual/platform.html @@ -46,7 +46,7 @@ or <apply> the real tar program. to build up a list of files. Unexpected things can happen.
  • Linux on IA-64: apparently you need a larger heap than the default one (64M) to compile big projects. If you get out of heap errors, either increase the heap or use a -forking javac. Better yet, use jikes for extra compilation speed.
  • +forking javac. Better yet, use jikes for extra compilation speed.

    Microsoft Windows

    @@ -87,7 +87,7 @@ Ant is trying to run, it is not on the path.

    There are reports of problems with Windows Vista security bringing up dialog boxes asking if the user wants to run an untrusted executable during an Ant run, such as when the <signjar> task -runs the jarsigner.exe program. This is beyond Ant's control, and stems from the OS +runs the jarsigner.exe program. This is beyond Ant's control, and stems from the OS trying to provide some illusion of security by being reluctant to run unsigned native executables. The latest Java versions appear to resolve this problem by having signed binaries.

    @@ -102,7 +102,7 @@ and JRE tools under Windows or cygwin. Relative path names such as src/org are supported, but Java tools do not understand /cygdrive/c to mean c:\.

    -The utility cygpath (used industrially in the ant script to support +The utility cygpath (used industrially in the ant script to support cygwin) can convert cygwin path names to Windows. You can use the <exec> task in Ant to convert cygwin paths to Windows path, for instance like that:

    @@ -139,7 +139,7 @@ or dist\bin).
  • CLASSPATH—put ant.jar and any other needed jars on the system classpath.
  • ANT_OPTS—On NetWare, ANT_OPTS needs to include a parameter of - the form, -envCWD=ANT_HOME, with ANT_HOME being the + the form, -envCWD=ANT_HOME, with ANT_HOME being the fully expanded location of Ant, not an environment variable. This is due to the fact that the NetWare System Console has no notion of a current working directory.
  • diff --git a/manual/projecthelper.html b/manual/projecthelper.html index 4c2523e76..057f07c1a 100644 --- a/manual/projecthelper.html +++ b/manual/projecthelper.html @@ -28,122 +28,114 @@

    What is a ProjectHelper?

    -The ProjectHelper in Apache Ant is responsible for parsing the build file -and creating Java instances representing the build workflow. It also signals which -kind of file it can parse, and which file name it expects as default input file. +The ProjectHelper in Apache Ant is responsible for parsing the build file +and creating Java instances representing the build workflow. It also signals which kind of file it +can parse, and which file name it expects as default input file.

    -Ant's default ProjectHelper -(org.apache.tools.ant.helper.ProjectHelper2) parses the -usual build.xml files. And if no build file is specified on the command -line, it will expect to find a file named build.xml. +Ant's default ProjectHelper +(org.apache.tools.ant.helper.ProjectHelper2) parses the +usual build.xml files. And if no build file is specified on the command line, it will +expect to find a file named build.xml.

    -The immediate benefit of a such abstraction it that it is possible to make Ant -understand other kind of descriptive languages than XML. Some experiments have been -done around a pure Java frontend, and a Groovy one too (ask the dev mailing list for -further info about these). +The immediate benefit of a such abstraction it that it is possible to make Ant understand other kind +of descriptive languages than XML. Some experiments have been done around a pure Java frontend, and +a Groovy one too (ask the dev mailing list for further info about these).

    -Since Ant 1.8.2, the import task will also -try to use the proper helper to parse the imported file. So it is possible to write -different build files in different languages and have them import each other. +Since Ant 1.8.2, the import task will also try to use the +proper helper to parse the imported file. So it is possible to write different build files in +different languages and have them import each other.

    How is Ant is selecting the proper ProjectHelper

    -Ant knows about several implementations of ProjectHelper and has to -decide which to use for each build file. +Ant knows about several implementations of ProjectHelper and has to decide +which to use for each build file.

    -At startup Ant lists the all implementations found and keeps them in the same order -they've been found in an internal 'repository': +At startup Ant lists the all implementations found and keeps them in the same order they've been +found in an internal 'repository':

      -
    • the first to be searched for is the one declared by the system property - org.apache.tools.ant.ProjectHelper (see - Java System Properties);
    • -
    • then it searches with its class loader for a ProjectHelper - service declarations in the META-INF: it searches in the classpath for a - file META-INF/services/org.apache.tools.ant.ProjectHelper. - This file will just contain the fully qualified name of the - implementation of ProjectHelper to instantiate;
    • -
    • it will also search with the system class loader for - ProjectHelper service declarations in the META-INF;
    • -
    • last but not least it will add its default ProjectHelper - that can parse classical build.xml files.
    • +
    • the first to be searched for is the one declared by the system + property org.apache.tools.ant.ProjectHelper + (see Java System Properties);
    • +
    • then it searches with its class loader for a ProjectHelper service declarations + in the META-INF: it searches in the classpath for a + file META-INF/services/org.apache.tools.ant.ProjectHelper. This file will just + contain the fully qualified name of the implementation + of ProjectHelper to instantiate;
    • +
    • it will also search with the system class loader for ProjectHelper + service declarations in the META-INF;
    • +
    • last but not least it will add its default ProjectHelper that can + parse classical build.xml files.

    -In case of an error while trying to instantiate a ProjectHelper, Ant will +In case of an error while trying to instantiate a ProjectHelper, Ant will log an error but won't stop. If you want further debugging info about -the ProjectHelper internal 'repository', use the system -property ant.project-helper-repo.debug and set it to true; -the full stack trace will then also be printed. +the ProjectHelper internal 'repository', use the system +property ant.project-helper-repo.debug and set it to true; the full stack trace +will then also be printed.

    -When Ant is expected to parse a file, it will ask the ProjectHelper -repository to find an implementation that will be able to parse the input -file. Actually it will just iterate over the ordered list and the first implementation -that returns true to supportsBuildFile(File buildFile) will -be selected. +When Ant is expected to parse a file, it will ask the ProjectHelper +repository to find an implementation that will be able to parse the input file. Actually it will +just iterate over the ordered list and the first implementation that returns true +to supportsBuildFile(File buildFile) will be selected.

    -When Ant is started and no input file has been specified, it will search for a default -input file. It will iterate over list of ProjectHelpers and will select -the first one that expects a default file that actually exist. +When Ant is started and no input file has been specified, it will search for a default input +file. It will iterate over list of ProjectHelpers and will select the +first one that expects a default file that actually exist.

    Writing your own ProjectHelper

    -The class org.apache.tools.ant.ProjectHelper is the API expected to be -implemented. So write your own ProjectHelper by extending that abstract -class. You are then expected to implement at least the function parse(Project -project, Object source). Note also that your implementation will be -instantiated by Ant, and it is expecting a default constructor with no arguments. +The class org.apache.tools.ant.ProjectHelper is the API expected to be +implemented. So write your own ProjectHelper by extending that abstract +class. You are then expected to implement at least the function parse(Project +project, Object source). Note also that your implementation will be instantiated by Ant, and +it is expecting a default constructor with no arguments.

    -There are some functions that will help you define what your helper is capable of and -what is is expecting: +There are some functions that will help you define what your helper is capable of and what is is +expecting:

      -
    • getDefaultBuildFile(): defines which file name is expected if - none provided
    • -
    • supportsBuildFile(File buildFile): defines if your parser - can parse the input file
    • -
    • canParseAntlibDescriptor(URL url): whether your - implementation is capable of parsing a given Antlib - descriptor. The base class returns false
    • -
    • parseAntlibDescriptor(Project containingProject, URL - source): invoked to actually parse the Antlib - descriptor if your implementation returned true - for the previous method.
    • +
    • getDefaultBuildFile(): defines which file name is expected if none + provided
    • +
    • supportsBuildFile(File buildFile): defines if your parser can parse + the input file
    • +
    • canParseAntlibDescriptor(URL url): whether your implementation is + capable of parsing a given Antlib descriptor. The base class returns false
    • +
    • parseAntlibDescriptor(Project containingProject, URL source): + invoked to actually parse the Antlib descriptor if your implementation returned true for + the previous method.

    -Now that you have your implementation ready, you have to declare it to Ant. Three -solutions here: +Now that you have your implementation ready, you have to declare it to Ant. Three solutions here:

      -
    • use the system property org.apache.tools.ant.ProjectHelper - (see also the Java System Properties);
    • +
    • use the system property org.apache.tools.ant.ProjectHelper (see also + the Java System Properties);
    • use the service file in META-INF: in the jar you will build with your - implementation, add a file - META-INF/services/org.apache.tools.ant.ProjectHelper. - And then in this file just put the fully qualified name of your - implementation
    • -
    • use the projecthelper task (since - Ant 1.8.2) which will install dynamically a helper in the internal helper - 'repository'. Then your helper can be used on the next call to the - import task.
    • + implementation, add a file META-INF/services/org.apache.tools.ant.ProjectHelper. + And then in this file just put the fully qualified name of your implementation +
    • use the projecthelper task (since Ant 1.8.2) + which will install dynamically a helper in the internal helper 'repository'. Then your helper + can be used on the next call to the import task.
    diff --git a/manual/properties.html b/manual/properties.html index 224d9a3b8..8dc459e8a 100644 --- a/manual/properties.html +++ b/manual/properties.html @@ -106,16 +106,18 @@

    PropertyHelpers

    Ant's property handling is accomplished by an instance - of org.apache.tools.ant.PropertyHelper associated with the current Project. You - can learn more about this class by examining Ant's Java API. In Ant 1.8 the PropertyHelper class - was much reworked and now itself employs a number of helper classes (actually instances of - the org.apache.tools.ant.PropertyHelper$Delegate marker interface) to take care of - discrete tasks such as property setting, retrieval, parsing, etc. This makes Ant's property - handling highly extensible; also of interest is the + of org.apache.tools.ant.PropertyHelper associated with the current + Project. You can learn more about this class by examining Ant's Java API. In Ant 1.8 the + PropertyHelper class was much reworked and now itself employs a number + of helper classes (actually instances of + the org.apache.tools.ant.PropertyHelper$Delegate marker interface) to + take care of discrete tasks such as property setting, retrieval, parsing, etc. This makes Ant's + property handling highly extensible; also of interest is the new propertyhelper task used to manipulate the PropertyHelper and its delegates from the context of the Ant buildfile.

    -

    There are three sub-interfaces of Delegate that may be useful to implement.

    +

    There are three sub-interfaces of Delegate that may be useful to + implement.

    • org.apache.tools.ant.property.PropertyExpander is responsible for finding the @@ -126,36 +128,36 @@ syntax—or allow nested property expansions since the default implementation doesn't balance braces (see NestedPropertyExpander in the props Antlib for + target="_top">NestedPropertyExpander in the props Antlib for an example).

    • -
    • org.apache.tools.ant.PropertyHelper$PropertyEvaluator is used to +
    • org.apache.tools.ant.PropertyHelper$PropertyEvaluator is used to expand ${some-string} into an Object.

      This is the interface you'd implement if you want to provide your own storage independent of Ant's project instance—the interface represents the reading end. An example for - this would be org.apache.tools.ant.property.LocalProperties which implements - storage for local properties.

      + this would be org.apache.tools.ant.property.LocalProperties which + implements storage for local properties.

      Another reason to implement this interface is if you wanted to provide your own "property protocol" like expanding toString:foo by looking up the project - reference foo and invoking toString() on it (which is already - implemented in Ant, see below).

      + reference foo and invoking toString() on it (which is + already implemented in Ant, see below).

    • -
    • org.apache.tools.ant.PropertyHelper$PropertySetter is responsible for setting - properties. +
    • org.apache.tools.ant.PropertyHelper$PropertySetter is responsible + for setting properties.

      This is the interface you'd implement if you want to provide your own storage independent of Ant's project instance—the interface represents the reading end. An example for - this would be org.apache.tools.ant.property.LocalProperties which implements - storage for local properties.

      + this would be org.apache.tools.ant.property.LocalProperties which + implements storage for local properties.

    -

    The default PropertyExpander looks similar to:

    +

    The default PropertyExpander looks similar to:

     public class DefaultExpander implements PropertyExpander {
    @@ -176,8 +178,9 @@ public class DefaultExpander implements PropertyExpander {
     }

    The logic that replaces ${toString:some-id} with the stringified - representation of the object with id some-id inside the current build is - contained in a PropertyEvaluator similar to the following code:

    + representation of the object with id some-id inside the current + build is contained in a PropertyEvaluator similar to the following + code:

     public class ToStringEvaluator implements PropertyHelper.PropertyEvaluator {
    @@ -234,10 +237,10 @@ public class ToStringEvaluator implements PropertyHelper.PropertyEvaluator {
     
       

    This means you can't use easily expand properties whose names are given by properties, but there are some workarounds for older versions of Ant. With Ant 1.8.0 and - the the props Antlib you can - configure Ant to use the NestedPropertyExpander defined there if you need such a - feature.

    + target="_top">some workarounds for older versions of Ant. Since Ant 1.8.0 using + the props Antlib you can + configure Ant to use the NestedPropertyExpander defined there if you + need such a feature.

    Expanding a "Property Name"

    @@ -253,9 +256,9 @@ public class ToStringEvaluator implements PropertyHelper.PropertyEvaluator {

    Any Ant type which has been declared with a reference can also its string value extracted by using the ${toString:} operation, with the name of the reference listed after - the toString: text. The toString() method of the Java class instance - that is referenced is invoked—all built in types strive to produce useful and relevant - output in such an instance.

    + the toString: text. The toString() method of the Java + class instance that is referenced is invoked—all built in types strive to produce useful + and relevant output in such an instance.

    For example, here is how to get a listing of the files in a fileset,

    @@ -272,12 +275,13 @@ public class ToStringEvaluator implements PropertyHelper.PropertyEvaluator { the ${ant.refid:} operation, with the name of the reference listed after the ant.refid: text. The difference between this operation and ${toString:} is that ${ant.refid:} will - expand to the referenced object itself. In most circumstances the toString method - will be invoked anyway, for example if the ${ant.refid:} is surrounded by other - text.

    + expand to the referenced object itself. In most circumstances + the toString() method will be invoked anyway, for example if + the ${ant.refid:} is surrounded by other text.

    This syntax is most useful when using a task with attribute setters that accept objects other - than String. For example, if the setter accepts a Resource object as in

    + than String. For example, if the setter accepts + a Resource object as in

    public void setAttr(Resource r) { ... }
    @@ -327,7 +331,7 @@ public class ToStringEvaluator implements PropertyHelper.PropertyEvaluator { </target> <target name="lots-of-stuff" depends="use-file,other-unconditional-stuff"/>

    - Now ant -Dfile.exists=false lots-of-stuff will run other-unconditional-stuff + Now ant -Dfile.exists=false lots-of-stuff will run other-unconditional-stuff but not use-file, as you might expect, and you can disable the condition from another script too:

    diff --git a/manual/proxy.html b/manual/proxy.html index 4071503be..72ed1366f 100644 --- a/manual/proxy.html +++ b/manual/proxy.html @@ -60,7 +60,7 @@

    Java 5+ proxy support

    Since Ant 1.7

    - When Ant starts up, if the -autoproxy command is + When Ant starts up, if the -autoproxy command is supplied, Ant sets the java.net.useSystemProxies system property. This tells a Java 5+ runtime to use the current set of property settings of the host environment. Other JVMs, such as @@ -78,7 +78,7 @@ like Oracle JDBC drivers or pure Java SVN clients.

    - To make the -autoproxy option the default, add it to + To make the -autoproxy option the default, add it to the environment variable ANT_ARGS, which contains a list of arguments to pass to Ant on every command line run.

    @@ -130,7 +130,7 @@

    Manual JVM options

    Any JVM can have its proxy options explicitly configured by passing - the appropriate -D system property options to the + the appropriate -D system property options to the runtime. Ant can be configured through all its shell scripts via the ANT_OPTS environment variable, which is a list of options to supply to Ant's JVM: @@ -260,7 +260,7 @@ For csh/tcsh: There are four ways to set up proxies in Ant.

      -
    1. With Ant 1.7 and Java 5+ using the -autoproxy parameter.
    2. +
    3. With Ant 1.7 and Java 5+ using the -autoproxy parameter.
    4. Via JVM system properties—set these in the ANT_ARGS environment variable.
    5. Via the <setproxy> task.
    6. Custom ProxySelector implementations
    7. @@ -275,7 +275,7 @@ For csh/tcsh: for Java code to adapt to them. However, given the fact that it currently does break some builds, it will be some time before Ant enables the automatic proxy feature by default. Until then, you have - to enable the -autoproxy option or use one of the + to enable the -autoproxy option or use one of the alternate mechanisms to configure the JVM.

      diff --git a/manual/running.html b/manual/running.html index e9d0ef248..84daea747 100644 --- a/manual/running.html +++ b/manual/running.html @@ -29,32 +29,32 @@

      If you've installed Apache Ant as described in the Installing Ant section, running Ant -from the command-line is simple: just type 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 (or +use the command-line option -buildfile file, +where file is the name of the build file you want to use (or a directory containing a build.xml file).

      -

      If you use the -find [file] option, Ant will +

      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 +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, +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 @@ -62,19 +62,19 @@ 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 +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, +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; -and -silent which makes Ant print nothing but task output +and -silent which makes Ant print nothing but task output and build failures (useful to capture Ant output by scripts).

      It is also possible to specify one or more targets that should be @@ -83,16 +83,16 @@ the default attribute of the project tag is used.

      -

      The -projecthelp option prints out a list of the build +

      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 "Other targets", then the "Default" target is listed ("Other targets" are only displayed if there are no main targets, or if Ant is invoked -in -verbose or -debug mode).

      +in -verbose or -debug mode).

      Command-line Options Summary

      -
      ant [options] [target [target2 [target3] ...]]
      +
      ant [options] [target [target2 [target3] ...]]
       Options:
         -help, -h              print this message and exit
         -projecthelp, -p       print project help information and exit
      @@ -128,10 +128,10 @@ Options:
         -autoproxy             Java 5+ : use the OS proxies
         -main <class>          override Ant's normal entry point
       
      -

      For more information about -logger and --listener see +

      For more information about -logger and +-listener see Loggers & Listeners. -

      For more information about -inputhandler see +

      For more information about -inputhandler see InputHandler.

      Easiest way of changing the exit-behaviour is subclassing the original main class:

      @@ -141,7 +141,7 @@ public class CustomExitCode extends org.apache.tools.ant.Main {
           }
       }
       
      -

      and starting Ant with access (-lib path-to-class) to this class.

      +

      and starting Ant with access (-lib path-to-class) to this class.

      Library Directories

      @@ -160,22 +160,22 @@ installation to be locked down which will please system administrators.

      Additional directories to be searched may be added by using -the -lib option. The -lib option specifies +the -lib option. The -lib option specifies a search path. Any jars or classes in the directories of the path will be added to Ant's classloader. The order in which jars are added to the classpath is as follows:

        -
      • -lib jars in the order specified by the -lib options on the command line
      • -
      • jars from ${user.home}/.ant/lib (unless -nouserlib is set)
      • +
      • jars in the order specified by the -lib options on the command line
      • +
      • jars from ${user.home}/.ant/lib (unless -nouserlib is set)
      • jars from ANT_HOME/lib

      Note that the CLASSPATH environment variable is passed -to Ant using a -lib option. Ant itself is started with a +to Ant using a -lib option. Ant itself is started with a very minimalistic classpath. Ant should work perfectly well with an empty CLASSPATH environment variable, something the -the -noclasspath option actually enforces. We get many +the -noclasspath option actually enforces. We get many more support calls related to classpath problems (especially quoting problems) than we like.

      @@ -188,30 +188,30 @@ your JVM documentation for more details.

      Examples

      -
      ant
      +
      ant

      runs Ant using the build.xml file in the current directory, on the default target.

      -
      ant -buildfile test.xml
      +
      ant -buildfile test.xml

      runs Ant using the test.xml file in the current directory, on the default target.

      -
      ant -buildfile test.xml dist
      +
      ant -buildfile test.xml dist

      runs Ant using the test.xml file in the current directory, on the target called dist.

      -
      ant -buildfile test.xml -Dbuild=build/classes dist
      +
      ant -buildfile test.xml -Dbuild=build/classes dist

      runs Ant using the test.xml file in the current directory, on the target called dist, setting the build property to the -value build/classes.

      +value build/classes.

      -
      ant -lib /home/ant/extras
      +
      ant -lib /home/ant/extras

      runs Ant picking up additional task and support jars from the /home/ant/extras location

      -
      ant -lib one.jar;another.jar
      -
      ant -lib one.jar -lib another.jar
      +
      ant -lib one.jar;another.jar
      +
      ant -lib one.jar -lib another.jar

      adds two jars to Ants classpath.

      Files

      @@ -238,8 +238,8 @@ section for examples.

    8. ANT_ARGS—Ant command-line arguments. For example, set ANT_ARGS to point to a different logger, include a - listener, and to include the -find flag.
      - Note: If you include -find + listener, and to include the -find flag.
      + Note: If you include -find in ANT_ARGS, you should include the name of the build file to find, even if the file is called build.xml.
    9. @@ -248,7 +248,7 @@ section for examples.

      Some of Ant's core classes can be configured via system properties.

      Here is the result of a search through the codebase. Because system properties are available via Project instance, I searched for them with a

      -
      grep -r -n "getPropert" * > ..\grep.txt
      +
      grep -r -n "getPropert" * > ..\grep.txt

      command. After that I filtered out the often-used but not-so-important values (most of them read-only values): path.separator, ant.home, basedir, user.dir, os.name, line.separator, java.home, java.version, java.version, user.home, java.class.path
      @@ -358,34 +358,34 @@ properties are available via Project instance, I searched for them with a

      build.compiler.emacs boolean (default false) Enable emacs-compatible error messages; - see javac "Jikes Notes". + see javac "Jikes Notes". build.compiler.fulldepend boolean (default false) Enable full dependency checking; - see javac "Jikes Notes". + see javac "Jikes Notes". build.compiler.jvc.extensions Deprecated Enable Microsoft extensions of their Java compiler; - see javac "Jvc Notes". + see javac "Jvc Notes". build.compiler.pedantic boolean (default false) Enable pedantic warnings; - see javac "Jikes Notes". + see javac "Jikes Notes". build.compiler.warnings Deprecated - See javac "Jikes Notes" + See javac "Jikes Notes" build.rmic @@ -508,15 +508,15 @@ that command being available in the Windows path.

      OS/2 Users

      The OS/2 launch script was developed to perform complex tasks. It has -two parts: ant.cmd which calls Ant -and antenv.cmd which sets the environment for Ant. Most -often you will just call ant.cmd using the same command +two parts: ant.cmd which calls Ant +and antenv.cmd which sets the environment for Ant. Most +often you will just call ant.cmd using the same command line options as described above. The behaviour can be modified by a number of ways explained below.

      -Script ant.cmd first verifies whether the Ant environment +Script ant.cmd first verifies whether the Ant environment is set correctly. The requirements are:

        @@ -527,36 +527,36 @@ is set correctly. The requirements are:

      -If any of these conditions is violated, script antenv.cmd +If any of these conditions is violated, script antenv.cmd is called. This script first invokes configuration scripts if there -exist: the system-wide configuration antconf.cmd from +exist: the system-wide configuration antconf.cmd from the %ETC% directory and then the user -configuration antrc.cmd from the %HOME% +configuration antrc.cmd from the %HOME% directory. At this moment both JAVA_HOME and ANT_HOME must be defined -because antenv.cmd now adds classes.zip +because antenv.cmd now adds classes.zip or tools.jar (depending on version of JVM) and everything from %ANT_HOME%\lib except ant-*.jar -to CLASSPATH. Finally ant.cmd calls -per-directory configuration antrc.cmd. All settings made -by ant.cmd are local and are undone when the script -ends. The settings made by antenv.cmd are persistent +to CLASSPATH. Finally ant.cmd calls +per-directory configuration antrc.cmd. All settings made +by ant.cmd are local and are undone when the script +ends. The settings made by antenv.cmd are persistent during the lifetime of the shell (of course unless called -automatically from ant.cmd). It is thus possible to -call antenv.cmd manually and modify some settings before -calling ant.cmd. +automatically from ant.cmd). It is thus possible to +call antenv.cmd manually and modify some settings before +calling ant.cmd.

      -Scripts envset.cmd and runrc.cmd perform +Scripts envset.cmd and runrc.cmd perform auxiliary tasks. All scripts have some documentation inside.

      Running Ant as a background process on Unix(-like) systems

      -If you start Ant as a background process (like in ant -&) and the build process creates another process, Ant will +If you start Ant as a background process (like in ant +&) and the build process creates another process, Ant will immediately try to read from standard input, which in turn will most likely suspend the process. In order to avoid this, you must redirect Ant's standard input or explicitly provide input to each spawned @@ -576,13 +576,13 @@ If you have installed Ant in the do-it-yourself way, Ant can be started from one of two entry points:

      -
      java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]
      -
      java -Dant.home=c:\ant org.apache.tools.ant.launch.Launcher [options] [target]
      +
      java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]
      +
      java -Dant.home=c:\ant org.apache.tools.ant.launch.Launcher [options] [target]

      The first method runs Ant's traditional entry point. The second method uses the Ant Launcher introduced in Ant 1.6. The former method does -not support the -lib option and all required classes are +not support the -lib option and all required classes are loaded from the CLASSPATH. You must ensure that all required jars are available. At a minimum the CLASSPATH should include: @@ -596,7 +596,7 @@ should include:

      The latter method supports -the -lib, -nouserlib, -noclasspath +the -lib, -nouserlib, -noclasspath options and will load jars from the specified ANT_HOME. You should start the latter with the most minimal classpath possible, generally just diff --git a/manual/stylesheets/style.css b/manual/stylesheets/style.css index 37ad35ebc..9b356456e 100644 --- a/manual/stylesheets/style.css +++ b/manual/stylesheets/style.css @@ -80,7 +80,7 @@ q.no-break { hyphens: none; } -code, samp { +code, samp, kbd { white-space: nowrap; hyphens: none; font-size: 1.125rem; @@ -114,10 +114,29 @@ pre var, code var { background: #efefef; } +/* highlight console input */ +.input, kbd { + color: white; + background: darkseagreen; + overflow: hidden; + text-overflow: ellipsis; +} + /* highlight console output */ .output { color: white; background: #837A67; + overflow: hidden; + text-overflow: ellipsis; +} + +/* a workaround for invisible + (white on white) overflows */ +pre.input:hover, pre.output:hover { + margin-right: 0; + margin-left: 0; + overflow: scroll; + text-overflow: initial; } td { diff --git a/manual/targets.html b/manual/targets.html index ba239ff2b..a3f2471a2 100644 --- a/manual/targets.html +++ b/manual/targets.html @@ -121,9 +121,9 @@

      The optional description attribute can be used to provide a one-line description of this target, which is printed by - the -projecthelp command-line option. Targets without + the -projecthelp command-line option. Targets without such a description are deemed internal and will not be listed, - unless either the -verbose or -debug + unless either the -verbose or -debug option is used.

      It is a good practice to place @@ -241,7 +241,7 @@

      Unlike targets they don't contain any tasks, their main purpose is to collect targets that contribute to the desired state in - their depends list.

      + their depends list.

      Targets can add themselves to an extension-point's depends list via diff --git a/manual/tasksoverview.html b/manual/tasksoverview.html index 8eb702ee7..7e69b5103 100644 --- a/manual/tasksoverview.html +++ b/manual/tasksoverview.html @@ -107,14 +107,14 @@ documentation.

      Rpm -

      Invokes the rpm executable to build a Linux +

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

      SignJar -

      Signs a jar or zip file with the javasign +

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

      @@ -227,7 +227,7 @@ documentation.

      Rmic -

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

      +

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

      @@ -270,7 +270,7 @@ documentation.

      Javadoc -

      Generates code documentation using the javadoc +

      Generates code documentation using the javadoc tool. The Javadoc2 task is deprecated; use the Javadoc task instead.

      @@ -417,7 +417,7 @@ documentation.

      Changes 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.

      + chmod command.

      @@ -662,8 +662,9 @@ documentation.

      Fail -

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

      +

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

      @@ -1018,9 +1019,9 @@ documentation.

      CVSPass -

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

      +

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

      @@ -1033,26 +1034,26 @@ documentation.

      ClearCase -

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

      +

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

      Continuus/Synergy -

      Tasks to perform the Continuus ccmcheckin, - ccmcheckout, ccmcheckintask, ccmreconfigure, - and ccmcreateTask commands.

      +

      Tasks to perform the Continuus ccm checkin, + checkout, reconfigure, ccmcheckintask, + and ccmcreatetask commands.

      Microsoft Visual SourceSafe -

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

      +

      Tasks to perform the Visual SourceSafe ss get, + label, history, checkin, + checkout, add, cp, + and create commands.

      @@ -1063,8 +1064,8 @@ documentation.

      SourceOffSite -

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

      +

      Tasks to perform the SourceOffSite sos get, label, + checkin, and checkout commands.

      diff --git a/manual/tutorial-HelloWorldWithAnt.html b/manual/tutorial-HelloWorldWithAnt.html index 784b1424c..41d64048d 100644 --- a/manual/tutorial-HelloWorldWithAnt.html +++ b/manual/tutorial-HelloWorldWithAnt.html @@ -43,12 +43,12 @@ individual steps: classes for our compiled files and jarWe have to create only the src directory. (Because I am working on Windows, here is the Windows syntax—translate to your shell):

      -
      md src
      +
      md src

      The following simple Java class just prints a fixed message out to STDOUT, so just write this code into src\oata\HelloWorld.java.

      -
      +
       package oata;
       
       public class HelloWorld {
      @@ -58,7 +58,7 @@ public class HelloWorld {
       }

      Now just try to compile and run that:

      -
      +
       md build\classes
       javac -sourcepath src -d build\classes src\oata\HelloWorld.java
       java -cp build\classes oata.HelloWorld
      @@ -67,14 +67,14 @@ which will result in

      Creating a jar-file is not very difficult. But creating a startable jar-file needs more steps: create a manifest-file containing the start class, creating the target directory and archiving the files.

      -
      +
       echo Main-Class: oata.HelloWorld>myManifest
       md build\jar
       jar cfm build\jar\HelloWorld.jar myManifest -C build\classes .
       java -jar build\jar\HelloWorld.jar
      -

      Note: Do not have blanks around the >-sign in the echo -Main-Class instruction because it would falsify it!

      +

      Note: Do not have blanks around the >-sign in the echo Main-Class instruction because +it would falsify it!

      Four steps to a running application

      After finishing the java-only step we have to think about our build process. We have to compile our code, @@ -85,7 +85,7 @@ startable jar file would be nice ... And it's a good practise to have a clean generated stuff. Many failures could be solved just by a "clean build".

      By default Ant uses build.xml as the name for a buildfile, so our .\build.xml would be:

      -
      +
       <project>
       
           <target name="clean">
      @@ -113,12 +113,12 @@ generated stuff. Many failures could be solved just by a "clean build".

      </project>

      Now you can compile, package and run the application via

      -
      +
       ant compile
       ant jar
       ant run

      Or shorter with

      -
      ant compile jar run
      +
      ant compile jar run

      While having a look at the buildfile, we will see some similar steps between Ant and the Java-only commands:

      @@ -127,7 +127,7 @@ ant run - - @@ -180,7 +180,7 @@ and <taskdef>). When you do this they are evaluated before a will generate build failures if they are used outside of targets as they may cause infinite loops otherwise (<antcall> for example).

      -

      We have given some targets descriptions; this causes the -projecthelp invocation option to list them as +

      We have given some targets descriptions; this causes the -projecthelp invocation option to list them as public targets with the descriptions; the other target is internal and not listed.

      Finally, for this target to work the source in the src subdirectory should be stored in a directory tree which matches the package names. Check the <javac> task for details.

      @@ -424,7 +424,7 @@ deliberately assign a different meaning to refid.

      Don't add anything to the CLASSPATH environment variable—this is often the reason for very obscure errors. Use Ant's own mechanisms for adding libraries:

        -
      • via command line argument -lib
      • +
      • via command line argument -lib
      • adding to ${user.home}/.ant/lib
      • adding to ${ant.home}/lib
      Ant
      +  
       md build\classes
       javac
           -sourcepath src
      @@ -144,7 +144,7 @@ jar cfm
       
       
       java -jar build\jar\HelloWorld.jar
      +  
       <mkdir dir="build/classes"/>
       <javac
           srcdir="src"
      @@ -171,7 +171,7 @@ steps.

      The first and second point would be addressed with properties, the third with a special property—an attribute of the <project> tag and the fourth problem can be solved using dependencies.

      -
      +
       <project name="HelloWorld" basedir="." default="main">
       
           <property name="src.dir"     value="src"/>
      @@ -212,7 +212,7 @@ attribute of the <project> tag and the fourth problem can be
       
       </project>
      -

      Now it's easier, just do a ant and you will get

      +

      Now it's easier, just do a ant and you will get

       Buildfile: build.xml
       
      @@ -252,7 +252,7 @@ this library could be accessed during compilation and run.

      the Short Manual [2]. First we have to modify the java source to use the logging framework:

      -
      +
       package oata;
       
       import org.apache.log4j.Logger;
      @@ -269,13 +269,13 @@ public class HelloWorld {
       
       

      Most of the modifications are "framework overhead" which has to be done once. The blue line is our "old System-out" statement.

      -

      Don't try to run ant—you will only get lot of compiler errors. Log4J is not on the classpath so we +

      Don't try to run ant—you will only get lot of compiler errors. Log4J is not on the classpath so we have to do a little work here. But do not change the CLASSPATH environment variable! This is only for this project and maybe you would break other environments (this is one of the most famous mistakes when working with Ant). We introduce Log4J (or to be more precise: all libraries (jar-files) which are somewhere under .\lib) into our buildfile:

      -
      +
       <project name="HelloWorld" basedir="." default="main">
           ...
           <property name="lib.dir"     value="lib"/>
      @@ -304,9 +304,9 @@ buildfile:

      </project>
      -

      In this example we start our application not via its Main-Class manifest-attribute, because we could not provide a -jarname and a classpath. So add our class in the red line to the already defined path and start as -usual. Running ant would give (after the usual compile stuff):

      +

      In this example we start our application not via its Main-Class manifest-attribute, because we could not +provide a jarname and a classpath. So add our class in the red line to the already defined path and start as +usual. Running ant would give (after the usual compile stuff):

      [java] 0 [main] INFO oata.HelloWorld  - Hello World
      @@ -324,14 +324,14 @@ usual. Running ant would give (after the usual compile stuff):

      Configuration files

      Why we have used Log4J? "It's highly configurable"? No—all is hardcoded! But that is not the fault of -Log4J—it's ours. We had coded BasicConfigurator.configure(); which implies a simple, but hardcoded -configuration. More comfortable would be using a property file. In the Java source file, delete -the BasicConfiguration line from the main() method (and the -related import-statement). Log4J will search then for a configuration as described in it's manual. Then +Log4J—it's ours. We had coded BasicConfigurator.configure(); which implies a simple, but +hardcoded configuration. More comfortable would be using a property file. In the Java source file, delete +the BasicConfiguration line from the main() method (and the +related import statement). Log4J will search then for a configuration as described in it's manual. Then create a new file src/log4j.properties. That's the default name for Log4J's configuration and using that name would make life easier—not only the framework knows what is inside, you too!

      -
      +
       log4j.rootLogger=DEBUG, stdout
       
       log4j.appender.stdout=org.apache.log4j.ConsoleAppender
      @@ -341,11 +341,11 @@ log4j.appender.stdout.layout.ConversionPattern=<
       

      This configuration creates an output channel (Appender) to console named as stdout which prints -the message (%m) followed by a line feed (%n)—same as the earlier System.out.println() -:-) Oooh kay—but we haven't finished yet. We should deliver the configuration file, too. So we change the -buildfile:

      +the message (%m) followed by a line feed (%n)—same as the +earlier System.out.println() :-) Oooh kay—but we haven't finished yet. We should deliver +the configuration file, too. So we change the buildfile:

      -
      +
           ...
           <target name="compile">
               <mkdir dir="${classes.dir}"/>
      @@ -363,7 +363,7 @@ start the application from that directory and these files will included into the
       

      In this step we will introduce the usage of the JUnit [3] test framework in combination with Ant. Because Ant has a built-in JUnit 4.12 you could start directly using it. Write a test class in src\HelloWorldTest.java:

      -
      +
       import org.junit.Test;
       
       public class HelloWorldTest {
      @@ -383,7 +383,7 @@ public class HelloWorldTest {
       information see the JUnit documentation [3] and the manual of junit task.  Now we add a
       junit instruction to our buildfile:

      -
      +
           ...
       
           <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
      @@ -418,7 +418,7 @@ How much tests failed? Some errors? printsummary lets us know.  The c
       To run tests the batchtest here is used, so you could easily add more test classes in the future just by
       naming them *Test.java.  This is a common naming scheme.

      -

      After a ant junit you'll get:

      +

      After a ant junit you'll get:

       ...
      @@ -433,7 +433,7 @@ BUILD SUCCESSFUL
       

      We can also produce a report. Something that you (and other) could read after closing the shell .... There are two steps: 1. let <junit> log the information and 2. convert these to something readable (browsable).

      -

      +
           ...
           <property name="report.dir"  value="${build.dir}/junitreport"/>
           ...
      diff --git a/manual/tutorial-tasks-filesets-properties.html b/manual/tutorial-tasks-filesets-properties.html
      index 8df706f6e..220ae8d9d 100644
      --- a/manual/tutorial-tasks-filesets-properties.html
      +++ b/manual/tutorial-tasks-filesets-properties.html
      @@ -46,7 +46,7 @@ property.

      Build environment

      We can use the buildfile from the other tutorial and modify it a little bit. That's the advantage of using properties—we can reuse nearly the whole script. :-)

      -
      +
       <?xml version="1.0" encoding="UTF-8"?>
       <project name="FindTask" basedir="." default="test">
           ...
      @@ -66,18 +66,18 @@ same for sources).

      Property access

      Our first step is to set a property to a value and print the value of that property. So our scenario would be

      -
      +
           <find property="test" value="test-value"/>
           <find print="test"/>

      Ok, it can be rewritten with the core tasks

      -
      +
           <property name="test" value="test-value"/>
           <echo message="${test}"/>

      but I have to start on known ground :-)

      So what to do? Handling three attributes (property, value, print) and an execute method. Because this is only an introduction example I don't do much checking:

      -
      +
       import org.apache.tools.ant.BuildException;
       
       public class Find extends Task {
      @@ -104,15 +104,16 @@ public class Find extends Task {
           }
       }
      -

      As said in the other tutorial, the property access is done via Project instance. We get this instance via the -public getProject() method which we inherit from Task (more precisely -from ProjectComponent). Reading a property is done via getProperty(propertyname) (very -simple, isn't it?). This property returns the value as String or null if not set.
      -Setting a property is ... not really difficult, but there is more than one setter. You can use -the setProperty() method which will do the job as expected. But there is a golden rule in -Ant: properties are immutable. And this method sets the property to the specified value—whether it has a -value before that or not. So we use another way. setNewProperty() sets the property only if there is no -property with that name. Otherwise a message is logged.

      +

      As said in the other tutorial, the property access is done via Project instance. We get +this instance via the public getProject() method which we inherit +from Task (more precisely from ProjectComponent). Reading a property +is done via getProperty(propertyname) (very simple, isn't it?). This property returns +the value as String or null if not set.
      Setting a property is ... not really difficult, +but there is more than one setter. You can use the setProperty() method which will do the job +as expected. But there is a golden rule in Ant: properties are immutable. And this method sets the property to +the specified value—whether it has a value before that or not. So we use another +way. setNewProperty() sets the property only if there is no property with that name. Otherwise +a message is logged.

      (By the way, a short explanation of Ant's "namespaces"—not to be confused with XML namespaces: an <antcall> creates a new space for property names. All properties from the caller are passed to the @@ -123,7 +124,7 @@ callee, but the callee can set its own properties without notice by the caller.)

      After putting our two line example from above into a target names use.simple we can call that from our test case:

      -
      +
       import org.junit.Assert;
       import org.junit.Before;
       import org.junit.Rule;
      @@ -154,7 +155,7 @@ public class FindTest {
       and I don't have to spend more explanations about their usage in buildfiles. Our goal is to search for a file in
       path. And in this step the path is simply a fileset (or more precise: a collection of filesets). So our usage would
       be

      -
      +
           <find file="ant.jar" location="location.ant-jar">
               <fileset dir="${ant.home}" includes="**/*.jar"/>
           </find>
      @@ -162,7 +163,7 @@ be

      What do we need? A task with two attributes (file, location) and nested filesets. Because we had attribute handling already explained in the example above and the handling of nested elements is described in the other tutorial, the code should be very easy:

      -
      +
       public class Find extends Task {
       
           private String file;
      @@ -196,10 +197,10 @@ tested?

    10. don't find a present file
    11. behaviour if file can't be found
    12. -

      Maybe you find some more test cases. But this is enough for now.
      -For each of these points we create a testXX method.

      +

      Maybe you find some more test cases. But this is enough for now.
      For each of these points we create +a testXX method.

      -
      +
       public class FindTest {
       
           @Rule
      @@ -252,10 +253,10 @@ public class FindTest {
           }
       }
      -

      If we run this test class all test cases (except testFileNotPresent) fail. Now we can implement our task, -so that these test cases will pass.

      +

      If we run this test class all test cases (except testFileNotPresent) fail. Now we can +implement our task, so that these test cases will pass.

      -
      +
           protected void validate() {
               if (file == null) throw new BuildException("file not set");
               if (location == null) throw new BuildException("location not set");
      @@ -281,28 +282,29 @@ so that these test cases will pass.

      getProject().setNewProperty(location, foundLocation); }
      -

      On //1 we check the prerequisites for our task. Doing that in a validate-method is a -common way, because we separate the prerequisites from the real work. On //2 we iterate over all nested -filesets. If we don't want to handle multiple filesets, the addFileset() method has to reject the further -calls. We can get the result of a fileset via its DirectoryScanner like done in //3. After that we -create a platform independent String representation of the file path (//4, can be done in other ways of -course). We have to do the replace(), because we work with a simple string comparison. Ant itself is -platform independent and can therefore run on filesystems with slash (/, e.g. Linux) or backslash (\, -e.g. Windows) as path separator. Therefore we have to unify that. If we find our file, we create an absolute path -representation on //5, so that we can use that information without knowing the basedir. -(This is very important on use with multiple filesets, because they can have different basedirs and the -return value of the directory scanner is relative to its basedir.) Finally we store the location of the file -as property, if we had found one (//6).

      +

      On //1 we check the prerequisites for our task. Doing that in a validate() +method is a common way, because we separate the prerequisites from the real work. On //2 we iterate +over all nested filesets. If we don't want to handle multiple filesets, the addFileset() +method has to reject the further calls. We can get the result of a fileset via +its DirectoryScanner like done in //3. After that we create a platform +independent String representation of the file path (//4, can be done in other ways of course). We have +to do the replace(), because we work with a simple string comparison. Ant itself is platform +independent and can therefore run on filesystems with slash (/, e.g. Linux) or backslash (\, e.g. Windows) +as path separator. Therefore we have to unify that. If we find our file, we create an absolute path representation +on //5, so that we can use that information without knowing the basedir. (This is very +important on use with multiple filesets, because they can have different basedirs and the return value of the +directory scanner is relative to its basedir.) Finally we store the location of the file as property, if we +had found one (//6).

      Ok, much more easier in this simple case would be to add the file as additional include element to all filesets. But I wanted to show how to handle complex situations without being complex :-)

      The test case uses the Ant property ant.home as reference. This property is set by -the Launcher class which starts ant. We can use that property in our buildfiles as +the Launcher class which starts ant. We can use that property in our buildfiles as a build-in property [3]. But if we create a new Ant environment we have to set that value for our own. And we use the <junit> task in fork mode. Therefore we have do modify our buildfile:

      -
      +
           <target name="junit" description="Runs the unit tests" depends="jar">
               <delete dir="${junit.out.dir.xml}"/>
               <mkdir  dir="${junit.out.dir.xml}"/>
      @@ -327,24 +329,24 @@ modified to support paths instead of filesets. So we want that, too.

      Changing from fileset to path support is very easy:

      Change Java code from: -
      +
           private List<FileSet> filesets = new ArrayList<>();
           public void addFileset(FileSet fileset) {
               filesets.add(fileset);
           }
      to: -
      +
           private List<Path> paths = new ArrayList<>();             *1
           public void addPath(Path path) {                          *2
               paths.add(path);
           }
      and build file from: -
      +
           <find file="ant.jar" location="location.ant-jar">
               <fileset dir="${ant.home}" includes="**/*.jar"/>
           </find>
      to: -
      +
           <find file="ant.jar" location="location.ant-jar">
               <path>                                                *3
                   <fileset dir="${ant.home}" includes="**/*.jar"/>
      @@ -355,19 +357,20 @@ have to provide the right method: an addName(Type t).
       here. Finally we have to modify our buildfile on *3 because our task doesn't support nested filesets
       any longer. So we wrap the fileset inside a path.

      -

      And now we modify the test case. Oh, not very much to do :-) Renaming the testMissingFileset() (not -really a must-be but better it's named like the thing it does) and update the expected-String in -that method (now a path not set message is expected). The more complex test cases base on the build -script. So the targets testFileNotPresent and testFilePresent have to be modified in the manner -described above.

      +

      And now we modify the test case. Oh, not very much to do :-) Renaming +the testMissingFileset() (not really a must-be but better it's named like the thing +it does) and update the expected-String in that method (now a path not set message is +expected). The more complex test cases base on the build script. So the targets testFileNotPresent +and testFilePresent have to be modified in the manner described above.

      The test are finished. Now we have to adapt the task implementation. The easiest modification is in -the validate() method where we change the last line to if (paths.size()<1) throw new -BuildException("path not set");. In the execute() method we have a little more work. ... mmmh -... in reality it's less work, because the Path class does the whole DirectoryScanner-handling and -creating-absolute-paths stuff for us. So the execute method becomes just:

      +the validate() method where we change the last line to if +(paths.size()<1) throw new BuildException("path not set");. In the execute() method +we have a little more work. ... mmmh ... in reality it's less work, because the Path class +does the whole DirectoryScanner-handling and creating-absolute-paths stuff for us. So the +execute method becomes just:

      -
      +
           public void execute() {
               validate();
               String foundLocation = null;
      @@ -395,12 +398,12 @@ And would it be good to get all of them?—It depends ...

      In this section we will extend that task to support returning a list of all files. Lists as property values are not supported by Ant natively. So we have to see how other tasks use lists. The most famous task using lists is -Ant-Contribs <foreach>. All list elements are concatenated and separated with a customizable +Ant-Contrib's <foreach>. All list elements are concatenated and separated with a customizable separator (default ,).

      So we do the following:

      -
      <find ... delimiter=""/> ... </find>
      +
      <find ... delimiter=""/> ... </find>

      if the delimiter is set, we will return all found files as list with that delimiter.

      @@ -415,7 +418,7 @@ separator (default ,).

      So we add as test case:

      in the buildfile: -
      +
           <target name="test.init">
               <mkdir dir="test1/dir11/dir111"/>                             *1
               <mkdir dir="test1/dir11/dir112"/>
      @@ -446,7 +449,7 @@ separator (default ,).

      </delete> </target>
      in the test class: -
      +
           public void testMultipleFiles() {
               executeTarget("testMultipleFiles");
               String result = getProject().getProperty("location.test");
      @@ -461,7 +464,7 @@ reuse later (*3).
       
       

      The task implementation is modified as followed:

      -
      +
           private List<String> foundFiles = new ArrayList<>();
           ...
           private String delimiter = null;
      @@ -531,7 +534,7 @@ add a feature after an Ant release, provide a since Ant xx statement wh
       
       

      As a template we have:

      -
      +
       <html>
       
       <head>
      @@ -579,7 +582,7 @@ add a feature after an Ant release, provide a since Ant xx statement wh
       </html>

      Here is an example documentation page for our task:

      -
      +
       <html>
       
       <head>
      @@ -683,17 +686,18 @@ behaviour hasn't
       

      Package / Directories

      This task does not depend on any external library. Therefore we can use this as a core task. This task contains only one class. So we can use the standard package for core -tasks: org.apache.tools.ant.taskdefs. Implementations are in the directory src/main, tests -in src/testcases and buildfiles for tests in src/etc/testcases.

      +tasks: org.apache.tools.ant.taskdefs. Implementations are in the +directory src/main, tests in src/testcases and buildfiles for tests +in src/etc/testcases.

      Now we integrate our work into Ant distribution. So first we do an update of our Git tree. If not done yet, you should clone the Ant repository on GitHub[7], then create a local clone:

      -
      git clone https://github.com/your-sig/ant.git
      +
      git clone https://github.com/your-sig/ant.git

      Now we will build our Ant distribution and do a test. So we can see if there are any tests failing on our machine. (We can ignore these failing tests on later steps; Windows syntax used here—translate to UNIX if needed):

      -
      +
       ANTREPO> build                                                    // 1
       ANTREPO> set ANT_HOME=%CD%\dist                                   // 2
       ANTREPO> ant test -Dtest.haltonfailure=false                      // 3
      @@ -723,7 +727,7 @@ the beginning. The advantage: this step isn't necessary and saves a lot of work

      Now our modifications are done and we will retest it:

      -
      +
       ANTREPO> build
       ANTREPO> ant run-single-test                                      // 1
                    -Dtestcase=org.apache.tools.ant.taskdefs.FindTest    // 2
      @@ -734,12 +738,12 @@ not to halt on the first failure—we want to see all failures of our own te
       

      And ... oh, all tests fail: Ant could not find the task or a class this task relies upon.

      Ok: in the earlier steps we told Ant to use the Find class for the <find> task (remember -the <taskdef> statement in the "use.init" target). But now we want to introduce that task as a core -task. And nobody wants to taskdef the javac, echo, ... So what to do? The answer is -the src/main/.../taskdefs/default.properties. Here is the mapping between taskname and implementing class -done. So we add a find=org.apache.tools.ant.taskdefs.Find as the last core task (just before the # -optional tasks line). Now a second try:

      -
      +the <taskdef> statement in the use.init target). But now we want to introduce that task as a
      +core task. And nobody wants to taskdef the javac, echo, ... So what to do? The
      +answer is the src/main/.../taskdefs/default.properties. Here is the mapping between taskname and
      +implementing class done. So we add a find=org.apache.tools.ant.taskdefs.Find as the last core task (just
      +before the # optional tasks line). Now a second try:

      +
       ANTREPO> build                                                    // 1
       ANTREPO> ant run-single-test
                    -Dtestcase=org.apache.tools.ant.taskdefs.FindTest
      @@ -747,10 +751,10 @@ ANTREPO> ant run-single-test
       

      We have to rebuild (//1) Ant because the test look in the %ANT_HOME%\lib\ant.jar (more precise: on the classpath) for the properties file. And we have only modified it in the source path. So we have to rebuild that jar. But now all tests pass and we check whether our class breaks some other tests.

      -
      ANTREPO> ant test -Dtest.haltonfailure=false
      +
      ANTREPO> ant test -Dtest.haltonfailure=false

      Because there are a lot of tests this step requires a little bit of time. So use the run-single-test during development and do the test only at the end (maybe sometimes during development too). We use -the -Dtest.haltonfailure=false here because there could be other tests fail and we have to look into +the -Dtest.haltonfailure=false here because there could be other tests fail and we have to look into them.

      This test run should show us two things: our test will run and the number of failing tests is the same as directly @@ -767,7 +771,7 @@ from Clean the ANT_HOME variable, delete the build, bootstrap and dist directories, and point JAVA_HOME to the JDK 5 home directory. Then create the patch with your commit, checkout 1.9.x branch in Git, apply your patch and do the build, set ANT_HOME and -run ant test (like above).

      +run ant test (like above).

      Our test should pass.

      @@ -784,7 +788,7 @@ All jar's stored there are available to Ant so you haven't to add it to you since Ant 1.6).

      So we will run the tests with

      -
      ANTREPO> ant -f check.xml checkstyle htmlreport
      +
      ANTREPO> ant -f check.xml checkstyle htmlreport

      I prefer the HTML report because there are lots of messages and we can navigate faster. Open the ANTREPO/build/reports/checkstyle/html/index.html and navigate to the Find.java. Now we see that there are some errors: missing whitespaces, unused imports, missing javadocs. So we have to do that.

      diff --git a/manual/tutorial-writing-tasks.html b/manual/tutorial-writing-tasks.html index a1dee0288..c292f70ed 100644 --- a/manual/tutorial-writing-tasks.html +++ b/manual/tutorial-writing-tasks.html @@ -17,7 +17,7 @@ Tutorial: Writing Tasks - +

      Tutorial: Writing Tasks

      @@ -53,7 +53,7 @@ names build.xml. What should Ant do for us?

    13. clean up everything
    14. So the buildfile contains three targets. -
      +
       <?xml version="1.0" encoding="UTF-8"?>
       <project name="MyTask" basedir="." default="jar">
       
      @@ -77,7 +77,7 @@ rewrite that using <property>s. On second there are some hand
       requires that the destination directory exists; a call of clean with a non existing classes directory will
       fail; jar requires the execution of some steps before. So the refactored code is:
       
      -
      +
       <?xml version="1.0" encoding="UTF-8"?>
       <project name="MyTask" basedir="." default="jar">
       
      @@ -106,20 +106,20 @@ properties [1] of Ant.

      Now we write the simplest Task—a HelloWorld Task (what else?). Create a text file HelloWorld.java in the src-directory with:

      -
      +
       public class HelloWorld {
           public void execute() {
               System.out.println("Hello World");
           }
       }
      -

      and we can compile and jar it with ant (default target is jar and via its depends +

      and we can compile and jar it with ant (default target is jar and via its depends attribute the compile is executed before).

      Use the Task

      But after creating the jar we want to use our new Task. Therefore we need a new target use. Before we can use our new task we have to declare it with <taskdef> [2]. And for easier process we change the default attribute:

      -
      +
       <?xml version="1.0" encoding="UTF-8"?>
       <project name="MyTask" basedir="." default="use">
       
      @@ -135,7 +135,7 @@ our new task we have to declare it with 
       Buildfile: build.xml
       
      @@ -154,13 +154,14 @@ Total time: 3 seconds

      Integration with TaskAdapter

      Our class has nothing to do with Ant. It extends no superclass and implements no interface. How does Ant know to -integrate? Via name convention: our class provides a method with signature public void execute(). This -class is wrapped by Ant's org.apache.tools.ant.TaskAdapter which is a task and uses reflection for setting -a reference to the project and calling the execute() method.

      +integrate? Via name convention: our class provides a method with signature public void +execute(). This class is wrapped by Ant's org.apache.tools.ant.TaskAdapter which is a +task and uses reflection for setting a reference to the project and calling the execute() +method.

      Setting a reference to the project? Could be interesting. The Project class gives us some nice abilities: access to Ant's logging facilities getting and setting properties and much more. So we try to use that class:

      -
      +
       import org.apache.tools.ant.Project;
       
       public class HelloWorld {
      @@ -176,18 +177,18 @@ public class HelloWorld {
               project.log("Here is project '" + message + "'.", Project.MSG_INFO);
           }
       }
      -

      and the execution with ant will show us the expected

      +

      and the execution with ant will show us the expected

       use:
       Here is project 'MyTask'.

      Deriving from Ant's Task

      -

      Ok, that works ... But usually you will extend org.apache.tools.ant.Task. That class is integrated in -Ant, gets the project reference, provides documentation fields, provides easier access to the logging facility and (very -useful) gives you the exact location where in the buildfile this task instance is used.

      +

      Ok, that works ... But usually you will extend org.apache.tools.ant.Task. That class is +integrated in Ant, gets the project reference, provides documentation fields, provides easier access to the logging +facility and (very useful) gives you the exact location where in the buildfile this task instance is used.

      Oki-doki—let's us use some of these:

      -
      +
       import org.apache.tools.ant.Task;
       
       public class HelloWorld extends Task {
      @@ -209,23 +210,25 @@ use:
       [helloworld] I am used in: C:\tmp\anttests\MyFirstTask\build.xml:23:

      Accessing the Task's Project

      -

      The parent project of your custom task may be accessed through method getProject(). However, do not -call this from the custom task constructor, as the return value will be null. Later, when node attributes or text are -set, or method execute() is called, the Project object is available.

      +

      The parent project of your custom task may be accessed through method getProject(). +However, do not call this from the custom task constructor, as the return value will be null. Later, when node +attributes or text are set, or method execute() is called, the Project object is +available.

      Here are two useful methods from class Project:

        -
      • String getProperty(String propertyName)
      • -
      • String replaceProperties(String value)
      • +
      • String getProperty(String propertyName)
      • +
      • String replaceProperties(String value)
      -

      The method replaceProperties() is discussed further in section Nested Text.

      +

      The method replaceProperties() is discussed further in section Nested +Text.

      Attributes

      Now we want to specify the text of our message (it seems that we are rewriting the <echo/> task -:-). First we well do that with an attribute. It is very easy—for each attribute provide a public void -set<attributename>(<type> newValue) method and Ant will do the rest via -reflection.

      -
      +:-). First we well do that with an attribute.  It is very easy—for each attribute provide
      +a public void setAttributename(Type newValue) method and Ant will do the rest
      +via reflection.

      +
       import org.apache.tools.ant.Task;
       import org.apache.tools.ant.BuildException;
       
      @@ -244,14 +247,14 @@ public class HelloWorld extends Task {
           }
       
       }
      -

      Oh, what's that in execute()? Throw a BuildException? Yes, that's the usual way to show Ant -that something important is missed and complete build should fail. The string provided there is written as -build-fails-message. Here it's necessary because the log() method can't handle a null value as -parameter and throws a NullPointerException. (Of course you can initialize the message with a default -string.)

      +

      Oh, what's that in execute()? Throw a BuildException? Yes, that's the usual +way to show Ant that something important is missed and complete build should fail. The string provided there is written +as build-fails-message. Here it's necessary because the log() method can't handle +a null value as parameter and throws a NullPointerException. (Of course you can initialize +the message with a default string.)

      After that we have to modify our buildfile:

      -
      +
           <target name="use" description="Use the Task" depends="jar">
               <taskdef name="helloworld"
                        classname="HelloWorld"
      @@ -262,11 +265,12 @@ string.)

      Some background for working with attributes: Ant supports any of these datatypes as arguments of the set-method:

        -
      • primitive data types like int, long, ...
      • -
      • their wrapper classes like java.lang.Integer, java.lang.Long, ...
      • -
      • java.lang.String
      • -
      • some other classes (e.g. java.io.File; see Manual 'Writing Your Own -Task' [3])
      • +
      • primitive data types like int, long, ...
      • +
      • their wrapper classes like java.lang.Integer, java.lang.Long, +...
      • +
      • java.lang.String
      • +
      • some other classes (e.g. java.io.File; see Manual +'Writing Your Own Task' [3])
      • Any Java Object parsed from Ant 1.8's Property Helper
      @@ -275,8 +279,9 @@ would not set the message string to ${msg} if there is a property m

      Nested Text

      Maybe you have used the <echo> task in a way like <echo>Hello -World</echo>. For that you have to provide a public void addText(String text) method.

      -
      +World</echo>.  For that you have to provide a public void addText(String text)
      +method.

      +
       ...
       public class HelloWorld extends Task {
           private String message;
      @@ -287,10 +292,11 @@ public class HelloWorld extends Task {
           ...
       }

      But here properties are not resolved! For resolving properties we have to use -Project's replaceProperties(String propname) method which takes the property name as argument and returns -its value (or ${propname} if not set).

      -

      Thus, to replace properties in the nested node text, our method addText() can be written as:

      -
      +Project's replaceProperties(String propname) method which takes the property name as argument
      +and returns its value (or ${propname} if not set).

      +

      Thus, to replace properties in the nested node text, our method addText() can be written +as:

      +
           public void addText(String text) {
               message = getProject().replaceProperties(text);
           }
      @@ -301,12 +307,13 @@ the Manual [4] for other. We use the ways. There are several steps for that:

      1. We create a class for collecting all the info the nested element should contain. This class is created by the same -rules for attributes and nested elements as for the task (setattributename() methods).
      2. +rules for attributes and nested elements as for the task (setAttributename() +methods).
      3. The task holds multiple instances of this class in a list.
      4. A factory method instantiates an object, saves the reference in the list and returns it to Ant Core.
      5. -
      6. The execute() method iterates over the list and evaluates its values.
      7. +
      8. The execute() method iterates over the list and evaluates its values.
      -
      +
       import java.util.ArrayList;
       import java.util.List;
       ...
      @@ -335,9 +342,9 @@ import java.util.List;
           }
       ...

      Then we can use the new nested element. But where is XML-name for that defined? The mapping XML-name → -classname is defined in the factory method: public classname createXML-name(). Therefore we -write in the buildfile

      -
      +classname is defined in the factory method: public classname
      +createXML-name(). Therefore we write in the buildfile

      +
               <helloworld>
                   <message msg="Nested Element 1"/>
                   <message msg="Nested Element 2"/>
      @@ -347,7 +354,7 @@ as static

      Our task in a little more complex version

      For recapitulation now a little refactored buildfile:

      -
      +
       <?xml version="1.0" encoding="UTF-8"?>
       <project name="MyTask" basedir="." default="use">
       
      @@ -418,7 +425,7 @@ as static

      </project>

      And the code of the task:

      -
      +
       import org.apache.tools.ant.Task;
       import org.apache.tools.ant.BuildException;
       import java.util.ArrayList;
      @@ -438,7 +445,7 @@ public class HelloWorld extends Task {
               message = msg;
           }
       
      -    /** Should the build fail? Defaults to false. As attribute. */
      +    /** Should the build fail? Defaults to false. As attribute. */
           boolean fail = false;
           public void setFail(boolean b) {
               fail = b;
      @@ -542,10 +549,10 @@ C:\tmp\anttests\MyFirstTask>

      Test the Task

      We have written a test already: the use.* targets in the buildfile. But it's difficult to test that automatically. Commonly (and in Ant) JUnit is used for that. For testing tasks Ant provides a JUnit -Rule org.apache.tools.ant.BuildFileRule. This class provides some for testing tasks useful methods: -initialize Ant, load a buildfile, execute targets, capture debug and run logs ...

      +Rule org.apache.tools.ant.BuildFileRule. This class provides some for testing tasks useful +methods: initialize Ant, load a buildfile, execute targets, capture debug and run logs ...

      -

      In Ant it is usual that the testcase has the same name as the task with a prepending Test, therefore we +

      In Ant it is usual that the testcase has the same name as the task with a prepended Test, therefore we will create a file HelloWorldTest.java. Because we have a very small project we can put this file into src directory (Ant's own testclasses are in /src/testcases/...). Because we have already written our tests for "hand-test" we can use that for automatic tests, too. All test supporting classes are a part of @@ -554,7 +561,7 @@ jar file from source distro with target "test-jar".

      For executing the test and creating a report we need the optional tasks <junit> and <junitreport>. So we add to the buildfile:

      -
      +
       <project name="MyTask" basedir="." default="test">
       ...
           <property name="ant.test.lib" value="ant-testutil.jar"/>
      @@ -613,11 +620,12 @@ and <junitreport>. So we add to the buildfile:

      ... </project>
      -

      Back to the src/HelloWorldTest.java. We create a class with a public BuildFileRule field -annotated with JUnit's @Rule annotation. As per conventional JUnit4 tests, this class should have no -constructors, or a default no-args constructor, setup methods should be annotated with @Before, tear down -methods annotated with @After and any test method annotated with @Test. -

      +

      Back to the src/HelloWorldTest.java. We create a class with a +public BuildFileRule field annotated with JUnit's @Rule +annotation. As per conventional JUnit4 tests, this class should have no constructors, nor a default no-args constructor, +setup methods should be annotated with @Before, tear down methods annotated +with @After and any test method annotated with @Test. +

       import org.apache.tools.ant.BuildFileRule;
       import org.junit.Assert;
       import org.junit.Test;
      @@ -677,7 +685,7 @@ public class HelloWorldTest {
           }
       }
      -

      When starting ant we'll get a short message to STDOUT and a nice HTML report.

      +

      When starting ant we'll get a short message to STDOUT and a nice HTML report.

       C:\tmp\anttests\MyFirstTask>ant
       Buildfile: build.xml
      @@ -709,19 +717,20 @@ C:\tmp\anttests\MyFirstTask>

      Debugging

      -

      Try running Ant with the flag -verbose. For more information, try flag -debug.

      +

      Try running Ant with the flag -verbose. For more information, try flag -debug.

      For deeper issues, you may need to run the custom task code in a Java debugger. First, get the source for Ant and build it with debugging information.

      Since Ant is a large project, it can be a little tricky to set the right breakpoints. Here are two important breakpoints for version 1.8:

        -
      • Initial main() function: com.apache.tools.ant.launch.Launcher.main()
      • -
      • Task entry point: com.apache.tools.ant.UnknownElement.execute()
      • +
      • Initial main() + function: com.apache.tools.ant.launch.Launcher.main()
      • +
      • Task entry point: com.apache.tools.ant.UnknownElement.execute()
      -

      If you need to debug when a task attribute or the text is set, begin by debugging into method execute() -of your custom task. Then set breakpoints in other methods. This will ensure the class byte-code has been loaded by -JVM.

      +

      If you need to debug when a task attribute or the text is set, begin by debugging into +method execute() of your custom task. Then set breakpoints in other methods. This will +ensure the class bytecode has been loaded by JVM.

      Resources

      This tutorial and its resources are available via Tasks section below.)

      the default target to use when no target is supplied. No; however, since Ant 1.6.0, every project includes an implicit target that contains any and all top-level tasks and/or types. This target will always be executed as part of the project's initialization, even - when Ant is run with the -projecthelp option. + when Ant is run with the -projecthelp option.