0

This should be a simple one. I had another codebase that this worked but for some reason it wont work here at all. My file will.txt is unmodified.

Here is an exerp from my ant build file .. Any ideas Ive wasted hours already banging my head trying to get it to work.

<loadfile
       property="config.update.list"
       srcFile="config.update.list" failonerror="true">
  <filterchain>
     <replacetokens>        
        <token key="__PRODUCT_VERSION__" value="CATTY"/>
     </replacetokens>
     <striplinebreaks/>
  </filterchain>
</loadfile>

<echo>${config.update.list}</echo>

Below is contents of the file config.update list

/tmp/will.txt

Below is the contents of /tmp/will.txt

@__PRODUCT_VERSION__@ will
3
  • 1
    Did you try to run it with ant -v? Commented Jan 6, 2010 at 19:57
  • 1
    Why srcFile is set to config.update.list? Should it be /tmp/will.txt? Commented Jan 6, 2010 at 19:59
  • this is a simplified version config.update.list will have numerous files in it. Commented Jan 6, 2010 at 20:04

1 Answer 1

2

From Alexander Pogrebnyak's comment. Attribute srcFile should point to file name /tmp/will.txt:

<loadfile
   property="config.update.list"
   srcFile="/tmp/will.txt" failonerror="true">

Or if file name is stored in this property then you should use srcFile="${config.update.list}". Anyway, ant doesn't allow you to change value of the properties. So you can't use property="config.update.list" for output if it's already set. Try to use other property for output:

<loadfile
   property="config.update.list.output"
   srcFile="/tmp/will.txt" failonerror="true">
...
<echo>[${config.update.list.output}]</echo>
Sign up to request clarification or add additional context in comments.

1 Comment

This looks like what I was after. In the end due to time etc.. I choose todo it the using the replace tags e.g. <replace file="/tmp/will.txt" token="@__PRODUCT_VERSION__@" value="newvalue"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.