You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Suncire, Joe" <Jo...@qwest.com> on 2002/04/23 22:32:45 UTC
skipping binary files while filtering is on
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: skipping binary files while filtering is on
Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 23 Apr 2002, Joe Suncire <Jo...@qwest.com> wrote:
> Is there a more efficient way to do this?
Using external files to hold your patterns and in/excludesfile would
at least avoid the duplication of the patterns.
I'm not aware of any other solution right now - if that selector
proposal gets into Ant 1.5, it may be an option.
> Is there a way to "detect" a text-based versus binary file with ANT?
No - at least not yet.
> I've considered having an external file containing patternsets that
> the build.xml would reference .
Oops, should read the entire mail before writing my answer. Yes, do
that 8-)
Stefan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>