tags:

views:

25

answers:

1

I have a file username.txt with one word in it.

I have another file with template in it:

<root>
   <user name="${username}">
</root>

I need during ant build change template ${username} with content of file username.txt.
How to do it?
What ant task should I use for this purpose?

+1  A: 

If you can make your first file be a properties file instead of containing just the one word e.g.

username=superuser

Then you can load it using the property task. e.g.

<property file="username.properties" />

Update

If the file format needs to remain as in the question then take a look at the LoadFile task. It can be used to load the contents of a file into a property. e.g.

<loadfile property="username" srcFile="username.txt" />
mikej
ya beat me to it :)
JoseK
Unfortunately I cannot.
Vladimir Bezugliy
@Vladimir I have updated the answer with another suggestion to use the `LoadFile` task.
mikej