Browse Source

Add some error checking to new TSTAMP format element

Documentation fro tstamp and javac changes


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268397 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
e92741fae9
3 changed files with 65 additions and 0 deletions
  1. +10
    -0
      WHATSNEW
  2. +47
    -0
      docs/index.html
  3. +8
    -0
      src/main/org/apache/tools/ant/taskdefs/Tstamp.java

+ 10
- 0
WHATSNEW View File

@@ -45,6 +45,16 @@ Other changes:
of the source files are no longer required to be at the end of the of the source files are no longer required to be at the end of the
command. command.


* Ant now prints a warning when an attempt is made to use a property which has
not been set. Any build files which rely on non-set properties being passed
through untranslated will now break.
* Added a failonerror to the javac task. If set to false, the build will continue
even if there are compilation errors.
* Added nested format elements to the tstamp task allowing additional time formats
to be defined for arbitrary properties.

Fixed bugs: Fixed bugs:
----------- -----------




+ 47
- 0
docs/index.html View File

@@ -3099,6 +3099,13 @@ inclusion/exclusion of files works, and how to write patterns.</p>
tracking for compilers that support this (jikes and classic)</td> tracking for compilers that support this (jikes and classic)</td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">failonerror</td> <td valign="top">
If set to false, the build will continue even if there are compilation errors.
Defaults to true.
</td>
<td align="center" valign="top">No</td>
</tr>
</table> </table>


<h3>Parameters specified as nested elements</h3> <h3>Parameters specified as nested elements</h3>
@@ -4673,9 +4680,49 @@ initialization target.</p>
<td valign="top"><b>Description</b></td> <td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td> <td align="center" valign="top"><b>Required</b></td>
</tr> </tr>
<tr> <td colspan="3"/> No parameters</td>
</tr>
</table>

<h3>Nested Elements</h3>
The tstamp task supports a format nested element which allows a property to be
given the current date and time in a given format. The date/time patterns are as defined in the Java
SimpleDateFormat class.
<p>

<table width="60%" 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">property</td>
<td valign="top">
The property which is to receive the date/time string in the given pattern
</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top">pattern</td>
<td valign="top">The date/time pattern to be used. The values are defined by the Java
SimpleDateFormat class</td>
<td align="center" valign="top">Yes</td>
</tr>
</table> </table>

<h3>Examples</h3> <h3>Examples</h3>
<p> Set the standard DSTAMP, TSTAMP and TODAY properties according to the formats above
<pre> &lt;tstamp/&gt;</pre> <pre> &lt;tstamp/&gt;</pre>

<p> As for the above example, set the standard properties and also set the property
&quot;TODAY_UK&quot; with the date/time pattern &quot;d MMM yyyy&quot;

<pre> &lt;tstamp&gt;
&lt;format property=&quot;TODAY_UK&quot; pattern=&quot;d MMMM yyyy&quot;&gt;
&lt;/tstamp&gt;
</pre>

<hr> <hr>
<h2><a name="uptodate">Uptodate</a></h2> <h2><a name="uptodate">Uptodate</a></h2>
<h3>Description</h3> <h3>Description</h3>


+ 8
- 0
src/main/org/apache/tools/ant/taskdefs/Tstamp.java View File

@@ -123,6 +123,14 @@ public class Tstamp extends Task {
public void execute(Project project, Date date) public void execute(Project project, Date date)
{ {
if (propertyName == null) {
throw new BuildException("property attribute must be provided", location);
}
if (pattern == null) {
throw new BuildException("pattern attribute must be provided", location);
}
SimpleDateFormat sdf = new SimpleDateFormat (pattern); SimpleDateFormat sdf = new SimpleDateFormat (pattern);
project.setProperty(propertyName, sdf.format(date)); project.setProperty(propertyName, sdf.format(date));
} }


Loading…
Cancel
Save