How to programmatically concatenate with ANT?
ant, build-process, concatenation
Solution
I think your requirements are:
- load the filelist from another xml file
- concat this filelist together
If that's the case, there's no reason you should be making your own procedural loop. You can do something like:
scripts.xml
<scripts>
<src>file1</src>
<src>file2</src>
</scripts>
build.xml
<xmlproperty file="scripts.xml" collapseAttributes="true" />
<concat destfile="${out}" fixlastline="yes" eol="lf">
<filelist files="${scripts.src}"/>
</concat>
is this the case?
Problem
Let me preface by saying that I'm new to ant, and I'm using version 1.6.5 if it matters. I have a file with a list of files that I want to concatenate. The relevant part of my first attempt was this: ``` <target name="for-each"> <xmlproperty file="scripts.xml" collapseAttributes="true" /> <echo message="testing for-each"/> <concat destfile="${out}" fixlastline="yes" eol="lf"> <foreach list="${scripts.src}" target="loop" param="var" delimiter=","/> </concat> </target> <target name="loop"> <echo message="File :: ${var}"/> <fileset file="${SRC_DIR}${var}" /> </target> ``` However, concat doesn't support the foreach element. I don't simply want to cut and paste a fileset into the concat element because it's reused and may be changed in the original file often, so I want to programmaticly iterate over the script elements listed in my file instead. What would the right syntax be or how would I accomplish this?