Learner
Learner

Reputation: 21445

How to display a property defined in build.properties file in ANT

I have defined a property in my build.properties file, I am trying to check if the value is properly set or not using below code in my build.xml file.

<?xml version="1.0" ?>
<project name="myapp" default="showProps">
  <target name="showProps">
      <echo>My property is ${my_property.data}</echo>
      <echo message="${my_property.data}"/>
  </target>
</project>

But when I run the ant command I am getting output as:

showProps:
     [echo] My property is ${my_property.data}
     [echo] ${my_property.data}

Please tell me how to display the property value?

Upvotes: 0

Views: 720

Answers (1)

M A
M A

Reputation: 72884

Pass your properties file in the command-line:

ant -propertyfile build.properties

or load the properties file within the buildfile:

<project name="myapp" default="showProps">
   <property file="build.properties"/>
   <target name="showProps">
     <echo>My property is ${my_property.data}</echo>
     <echo message="${my_property.data}"/>
   </target>
</project>

Upvotes: 2

Related Questions