I am wondering what is the easiest way to read the contents of a file into a comma-delimited property, suitable as an argument to an attribute files filelist. I have two solutions, but I am not satisfied with any of them, and I would like to ask if anyone knows a better (shorter) way.
This only works with newer Ants, and it does not seem to be trustworthy, because each line of the input file has a prefix with basedir, which makes it necessary to call flattenmapperto delete the directory again.
<pathconvert property="files2" pathsep=",">
<resources>
<resourcelist>
<file file="IMPORT"/>
</resourcelist>
</resources>
<flattenmapper/>
</pathconvert>
Does anyone know how to avoid flattenmapperin this example? I tried to specify the attribute basedirin file, but it has no effect.
Another approach loadfilewith filterchain:
<loadfile property="files1" srcFile="IMPORT">
<filterchain>
<tokenfilter>
<replaceregex pattern="$" replace=","/>
</tokenfilter>
<striplinebreaks/>
<tokenfilter>
<replaceregex pattern=",$" replace=""/>
</tokenfilter>
</filterchain>
</loadfile>
, , , .
?