You can do this using the Ant loadfile task and then concat .
Here's an example, linecontainsregexp may be optional if your css file with import statements contains only import statements, one per line. (If this css file is more complex, then clarification is required below.)
<loadfile property="master.css" srcfile="master.css"> <filterchain> <linecontainsregexp> <regexp pattern="@import url" /> </linecontainsregexp> <replaceregex pattern=".*'(.*)'.*" replace="\1," /> <striplinebreaks/> </filterchain> </loadfile>
The result of this is a property containing a list of css comma separated commas in the required order. After that, you can specify Ant filelist to specify them in concatenation:
<concat destfile="all.css"> <filelist files="${master.css}" /> </concat>
source share