ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1026358 - in /ant/core/trunk: CONTRIBUTORS contributors.xml docs/manual/tutorial-writing-tasks.html
Date Fri, 22 Oct 2010 15:05:14 GMT
Author: bodewig
Date: Fri Oct 22 15:05:13 2010
New Revision: 1026358

improvements to 'writing tasks' tutorial by Kevin Connor Arpe


Modified: ant/core/trunk/CONTRIBUTORS
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Fri Oct 22 15:05:13 2010
@@ -177,6 +177,7 @@ Julian Simpson
 Justin Vallon
 Keiron Liddle
 Keith Visco
+Kevin Connor Arpe
 Kevin Greiner
 Kevin Jackson
 Kevin Ross

Modified: ant/core/trunk/contributors.xml
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Fri Oct 22 15:05:13 2010
@@ -743,6 +743,11 @@
+    <middle>Connor</middle>
+    <last>Arpe</last>
+  </name>
+  <name>
+    <first>Kevin</first>

Modified: ant/core/trunk/docs/manual/tutorial-writing-tasks.html
--- ant/core/trunk/docs/manual/tutorial-writing-tasks.html (original)
+++ ant/core/trunk/docs/manual/tutorial-writing-tasks.html Fri Oct 22 15:05:13 2010
@@ -31,11 +31,13 @@ tasks.</p>
 <li><a href="#use1">Use the Task</a></li>
 <li><a href="#TaskAdapter">Integration with TaskAdapter</a></li>
 <li><a href="#derivingFromTask">Deriving from Ant's Task</a></li>
+<li><a href="#accessTaskProject">Accessing the Task's Project</a></li>
 <li><a href="#attributes">Attributes</a></li>
 <li><a href="#NestedText">Nested Text</a></li>
 <li><a href="#NestedElements">Nested Elements</a></li>
 <li><a href="#complex">Our task in a little more complex version</a></li>
 <li><a href="#TestingTasks">Test the Task</a></li>
+<li><a href="#Debugging">Debugging</a></li>
 <li><a href="#resources">Resources</a></li>
@@ -232,6 +234,18 @@ use:
 [helloworld] I am used in: C:\tmp\anttests\MyFirstTask\build.xml:23:
+<a name="accessTaskProject">
+<h2>Accessing the Task's Project</h2>
+<p>The parent project of your custom task may be accessed through method <code>getProject()</code>.
 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 <code>execute()</code>
is called, the Project object is available.</p>
+<p>Here are two useful methods from class Project:
+  <li><code>String getProperty(String propertyName)</code></li>
+  <li>
+    <code>String replaceProperties(String value)</code>
+  </li>
+<p>The method <code>replaceProperties()</code> is discussed further in
section <a href="#NestedText">Nested Text</a>.</p>
 <a name="attributes">
@@ -298,6 +312,7 @@ For that you have to provide a <tt>publi
 <pre class="code">
 public class HelloWorld extends Task {
+    private String message;
     public void addText(String text) {
         message = text;
@@ -308,6 +323,12 @@ public class HelloWorld extends Task {
 But here properties are <b>not</b> resolved! For resolving properties we have
to use
 Project's <tt>replaceProperties(String propname) : String</tt> method which takes
 property name as argument and returns its value (or ${propname} if not set).</p>
+<p>Thus, to replace properties in the nested node text, our method <code>addText()</code>
can be written as:</p>
+<pre class="code">
+    public void addText(String text) {
+        message = getProject().replaceProperties(text);
+    }
 <a name="NestedElements"></a>
@@ -735,6 +756,21 @@ C:\tmp\anttests\MyFirstTask&gt;
+<a name="Debugging"></a
+<p>Try running Ant with the flag <code>-verbose</code>.  For more information,
try flag <code>-debug</code>.</p>
+<p>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.</p>
+<p>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:
+  <li>Initial <code>main()</code> function: <code></code></li>
+  <li>Task entry point: <code></code></li>
+<p>If you need to debug when a task attribute or the text is set, begin by debugging
into method <code>execute()</code> of your custom task.  Then set breakpoints
in other methods.  This will ensure the class byte-code has been loaded by the Java VM.</p>
 <a name="resources"></a>
 <p>This tutorial and its resources are available via

View raw message