Ant - How to echo a property value

Syntax:


<echo message="${PROPERTY_NAME}"/>

The properties loaded in an ant script can be displayed using the echo tag and the message parameter.

Example:

This example creates a test task. The property tmp.prop has the value "This is a test". A message is written in the output with the content of the property.

<project name="MyProject" default="test" basedir=".">

  <target name="test">
  
    <!-- Create a property -->
    <property name="tmp.prop" value="This is a test"/>
    
    <!-- Show the property -->
    <echo message="Content of tmp.prop = ${tmp.prop}"/>
  </target>

</project>               

The output will be:

$ ant
Buildfile: build.xml

test:
     [echo] Content of tmp.prop = This is a test

BUILD SUCCESSFUL
Total time: 0 seconds


References:

Apache Ant

Ant property

Share this article:

Recent Comments