Ant move puts a new line at the end of the property

I have an Ant task in Eclipse to get the version from a file:

<loadfile property="version" srcfile="version.txt"> <filterchain> <linecontainsregexp> <regexp pattern="^#define version .(\d{1,10})\.(\d{1,10})\.(\d{1,10})\.(\d{1,10})."/> </linecontainsregexp> <replaceregex pattern="^#define version .(\d{1,10})\.(\d{1,10})\.(\d{1,10})\.(\d{1,10})..*$" replace="\1.\2.\3.\4" /> </filterchain> </loadfile> <echo message="Version ${version}"/> 

The version is displayed without a new line. Further in the code, I want to use a property with a move task:

 <move file="${dir}\file.exe" tofile="${outputdir}\output-${version}-xxx.exe" overwrite="true" force="true" /> 

But this fails with the message

 BUILD FAILED build.xml:26: Failed to copy path\file.exe to path\output_directory\output-1.0.0.0 -xxx.exe due to output-1.0.0.0 -xxx.exe (Nรกzev souboru ฤi adresรกล™e nebo jmenovka svazku je nesprรกvnรก) 

(the last line means that the file name is invalid, it is obvious that it contains a new line in the middle).

Where am I mistaken? Is this a property? Even adding a line

 <replaceregex pattern="&#10;" replace="" flags="s"/> 

or other attempts to remove new lines from the property have not changed anything.

+4
source share
1 answer

You need line breaks , for example:

 <filterchain> <linecontainsregexp ... /> <replaceregex ... /> <striplinebreaks /> </filterchain> 

If you change your <echo> to:

 <echo message="Version -${version}-"/> 

you will see reporting.

+5
source

All Articles