diff --git a/docs/manual/CoreTasks/changelog.html b/docs/manual/CoreTasks/changelog.html index b1b34ea33..09a24244c 100644 --- a/docs/manual/CoreTasks/changelog.html +++ b/docs/manual/CoreTasks/changelog.html @@ -213,9 +213,9 @@ how to generate a HTML report from the XML report.

<revision>1.3</revision> <prevrevision>1.2</prevrevision> </file> - <msg><![CDATA[Use URLs directly rather than go via a FIle. + <msg><![CDATA[Use URLs directly rather than go via a File. -This allows temp[lates to be stored inside jar]]></msg> +This allows templates to be stored inside jar]]></msg> </entry> </changelog> diff --git a/docs/manual/CoreTasks/chmod.html b/docs/manual/CoreTasks/chmod.html index 6c7778683..c5214ba03 100644 --- a/docs/manual/CoreTasks/chmod.html +++ b/docs/manual/CoreTasks/chmod.html @@ -147,8 +147,8 @@ permissions.

keeps non-owners from touching cgi scripts, files with a .old -extension or directories begining with private_. A directory -ending in .old or a file begining with private_ would remain +extension or directories beginning with private_. A directory +ending in .old or a file beginning with private_ would remain unaffected.


diff --git a/docs/manual/CoreTypes/filterchain.html b/docs/manual/CoreTypes/filterchain.html index 9a4910419..3093fd956 100644 --- a/docs/manual/CoreTypes/filterchain.html +++ b/docs/manual/CoreTypes/filterchain.html @@ -648,34 +648,34 @@ This graphic shows the dependencies: - +</filterchain> - +</filterchain> - +</filterchain> - + - +</filterchain>
 
<filterchain>
+     
<filterchain>
     <headfilter lines="2"/>
-</filterchain>
 
<filterchain>
+     
<filterchain>
     <tailfilter lines="-1" skip="2"/>
-</filterchain>
 
<filterchain>
+     
<filterchain>
     <headfilter lines="-1" skip="2"/>
-</filterchain>
 
<filterchain>
-    <headfilter lines="-1" skip="2"/>
-    <tailfilter lines="-1" skip="2"/>
-</filterchain>
<filterchain>
+    <headfilter lines="-1" skip="2"/>
+    <tailfilter lines="-1" skip="2"/>
+</filterchain>
 
<filterchain>
+     
<filterchain>
     <tailfilter lines="2"/>
-</filterchain>
diff --git a/docs/manual/CoreTypes/selectors-program.html b/docs/manual/CoreTypes/selectors-program.html index 15a225cb7..ecb1de51e 100755 --- a/docs/manual/CoreTypes/selectors-program.html +++ b/docs/manual/CoreTypes/selectors-program.html @@ -201,9 +201,9 @@ public class MySelectorTest extends BaseSelectorTest { As an example of an error JUnit could log
     [junit]     FAILED
     [junit] Error for files: .;copy.filterset.filtered;tar/gz/asf-logo.gif.tar.gz
-    [junit] expected:<FTTTFTTTF...> but was:<TTTTTTTTT...>
+    [junit] expected:<FTTTFTTTF...> but was:<TTTTTTTTT...>
     [junit] junit.framework.ComparisonFailure: Error for files: .;copy.filterset.filtered;tar/gz/asf-logo.gif.tar.gz
-    [junit] expected:<FTTTFTTTF...> but was:<TTTTTTTTT...>
+    [junit] expected:<FTTTFTTTF...> but was:<TTTTTTTTT...>
     [junit]     at junit.framework.Assert.assertEquals(Assert.java:81)
     [junit]     at org.apache.tools.ant.types.selectors.BaseSelectorTest.performTest(BaseSelectorTest.java:194)
     

diff --git a/docs/manual/CoreTypes/selectors.html b/docs/manual/CoreTypes/selectors.html index 42606df35..0bc1a366c 100755 --- a/docs/manual/CoreTypes/selectors.html +++ b/docs/manual/CoreTypes/selectors.html @@ -613,7 +613,7 @@
 <fileset dir="${src}">
-  <type type="dir"/>
+  <type type="dir"/>
 </fileset>
 
@@ -622,12 +622,12 @@ directory, but avoid selecting empty directories, use:
-<fileset dir="${src}">
-    <and>
-        <present targetdir="template"/>
-        <type type="file"/>
-    </and>
-</fileset>
+<fileset dir="${src}">
+    <and>
+        <present targetdir="template"/>
+        <type type="file"/>
+    </and>
+</fileset>
 
@@ -816,62 +816,62 @@

Here are some examples of how to use the Modified Selector:

-    <copy todir="dest">
-        <fileset dir="src">
-            <modified/>
-        </fileset>
-    </copy
+    <copy todir="dest">
+        <fileset dir="src">
+            <modified/>
+        </fileset>
+    </copy>
     

This will copy all files from src to dest which content has changed. Using an updating PropertyfileCache with cache.properties and MD5-DigestAlgorithm.

-    <copy todir="dest">
-        <fileset dir="src">
+    <copy todir="dest">
+        <fileset dir="src">
             <modified update="true"
                       seldirs="true"
                       cache="propertyfile"
                       algorithm="digest"
-                      comparator="equal">
-                <param name="cache.cachefile"     value="cache.properties"/>
-                <param name="algorithm.algorithm" value="MD5"/>
-            </modified>
-        </fileset>
-    </copy>
+                      comparator="equal">
+                <param name="cache.cachefile"     value="cache.properties"/>
+                <param name="algorithm.algorithm" value="MD5"/>
+            </modified>
+        </fileset>
+    </copy>
     

This is the same example rewritten as CoreSelector with setting the all the values (same as defaults are).

-    <copy todir="dest">
-        <fileset dir="src">
-            <custom class="org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector">
-                <param name="update"     value="true"/>
-                <param name="seldirs"    value="true"/>
-                <param name="cache"      value="propertyfile"/>
-                <param name="algorithm"  value="digest"/>
-                <param name="comparator" value="equal"/>
-                <param name="cache.cachefile"     value="cache.properties"/>
-                <param name="algorithm.algorithm" value="MD5"/>
-            </custom>
-        </fileset>
-    </copy>
+    <copy todir="dest">
+        <fileset dir="src">
+            <custom class="org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector">
+                <param name="update"     value="true"/>
+                <param name="seldirs"    value="true"/>
+                <param name="cache"      value="propertyfile"/>
+                <param name="algorithm"  value="digest"/>
+                <param name="comparator" value="equal"/>
+                <param name="cache.cachefile"     value="cache.properties"/>
+                <param name="algorithm.algorithm" value="MD5"/>
+            </custom>
+        </fileset>
+    </copy>
     

And this is the same rewritten as CustomSelector.

-  <target name="generate-and-upload-site">
-      <echo> generate the site using forrest </echo>
-      <antcall target="site"/>
-
-      <echo> upload the changed file </echo>
-      <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.pwd}">
-          <fileset dir="htdocs/manual">
-              <modified/>
-          </fileset>
-      </ftp>
-  </target>
+  <target name="generate-and-upload-site">
+      <echo> generate the site using forrest </echo>
+      <antcall target="site"/>
+
+      <echo> upload the changed file </echo>
+      <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.pwd}">
+          <fileset dir="htdocs/manual">
+              <modified/>
+          </fileset>
+      </ftp>
+  </target>
     

