ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allwicher, Klaus" <>
Subject Copy question
Date Tue, 15 Aug 2006 09:49:58 GMT

I have a stylistic question to the copy task and the mappers.

I have the following situation: I have four directories, one
reference/source directory, one reference/compiled directory, one
current/source directory and a current/compiled directory:

+- reference
|  +- source
|  +- compiled
+- current
   +- source
   +- compiled

The task is to copy all the files from the reference/compiled directory to
the current/compiled directory, for which the source files does not differ.

* equal.ref  
* diff.ref
* only_ref.ref

* same as above with .bin suffix

* equal.ref (equal to reference/source)
* diff.ref (different content)


In the situation above the task should only copy
'reference/compiled/equal.bin' to the 'current/compiled' directory.

Currently I implemented this with a <for> loop over a fileset, which
includes the equal files of the both source directories. In the loop, I
change the filename/path of the reference/source folder to the reference
compiled folder.
This works, but does not look very nice. 
Is there an easier solutions (The compilation has nothing to do with
Java/C++, so that dedicated tasks for this cannot be used).

And finally here the code snippet, how it is currently implemented:

<property name="current.source"     value="current\source" />
<property name="current.compiled"   value="current\compiled" />
<property name="reference.source"   value="reference\source" />
<property name="reference.compiled" value="reference\compiled" />

<!-- replace backslashes with slashes, so that the path can be used in 
	regular expressions -->
<propertyregex property="normalized.current.source" override="true" 
	input="${current.source}" regexp="\\" replace="/" />
<propertyregex property="normalized.reference.compiled"  override="true" 
	input="${reference.compiled}"  regexp="\\" replace="/" />

<!-- Iterate over the files, which are equal in both source directories -->
<for param="filename" >
	<fileset dir="${current.source}" includes="**/*.ref" >
			<different targetdir="${reference.source}" 
				ignoreContents="false" />
	<propertyregex property="normalized.filename" override="true" 
		input="@{filename}" regexp="\\" replace="/" />
	<!-- replace the path to the source with the path to the compiled
reference -->
	<propertyregex property="normalized.filename" override="true" 

		select="\1${normalized.reference.compiled}/\2.bin" />
	<copy file="${normalized.filename}" todir="${current.compiled}" />

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message