ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Suncire, Joe" <Joe.Sunc...@qwest.com>
Subject skipping binary files while filtering is on
Date Tue, 23 Apr 2002 20:32:45 GMT
I'm performing the Copy task on a directory structure.  I have to take care
not to include binary files whenever I do filtering of tokens because there
may be @'s in binary files, especially .gif files, which would cause those
files to be corrupted.  

In order to achieve this, I perform the copy in two passes. In the first
pass, I copy and filter all the text-based files that have tokens in them,
explicitly skipping the files I've designated as "binary".  Then in the
second pass, I do a normal copy, this time getting all the binary files that
weren't copied in the first pass.  Here's the excerpt from by build.xml:

		        <target name="copy" depends="init">
		                <echo message="Using environment variables
from ${env_file}"/>
		                <filter filtersfile="${env_file}"/>

		                <!-- copy and parse the non-binary files -->
		                <copy todir="${builddir}" verbose="true"
filtering="true">
		                        <fileset dir="./checkout/rmc"
defaultexcludes="yes" casesensitive="false">
		                                <exclude name="**/*.java"/>
		                                <exclude name="**/*.jar"/>
		                                <exclude name="**/*.zip"/>
		                                <exclude name="**/*.gif"/>
		                                <exclude name="**/*.jpeg"/>
		                                <exclude name="**/*.jpg"/>
		                                <exclude name="**/*.doc"/>
		                                <exclude name="**/*.pdf"/>
		                                <exclude name="**/*.exe"/>
		                        </fileset>
		                </copy>

		                <!-- copy files that weren't copied in the
previous step -->
		                <copy todir="${builddir}" verbose="true"
filtering="false">
		                        <fileset dir="./checkout/rmc"
defaultexcludes="yes" casesensitive="false">
		                                <include name="**/*.java"/>
		                                <include name="**/*.jar"/>
		                                <include name="**/*.zip"/>
		                                <include name="**/*.gif"/>
		                                <include name="**/*.jpeg"/>
		                                <include name="**/*.jpg"/>
		                                <include name="**/*.doc"/>
		                                <include name="**/*.pdf"/>
		                                <include name="**/*.exe"/>
		                        </fileset>
		                </copy>
		        </target>


		Is there a more efficient way to do this?  Is there a way to
"detect" a text-based versus binary file with ANT?  I've considered having
an external file containing patternsets that the build.xml would reference .
That way, if a new binary type showed up in the directory structure (say, an
.xls ), then only this file would have to be modified, not the build.xml.

		Thanks

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message