A useful scenario for this selector inside a build environment for homepage generation (e.g. with diff --git a/docs/manual/OptionalTasks/replaceregexp.html b/docs/manual/OptionalTasks/replaceregexp.html index a05a29f34..e60ace63e 100644 --- a/docs/manual/OptionalTasks/replaceregexp.html +++ b/docs/manual/OptionalTasks/replaceregexp.html @@ -123,7 +123,7 @@ line separator. So with input

-<html>    <body>
+<html>    <body>
 <<TAB>><h1>    T E S T   </h1>  <<TAB>>    
 <<TAB>> </body></html>
 
diff --git a/docs/manual/running.html b/docs/manual/running.html index 7016d5d5e..912bf6bcf 100644 --- a/docs/manual/running.html +++ b/docs/manual/running.html @@ -217,7 +217,7 @@ set):

So here 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, ant.file, diff --git a/docs/manual/tutorial-tasks-filesets-properties.html b/docs/manual/tutorial-tasks-filesets-properties.html index 7feb55bdf..f0cf6035b 100644 --- a/docs/manual/tutorial-tasks-filesets-properties.html +++ b/docs/manual/tutorial-tasks-filesets-properties.html @@ -41,16 +41,16 @@ location of that file in a property.

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="ISO-8859-1"?>
-<project name="FindTask" basedir="." default="test">
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="FindTask" basedir="." default="test">
     ...
-    <target name="use.init" description="Taskdef´ the Find-Task" depends="jar">
-        <taskdef name="find" classname="Find" classpath="${ant.project.name}.jar"/>
-    </target>
+    <target name="use.init" description="Taskdef´ the Find-Task" depends="jar">
+        <taskdef name="find" classname="Find" classpath="${ant.project.name}.jar"/>
+    </target>
 
     <!-- the other use.* targets are deleted -->
     ...
-</project>
+</project>
 

The buildfile is in the archive @@ -63,13 +63,13 @@ tutorial-tasks-filesets-properties.zip [2] in /build.xml.01-propertyacce

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"/>
+    <find property="test" value="test-value"/>
+    <find print="test"/>
 
ok, can be rewritten with the core tasks
-    <property name="test" value="test-value"/>
-    <echo message="${test}"/>
+    <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. @@ -117,7 +117,7 @@ name. Otherwise a message is logged.

