Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How in Ant output values of properties?

In Ant exits task Echo:

<echo message="Hello, world"/> 

But it seems useless. I need to check values in ant file. E.g.

 <property file="${user.home}/build.properties"/>  <echo message="${file}" /> 

but I receive only:

 [echo] ${file} 

How I can have Ant display value of file?

like image 320
user810430 Avatar asked Nov 22 '11 13:11

user810430


People also ask

How do I set Ant properties?

The <property> task is used to set the Ant properties. The property value is immutable, once the value is set you cannot change it. To set a property to a specific value you use Name/value assignment. To set a property to a location you use Name/location assignment.

How do I override property value in Ant?

Ant Properties are set once and then can never be overridden. That's why setting any property on the command line via a -Dproperty=value will always override anything you've set in the file; the property is set and then nothing can override it. This way: Anything set at the command line takes precedence over build.

How do I use Ant properties file?

The name of the project, as specified in the name attribute of the project element. The default target of the current project. Comma separated list of the targets that were invoked in the current project. The full location of the Ant jar file.


2 Answers

This statement:

<property file="${user.home}/build.properties"/> 

Reads a property file(i.e. all properties in that file), and does not set the property named file.

This would be correct. You first set a property and then echo it:

<property name="file" value="${user.home}/build.properties"/> <echo message="${file}" /> 
like image 127
oers Avatar answered Oct 07 '22 14:10

oers


You're getting ${file} echoed back at you because you're not setting that property. Is there a line in your property file that says file = someValue?

Maybe you want to do something like this?

<property name="property.file" value="${user.home}/build.properties"/> <property file="${property.file}"/> <echo message="My property file is called &quot;${property.file}&quot;"/> 
like image 21
David W. Avatar answered Oct 07 '22 15:10

David W.