ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kovács István" <kovacs...@gmail.com>
Subject Copying, filtering
Date Thu, 21 Sep 2006 15:28:53 GMT
Hi,

I need to copy files from multiple directories to a single deployment
target directory. In the process, I need to replace a few strings. A
filter embedded in the copy task allows me to do that, but it would
corrupt the binary files, so I copy text files with the filter, binary
files without it. I'll have several similar targets that copy files
from different, sometimes overlapping sets of directories, and I'd
like to eliminate as much duplication as possible.
Here's what I currently do:

<project name="myProjectr" default="compileAll" basedir=".">
	<property name="binaryFiles"
value="**/*.class,**/*.jar,**/*.exe,**/*.dll,**/*.gif,**/*.jpg" />
[... stuff omitted ...]
	<target name="OneDeploy">
		<property name="dest" value="OneDir" />
		<delete dir="${dest}"  />
		<copy todir="${dest}">
			<fileset dir="skeleton/A" excludes="${binaryFiles}" />
			<fileset dir="skeleton/B" excludes="${binaryFiles}" />
			<fileset dir="skeleton/C" excludes="${binaryFiles}" />
			<filterset filtersfile="OneFilter.properties" />
		</copy>
		<copy todir="${dest}">
			<fileset dir="skeleton/A" includes="${binaryFiles}" />
			<fileset dir="skeleton/B" includes="${binaryFiles}" />
			<fileset dir="skeleton/C" includes="${binaryFiles}" />
		</copy>
	</target>

	<target name="OtherDeploy">
		<property name="dest" value="OtherDir" />
		<delete dir="${dest}"  />
		<copy todir="${dest}">
			<fileset dir="skeleton/A" excludes="${binaryFiles}" />
			<fileset dir="skeleton/B" excludes="${binaryFiles}" />
			<fileset dir="skeleton/D" excludes="${binaryFiles}" />
			<filterset filtersfile="OtherFilter.properties" />
		</copy>
		<copy todir="${dest}">
			<fileset dir="skeleton/A" includes="${binaryFiles}" />
			<fileset dir="skeleton/B" includes="${binaryFiles}" />
			<fileset dir="skeleton/D" includes="${binaryFiles}" />
		</copy>
	</target>
</project>

Q1: Is there a simpler way to define something like "all files from
skeleton/A, B and C that are not binary" (avoiding the need to repeat
the excludes attribute for each)?

Q2: Since the copying is identical (except for the name and number of
source directories involved and the destination directory), it'd be
nice to define the 'dest' property depending on the target, and define
the source directories there as well. I've thought of defining a
doCopy target, setting the destination directory as a property and
invoking it with antCall, but how do I take care of the sources?

TIA,
Kofa

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


Mime
View raw message