(by the way: a short word to ants "namespaces" (don´t be confused with xml namespaces which will be also introduces in the future (1.6 or 1.7): -an <antcall> creates a new space for property names. All properties from the caller +an <antcall> creates a new space for property names. All properties from the caller are passed to the callee, but the callee can set its own properties without notice by the caller.)

@@ -158,9 +158,9 @@ their usage in buildfiles. Our goal is to search a file in path. And on this ste 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>
+    <find file="ant.jar" location="location.ant-jar">
+        <fileset dir="${ant.home}" includes="**/*.jar"/>
+    </find>
 

@@ -315,30 +315,30 @@ whithout being complex :-)

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}" />
-        <junit printsummary="yes" haltonfailure="no">
-            <classpath refid="classpath.test"/>
-            <sysproperty key="ant.home" value="${ant.home}"/>
-            <formatter type="xml"/>
-            <batchtest fork="yes" todir="${junit.out.dir.xml}">
-                <fileset dir="${src.dir}" includes="**/*Test.java"/>
-            </batchtest>
-        </junit>
-    </target>
+    <target name="junit" description="Runs the unit tests" depends="jar">
+        <delete dir="${junit.out.dir.xml}"/>
+        <mkdir  dir="${junit.out.dir.xml}"/>
+        <junit printsummary="yes" haltonfailure="no">
+            <classpath refid="classpath.test"/>
+            <sysproperty key="ant.home" value="${ant.home}"/>
+            <formatter type="xml"/>
+            <batchtest fork="yes" todir="${junit.out.dir.xml}">
+                <fileset dir="${src.dir}" includes="**/*Test.java"/>
+            </batchtest>
+        </junit>
+    </target>
 

Using nested paths

A task providing support for filesets is a very comfortable one. But there is another -possibility of bundling files: the <path>. Fileset are easy if the files are all under +possibility of bundling files: the <path>. Fileset are easy if the files are all under a common base directory. But if this is not the case you have a problem. Another disadvantage is its speed: if you have only a few files in a huge directory structure, why not use a -<filelist> instead? <path>s combines these datatypes in that way that a path contains +<filelist> instead? <path>s combines these datatypes in that way that a path contains other paths, filesets, dirsets and filelists. This is why -Ant-Contribs [4] <foreach> task is modified to support paths instead of filesets. So we want that, +Ant-Contribs [4] <foreach> task is modified to support paths instead of filesets. So we want that, too.

Changing from fileset to path support is very easy:

@@ -354,15 +354,15 @@ too.

