<terp.echo> - an enhanced <echo> task

Using the <terp.echo> task requires that the ant-terp.jar file be available to ant and that the task be registered via a <taskdef> statement:

<taskdef name="terp.echo" classname="com.codemesh.terp.ant.TerpEcho"/>

Please note that you could use any value for the name attribute that you wish; you are not limited to terp.echo. All our examples and documentation use the terp.echo name and use a name prefix of terp. to signal that they originate with and rely on the terp framework.

The <terp.echo> task is an extension of the ANT <echo> task. In addition to the ANT <echo> task's attributes, it has the following attributes:

terp.echo attributes
Name Type Description
if String Optional attribute specifying a boolean terp expression. The expression represents a condition that must be satisfied for the task to be executed.
template File Optional attribute specifying an input file that will be treated as a terp template which is expanded with a context containing the currently declared ANT properties. If both template attribute and the ANT echo task's message attribute are used, the expanded template is appended to the message.
unless String Optional attribute specifying a boolean terp expression. The expression represents a condition that must not be satisfied for the task to be executed.

You can use the inherited file attribute to write the output to a file rather than to console. All inherited echo task attributes work as expected.

When using the <terp.echo> task with the template attribute, you might want to familiarize yourself with terp templates.

To make sure that the purpose of the <terp.echo> task is perfectly clear, we'll go through a couple of examples. Just by virtue of using any of the terp tasks in your build, the ANT <echo> task will have its behavior changed to understand terp expressions. This means that you can write:

<echo>${now['%tY']} on ${localhost.name}</echo>

and see the expected values. Why bother even having the <terp.echo> task? By template-enabling the task, we made it possible for subclasses to provide a simple mechanism for generating complex documents. A subclass can set the template attribute and burden the user only with setting the output destination.


Copyright 2006-2013 by Codemesh, Inc., ALL RIGHTS RESERVED

:
<terp.echo>
codemesh.com home expressions templates ant about us contact us download   

Commandline