paths.add(path); } and build file from: - <find file="ant.jar" location="location.ant-jar"> - <fileset dir="${ant.home}" includes="**/*.jar"/> - </find> + <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"/> - </path> - </find> + <find file="ant.jar" location="location.ant-jar"> + <path> *3 + <fileset dir="${ant.home}" includes="**/*.jar"/> + </path> + </find>

On *1 we rename only the vector. It´s just for better reading the source. On *2 we have to provide the right method: an addName(Type t). Therefore replace the @@ -414,13 +414,13 @@ And would it be good to get all of them? - It depends on ...

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 +tasks use lists. The most famous task using lists is Ant-Contribs <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.

@@ -436,35 +436,35 @@ elements are concatenated and separated with a customizable separator (default '

So we add as testcase:

 in the buildfile:
-    <target name="test.init">
-        <mkdir dir="test1/dir11/dir111"/>                             *1
-        <mkdir dir="test1/dir11/dir112"/>
+    <target name="test.init">
+        <mkdir dir="test1/dir11/dir111"/>                             *1
+        <mkdir dir="test1/dir11/dir112"/>
         ...
-        <touch file="test1/dir11/dir111/test"/>
-        <touch file="test1/dir11/dir111/not"/>
+        <touch file="test1/dir11/dir111/test"/>
+        <touch file="test1/dir11/dir111/not"/>
         ...
-        <touch file="test1/dir13/dir131/not2"/>
-        <touch file="test1/dir13/dir132/test"/>
-        <touch file="test1/dir13/dir132/not"/>
-        <touch file="test1/dir13/dir132/not2"/>
-        <mkdir dir="test2"/>
-        <copy todir="test2">                                          *2
-            <fileset dir="test1"/>
-        </copy>
-    </target>
-
-    <target name="testMultipleFiles" depends="use.init,test.init">    *3
-        <find file="test" location="location.test" delimiter=";">
-            <path>
-                <fileset dir="test1"/>
-                <fileset dir="test2"/>
-            </path>
-        </find>
-        <delete>                                                      *4
-            <fileset dir="test1"/>
-            <fileset dir="test2"/>
-        </delete>
-    </target>
+        <touch file="test1/dir13/dir131/not2"/>
+        <touch file="test1/dir13/dir132/test"/>
+        <touch file="test1/dir13/dir132/not"/>
+        <touch file="test1/dir13/dir132/not2"/>
+        <mkdir dir="test2"/>
+        <copy todir="test2">                                          *2
+            <fileset dir="test1"/>
+        </copy>
+    </target>
+
+    <target name="testMultipleFiles" depends="use.init,test.init">    *3
+        <find file="test" location="location.test" delimiter=";">
+            <path>
+                <fileset dir="test1"/>
+                <fileset dir="test2"/>
+            </path>
+        </find>
+        <delete>                                                      *4
+            <fileset dir="test1"/>
+            <fileset dir="test2"/>
+        </delete>
+    </target>
 
 in the test class:
     public void testMultipleFiles() {
@@ -563,123 +563,123 @@ important :-) examples
 As a template we have:
 
 
-<html>
+<html>
 
-<head>
-<meta http-equiv="Content-Language" content="en-us">
-<title> Taskname Task</title>
-</head>
+<head>
+<meta http-equiv="Content-Language" content="en-us">
+<title> Taskname Task</title>
+</head>
 
-<body>
+<body>
 
-<h2><a name="taskname">Taskname</a></h2>
-<h3>Description</h3>
-<p> Describe the task.</p>
+<h2><a name="taskname">Taskname</a></h2>
+<h3>Description</h3>
+<p> Describe the task.</p>
 
-<h3>Parameters</h3>
-<table border="1" cellpadding="2" cellspacing="0">
-  <tr>
-    <td valign="top"><b>Attribute</b></td>
-    <td valign="top"><b>Description</b></td>
-    <td align="center" valign="top"><b>Required</b></td>
-  </tr>
+<h3>Parameters</h3>
+<table border="1" cellpadding="2" cellspacing="0">
+  <tr>
+    <td valign="top"><b>Attribute</b></td>
+    <td valign="top"><b>Description</b></td>
+    <td align="center" valign="top"><b>Required</b></td>
+  </tr>
 
   do this html row for each attribute (including inherited attributes)
-  <tr>
-    <td valign="top">classname</td>
-    <td valign="top">the Java class to execute.</td>
-    <td align="center" valign="top">Either jar or classname</td>
-  </tr>
+  <tr>
+    <td valign="top">classname</td>
+    <td valign="top">the Java class to execute.</td>
+    <td align="center" valign="top">Either jar or classname</td>
+  </tr>
 
-</table>
+</table>
 
-<h3>Parameters specified as nested elements</h3>
+<h3>Parameters specified as nested elements</h3>
 
 Describe each nested element (including inherited)
-<h4>your nested element</h4>
-<p> description </p>
-<p><em>since Ant 1.6</em>.</p>
+<h4>your nested element</h4>
+<p> description </p>
+<p><em>since Ant 1.6</em>.</p>
 
-<h3>Examples</h3>
-<pre>
+<h3>Examples</h3>
+<pre>
     A code sample; don´t forget to escape the < of the tags with &lt;
-</pre>
+</pre>
 what should that example do?
 
-</body>
-</html>
+</body>
+</html>
 

For our task we have that [6]:

-<html>
-
-<head>
-<meta http-equiv="Content-Language" content="en-us">
-<title> Find Task</title>
-</head>
-
-<body>
-
-<h2><a name="find">Find</a></h2>
-<h3>Description</h3>
-<p>Searchs in a given path for a file and returns the absolute to it as property.
-If delimiter is set this task returns all found locations.</p>
-
-<h3>Parameters</h3>
-<table border="1" cellpadding="2" cellspacing="0">
-  <tr>
-    <td valign="top"><b>Attribute</b></td>
-    <td valign="top"><b>Description</b></td>
-    <td align="center" valign="top"><b>Required</b></td>
-  </tr>
-  <tr>
-    <td valign="top">file</td>
-    <td valign="top">The name of the file to search.</td>
-    <td align="center" valign="top">yes</td>
-  </tr>
-  <tr>
-    <td valign="top">location</td>
-    <td valign="top">The name of the property where to store the location</td>
-    <td align="center" valign="top">yes</td>
-  </tr>
-  <tr>
-    <td valign="top">delimiter</td>
-    <td valign="top">A delimiter to use when returning the list</td>
-    <td align="center" valign="top">only if the list is required</td>
-  </tr>
-</table>
-
-<h3>Parameters specified as nested elements</h3>
-
-<h4>path</h4>
-<p>The path where to search the file.</p>
-
-<h3>Examples</h3>
-<pre>
-    <find file="ant.jar" location="loc">
-        <path>
-            <fileset dir="${ant.home}"/>
-        <path>
-    </find>
-</pre>
-Searches in Ants home directory for a file <i>ant.jar</i> and stores its location in
-property <i>loc</i> (should be ANT_HOME/bin/ant.jar).
-
-<pre>
-    <find file="ant.jar" location="loc" delimiter=";">
-        <path>
-            <fileset dir="C:/"/>
-        <path>
-    </find>
-    <echo>ant.jar found in: ${loc}</echo>
-</pre>
-Searches in Windows C: drive for all <i>ant.jar</i> and stores their locations in
-property <i>loc</i> delimited with <i>';'</i>. (should need a long time :-)
+<html>
+
+<head>
+<meta http-equiv="Content-Language" content="en-us">
+<title> Find Task</title>
+</head>
+
+<body>
+
+<h2><a name="find">Find</a></h2>
+<h3>Description</h3>
+<p>Searchs in a given path for a file and returns the absolute to it as property.
+If delimiter is set this task returns all found locations.</p>
+
+<h3>Parameters</h3>
+<table border="1" cellpadding="2" cellspacing="0">
+  <tr>
+    <td valign="top"><b>Attribute</b></td>
+    <td valign="top"><b>Description</b></td>
+    <td align="center" valign="top"><b>Required</b></td>
+  </tr>
+  <tr>
+    <td valign="top">file</td>
+    <td valign="top">The name of the file to search.</td>
+    <td align="center" valign="top">yes</td>
+  </tr>
+  <tr>
+    <td valign="top">location</td>
+    <td valign="top">The name of the property where to store the location</td>
+    <td align="center" valign="top">yes</td>
+  </tr>
+  <tr>
+    <td valign="top">delimiter</td>
+    <td valign="top">A delimiter to use when returning the list</td>
+    <td align="center" valign="top">only if the list is required</td>
+  </tr>
+</table>
+
+<h3>Parameters specified as nested elements</h3>
+
+<h4>path</h4>
+<p>The path where to search the file.</p>
+
+<h3>Examples</h3>
+<pre>
+    <find file="ant.jar" location="loc">
+        <path>
+            <fileset dir="${ant.home}"/>
+        <path>
+    </find>
+</pre>
+Searches in Ants home directory for a file <i>ant.jar</i> and stores its location in
+property <i>loc</i> (should be ANT_HOME/bin/ant.jar).
+
+<pre>
+    <find file="ant.jar" location="loc" delimiter=";">
+        <path>
+            <fileset dir="C:/"/>
+        <path>
+    </find>
+    <echo>ant.jar found in: ${loc}</echo>
+</pre>
+Searches in Windows C: drive for all <i>ant.jar</i> and stores their locations in
+property <i>loc</i> delimited with <i>';'</i>. (should need a long time :-)
 After that it prints out the result (e.g. C:/ant-1.5.4/bin/ant.jar;C:/ant-1.6/bin/ant.jar).
 
-</body>
-</html>
+</body>
+</html>
 
@@ -755,9 +755,9 @@ on //4.

are any tests failing on our machine. (We can ignore these failing tests on later steps; windows syntax used here- translate to xNIX if needed):
-ANTHOME> build                                                    // 1
-ANTHOME> set ANT_HOME=%CD%\dist                                   // 2
-ANTHOME> ant test -Dtest.haltonfailure=false                      // 3
+ANTHOME> build                                                    // 1
+ANTHOME> set ANT_HOME=%CD%\dist                                   // 2
+ANTHOME> ant test -Dtest.haltonfailure=false                      // 3
 
First we have to build our Ant distribution (//1). On //2 we set the ANT_HOME @@ -782,14 +782,14 @@ necessary and saves a lot of work if you modify existing source :-)
.
  • in FindTest.java change the line configureProject("build.xml"); to configureProject("src/etc/testcases/taskdefs/find.xml");
  • move the find.html to ANTHOME/docs/manual/CoreTasks/find.html
  • -
  • add a <a href="CoreTasks/find.html">Find</a><br> +
  • add a <a href="CoreTasks/find.html">Find</a><br> in the ANTHOME/docs/manual/coretasklist.html
  • Now our modifications are done and we will retest it:
    -ANTHOME> build
    -ANTHOME> ant run-single-test                                      // 1
    +ANTHOME> build
    +ANTHOME> ant run-single-test                                      // 1
                  -Dtestcase=org.apache.tools.ant.taskdefs.FindTest    // 2
                  -Dtest.haltonfailure=false
     
    @@ -799,15 +799,15 @@ failures of our own test (//1 + 2).

    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 +

    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:

    -ANTHOME> build                                                    // 1
    -ANTHOME> ant run-single-test
    +ANTHOME> build                                                    // 1
    +ANTHOME> ant run-single-test
                  -Dtestcase=org.apache.tools.ant.taskdefs.FindTest
                  -Dtest.haltonfailure=false
     
    @@ -816,7 +816,7 @@ We have to rebuild (//1) Ant because the test look in the %ANT_HOME%\lib\ source path. So we have to rebuild that jar. But now all tests pass and we check whether our class breaks some other tests.
    -ANTHOME> ant test -Dtest.haltonfailure=false
    +ANTHOME> 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). @@ -863,7 +863,7 @@ directory (this feature was added with Ant 1.6).

    So we will run the tests with

    -ANTHOME> ant -f check.xml checkstyle htmlreport
    +ANTHOME> ant -f check.xml checkstyle htmlreport
     
    I prefer the HTML report because there are lots of messages and we can navigate faster. Open the ANTHOME/build/reports/checkstyle/html/index.html and navigate to the Find.java. Now we @@ -900,7 +900,7 @@ entry. For both we need some information:

    body more details about the path - This new task looks inside a nested <path/> for occurrences of a file and stores + This new task looks inside a nested <path/> for occurrences of a file and stores all locations as a property. See the included manual for details. diff --git a/docs/manual/tutorial-writing-tasks.html b/docs/manual/tutorial-writing-tasks.html index a5e3c4cd7..2495d57e0 100644 --- a/docs/manual/tutorial-writing-tasks.html +++ b/docs/manual/tutorial-writing-tasks.html @@ -44,52 +44,52 @@ create a text file names build.xml. What should Ant do for us? So the buildfile contains three targets.
    -<?xml version="1.0" encoding="ISO-8859-1"?>
    -<project name="MyTask" basedir="." default="jar">
    +<?xml version="1.0" encoding="ISO-8859-1"?>
    +<project name="MyTask" basedir="." default="jar">
     
    -    <target name="clean" description="Delete all generated files">
    -        <delete dir="classes"/>
    -        <delete file="MyTasks.jar"/>
    -    </target>
    +    <target name="clean" description="Delete all generated files">
    +        <delete dir="classes"/>
    +        <delete file="MyTasks.jar"/>
    +    </target>
     
    -    <target name="compile" description="Compiles the Task">
    -        <javac srcdir="src" destdir="classes"/>
    -    </target>
    +    <target name="compile" description="Compiles the Task">
    +        <javac srcdir="src" destdir="classes"/>
    +    </target>
     
    -    <target name="jar" description="JARs the Task">
    -        <jar destfile="MyTask.jar" basedir="classes"/>
    -    </target>
    +    <target name="jar" description="JARs the Task">
    +        <jar destfile="MyTask.jar" basedir="classes"/>
    +    </target>
     
    -</project>
    +</project>
     
    This buildfile uses often the same value (src, classes, MyTask.jar), so we should rewrite that -using <property>s. On second there are some handicaps: <javac> requires that the destination +using <property>s. On second there are some handicaps: <javac> 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 bofore. So the refactored code is:
    -<?xml version="1.0" encoding="ISO-8859-1"?>
    -<project name="MyTask" basedir="." default="jar">
    +<?xml version="1.0" encoding="ISO-8859-1"?>
    +<project name="MyTask" basedir="." default="jar">
     
    -    <property name="src.dir" value="src"/>
    -    <property name="classes.dir" value="classes"/>
    +    <property name="src.dir" value="src"/>
    +    <property name="classes.dir" value="classes"/>
     
    -    <target name="clean" description="Delete all generated files">
    -        <delete dir="${classes.dir}" failonerror="false"/>
    -        <delete file="${ant.project.name}.jar"/>
    -    </target>
    +    <target name="clean" description="Delete all generated files">
    +        <delete dir="${classes.dir}" failonerror="false"/>
    +        <delete file="${ant.project.name}.jar"/>
    +    </target>
     
    -    <target name="compile" description="Compiles the Task">
    -        <mkdir dir="${classes.dir}"/>
    -        <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
    -    </target>
    +    <target name="compile" description="Compiles the Task">
    +        <mkdir dir="${classes.dir}"/>
    +        <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
    +    </target>
     
    -    <target name="jar" description="JARs the Task" depends="compile">
    -        <jar destfile="${ant.project.name}.jar" basedir="${classes.dir}"/>
    -    </target>
    +    <target name="jar" description="JARs the Task" depends="compile">
    +        <jar destfile="${ant.project.name}.jar" basedir="${classes.dir}"/>
    +    </target>
     
    -</project>
    +</project>
     
    ant.project.name is one of the @@ -118,19 +118,19 @@ its depends-clause the "compile" is executed before).

    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 clause: +<taskdef> [2]. And for easier process we change the default clause:

    -<?xml version="1.0" encoding="ISO-8859-1"?>
    -<project name="MyTask" basedir="." default="use">
    +<?xml version="1.0" encoding="ISO-8859-1"?>
    +<project name="MyTask" basedir="." default="use">
     
         ...
     
    -    <target name="use" description="Use the Task" depends="jar">
    -        <taskdef name="helloworld" classname="HelloWorld" classpath="${ant.project.name}.jar"/>
    -        <helloworld/>
    -    </target>
    +    <target name="use" description="Use the Task" depends="jar">
    +        <taskdef name="helloworld" classname="HelloWorld" classpath="${ant.project.name}.jar"/>
    +        <helloworld/>
    +    </target>
     
    -</project>
    +</project>
     
    Important is the classpath-attribute. Ant searches in its /lib directory for @@ -226,8 +226,8 @@ use:

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

     import org.apache.tools.ant.Task;
    @@ -257,12 +257,12 @@ the log() method can't handle a null value as parameter and throws a Null
     
     

    After that we have to modify our buildfile:

    -    <target name="use" description="Use the Task" depends="jar">
    +    <target name="use" description="Use the Task" depends="jar">
             <taskdef name="helloworld"
                      classname="HelloWorld"
    -                 classpath="${ant.project.name}.jar"/>
    -        <helloworld message="Hello World"/>
    -    </target>
    +                 classpath="${ant.project.name}.jar"/>
    +        <helloworld message="Hello World"/>
    +    </target>
     
    That's all.

    @@ -275,13 +275,13 @@ arguments of the set-method:
    -Before calling the set-method all properties are resolved. So a <helloworld message="${msg}"/> +Before calling the set-method all properties are resolved. So a <helloworld message="${msg}"/> would not set the message string to "${msg}" if there is a property "msg" with a set value.

    Nested Text

    -

    Maybe you have used the <echo> task in a way like <echo>Hello World</echo>. +

    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.

     ...
    @@ -305,7 +305,7 @@ the Manual [
     We use the first way of the three described ways. There are several steps for that:
    1. We create a class for collecting all the infos the nested element should contain. This class is created by the same rules for attributes and nested elements - as for the task (set<attributename>() methods).
    2. + as for the task (set<attributename>() 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. @@ -346,10 +346,10 @@ The mapping XML-name : 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"/>
      -        </helloworld>
      +        <helloworld>
      +            <message msg="Nested Element 1"/>
      +            <message msg="Nested Element 2"/>
      +        </helloworld>
       
      @@ -357,76 +357,76 @@ the buildfile

      Our task in a little more complex version

      For recapitulation now a little refactored buildfile:

      -<?xml version="1.0" encoding="ISO-8859-1"?>
      -<project name="MyTask" basedir="." default="use">
      +<?xml version="1.0" encoding="ISO-8859-1"?>
      +<project name="MyTask" basedir="." default="use">
       
      -    <property name="src.dir" value="src"/>
      -    <property name="classes.dir" value="classes"/>
      +    <property name="src.dir" value="src"/>
      +    <property name="classes.dir" value="classes"/>
       
      -    <target name="clean" description="Delete all generated files">
      -        <delete dir="${classes.dir}" failonerror="false"/>
      -        <delete file="${ant.project.name}.jar"/>
      -    </target>
      +    <target name="clean" description="Delete all generated files">
      +        <delete dir="${classes.dir}" failonerror="false"/>
      +        <delete file="${ant.project.name}.jar"/>
      +    </target>
       
      -    <target name="compile" description="Compiles the Task">
      -        <mkdir dir="${classes.dir}"/>
      -        <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
      -    </target>
      +    <target name="compile" description="Compiles the Task">
      +        <mkdir dir="${classes.dir}"/>
      +        <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
      +    </target>
       
      -    <target name="jar" description="JARs the Task" depends="compile">
      -        <jar destfile="${ant.project.name}.jar" basedir="${classes.dir}"/>
      -    </target>
      +    <target name="jar" description="JARs the Task" depends="compile">
      +        <jar destfile="${ant.project.name}.jar" basedir="${classes.dir}"/>
      +    </target>
       
       
           <target name="use.init"
                   description="Taskdef the HelloWorld-Task"
      -            depends="jar">
      +            depends="jar">
               <taskdef name="helloworld"
                        classname="HelloWorld"
      -                 classpath="${ant.project.name}.jar"/>
      -    </target>
      +                 classpath="${ant.project.name}.jar"/>
      +    </target>
       
       
           <target name="use.without"
                   description="Use without any"
      -            depends="use.init">
      -        <helloworld/>
      -    </target>
      +            depends="use.init">
      +        <helloworld/>
      +    </target>
       
           <target name="use.message"
                   description="Use with attribute 'message'"
      -            depends="use.init">
      -        <helloworld message="attribute-text"/>
      -    </target>
      +            depends="use.init">
      +        <helloworld message="attribute-text"/>
      +    </target>
       
           <target name="use.fail"
                   description="Use with attribute 'fail'"
      -            depends="use.init">
      -        <helloworld fail="true"/>
      -    </target>
      +            depends="use.init">
      +        <helloworld fail="true"/>
      +    </target>
       
           <target name="use.nestedText"
                   description="Use with nested text"
      -            depends="use.init">
      -        <helloworld>nested-text</helloworld>
      -    </target>
      +            depends="use.init">
      +        <helloworld>nested-text</helloworld>
      +    </target>
       
           <target name="use.nestedElement"
                   description="Use with nested 'message'"
      -            depends="use.init">
      -        <helloworld>
      -            <message msg="Nested Element 1"/>
      -            <message msg="Nested Element 2"/>
      -        </helloworld>
      -    </target>
      +            depends="use.init">
      +        <helloworld>
      +            <message msg="Nested Element 1"/>
      +            <message msg="Nested Element 2"/>
      +        </helloworld>
      +    </target>
       
       
           <target name="use"
                   description="Try all (w/out use.fail)"
                   depends="use.without,use.message,use.nestedText,use.nestedElement"
      -    />
      +    />
       
      -</project>
      +</project>
       
      And the code of the task: @@ -505,7 +505,7 @@ public class HelloWorld extends Task { And it works:
      -C:\tmp\anttests\MyFirstTask>ant
      +C:\tmp\anttests\MyFirstTask>ant
       Buildfile: build.xml
       
       compile:
      @@ -537,7 +537,7 @@ use:
       
       BUILD SUCCESSFUL
       Total time: 3 seconds
      -C:\tmp\anttests\MyFirstTask>ant use.fail
      +C:\tmp\anttests\MyFirstTask>ant use.fail
       Buildfile: build.xml
       
       compile:
      @@ -552,7 +552,7 @@ BUILD FAILED
       C:\tmp\anttests\MyFirstTask\build.xml:36: Fail requested.
       
       Total time: 1 second
      -C:\tmp\anttests\MyFirstTask>
      +C:\tmp\anttests\MyFirstTask>
       
      Next step: test ... @@ -580,66 +580,66 @@ target "test-jar" or you can download a nightly build from
      http://gump.covalent.net/jars/latest/ant/ant-testutil.jar [5].

      -

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

      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"/>
      -    <property name="report.dir"   value="report"/>
      -    <property name="junit.out.dir.xml"  value="${report.dir}/junit/xml"/>
      -    <property name="junit.out.dir.html" value="${report.dir}/junit/html"/>
      -
      -    <path id="classpath.run">
      -        <path path="${java.class.path}"/>
      -        <path location="${ant.project.name}.jar"/>
      -    </path>
      -
      -    <path id="classpath.test">
      -        <path refid="classpath.run"/>
      -        <path location="${ant.test.lib}"/>
      -    </path>
      -
      -    <target name="clean" description="Delete all generated files">
      -        <delete failonerror="false" includeEmptyDirs="true">
      -            <fileset dir="." includes="${ant.project.name}.jar"/>
      -            <fileset dir="${classes.dir}"/>
      -            <fileset dir="${report.dir}"/>
      -        </delete>
      -    </target>
      -
      -    <target name="compile" description="Compiles the Task">
      -        <mkdir dir="${classes.dir}"/>
      -        <javac srcdir="${src.dir}" destdir="${classes.dir}" classpath="${ant.test.lib}"/>
      -    </target>
      +    <property name="ant.test.lib" value="ant-testutil.jar"/>
      +    <property name="report.dir"   value="report"/>
      +    <property name="junit.out.dir.xml"  value="${report.dir}/junit/xml"/>
      +    <property name="junit.out.dir.html" value="${report.dir}/junit/html"/>
      +
      +    <path id="classpath.run">
      +        <path path="${java.class.path}"/>
      +        <path location="${ant.project.name}.jar"/>
      +    </path>
      +
      +    <path id="classpath.test">
      +        <path refid="classpath.run"/>
      +        <path location="${ant.test.lib}"/>
      +    </path>
      +
      +    <target name="clean" description="Delete all generated files">
      +        <delete failonerror="false" includeEmptyDirs="true">
      +            <fileset dir="." includes="${ant.project.name}.jar"/>
      +            <fileset dir="${classes.dir}"/>
      +            <fileset dir="${report.dir}"/>
      +        </delete>
      +    </target>
      +
      +    <target name="compile" description="Compiles the Task">
      +        <mkdir dir="${classes.dir}"/>
      +        <javac srcdir="${src.dir}" destdir="${classes.dir}" classpath="${ant.test.lib}"/>
      +    </target>
       ...
      -    <target name="junit" description="Runs the unit tests" depends="jar">
      -        <delete dir="${junit.out.dir.xml}" />
      -        <mkdir  dir="${junit.out.dir.xml}" />
      -        <junit printsummary="yes" haltonfailure="no">
      -            <classpath refid="classpath.test"/>
      -            <formatter type="xml"/>
      -            <batchtest fork="yes" todir="${junit.out.dir.xml}">
      -                <fileset dir="${src.dir}" includes="**/*Test.java"/>
      -            </batchtest>
      -        </junit>
      -    </target>
      -
      -    <target name="junitreport" description="Create a report for the rest result">
      -        <mkdir dir="${junit.out.dir.html}" />
      -        <junitreport todir="${junit.out.dir.html}">
      -            <fileset dir="${junit.out.dir.xml}">
      -                <include name="*.xml"/>
      -            </fileset>
      -            <report format="frames" todir="${junit.out.dir.html}"/>
      -        </junitreport>
      -    </target>
      +    <target name="junit" description="Runs the unit tests" depends="jar">
      +        <delete dir="${junit.out.dir.xml}"/>
      +        <mkdir  dir="${junit.out.dir.xml}"/>
      +        <junit printsummary="yes" haltonfailure="no">
      +            <classpath refid="classpath.test"/>
      +            <formatter type="xml"/>
      +            <batchtest fork="yes" todir="${junit.out.dir.xml}">
      +                <fileset dir="${src.dir}" includes="**/*Test.java"/>
      +            </batchtest>
      +        </junit>
      +    </target>
      +
      +    <target name="junitreport" description="Create a report for the rest result">
      +        <mkdir dir="${junit.out.dir.html}"/>
      +        <junitreport todir="${junit.out.dir.html}">
      +            <fileset dir="${junit.out.dir.xml}">
      +                <include name="*.xml"/>
      +            </fileset>
      +            <report format="frames" todir="${junit.out.dir.html}"/>
      +        </junitreport>
      +    </target>
       
           <target name="test"
                   depends="junit,junitreport"
                   description="Runs unit tests and creates a report"
      -    />
      +    />
       ...
       

      @@ -693,7 +693,7 @@ public class HelloWorldTest extends BuildFileTest {

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

      -C:\tmp\anttests\MyFirstTask>ant
      +C:\tmp\anttests\MyFirstTask>ant
       Buildfile: build.xml
       
       compile:
      @@ -719,7 +719,7 @@ test:
       
       BUILD SUCCESSFUL
       Total time: 7 seconds
      -C:\tmp\anttests\MyFirstTask>
      +C:\tmp\anttests\MyFirstTask>