ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guttula, Mohan" <>
Subject RE: Create a file that contains files in directory
Date Fri, 21 Apr 2006 19:16:08 GMT
--- Snippet of my build.xml following IVAN suggestions that process
extensions "*.tab", "*.ind" and "*.seq" ----
<?xml version="1.0" encoding="UTF-8" ?>
<project basedir="." name="baseProject" default="help">
    <property name="master_base" value="c:\StarTeam\MyProject\release"/>
    <macrodef name="partial_file">
    	<attribute name="extension"/>
			<fileset dir="${master_base}"
				<include name="**/*.@{extension}"/>
			<pathconvert property="@{extension}.files"
pathsep="${line.separator}" refid="@{extension}.files.fs">
from="${master_base}${file.separator}*" to="@*"/>
    <target name="masterlist">
		<partial_file extension="tab">
		<partial_file extension="ind">
		<partial_file extension="seq">
		<move file="tab.txt" tofile="master.sql">
				<concatfilter append="ind.txt"/>
				<concatfilter append="seq.txt"/>
		<delete file="tab.txt"/>
		<delete file="ind.txt"/>
		<delete file="seq.txt"/>

******** "master.sql" using target "masterlist" *****

Now the issue is while appending files together in the master list.
I want to know how I can use concatfilter to append the output of the
next text file in a new line in target file? i.e., the final output of
the target file should look like the following:
------- Final "master.sql" ----


-----Original Message-----
From: Ivan "Rambius" Ivanov [] 
Sent: Wednesday, April 19, 2006 9:11 PM
To: Ant Users List
Subject: RE: Create a file that contains files in directory


--- "Guttula, Mohan" <> wrote:

> The issue was with relative path in the base
> directory. i.e., 
> <property name="master_base" value="release"/>
> Issue is resolved by using IVAN suggestion which is
> as follows:
> -----
> <property name="master_base" location="release"/>
> -----

Defining location of files and dirs with location
attribute comes vary handy when one deals with
mappers. This attribute allows you to cite the files
with their relative (to ${basedir}) names and yet Ant
deals works with their absolute paths taking care of
slashes and backslashes.

> Ivan - do you know if I can append "@" to the
> beginning of each line in
> the target directory. i.e., 
> **** Target file (master.sql) *****
> @temp/
> @temp1/temp1.ind
> @temp2/temp2.trg
> @temp3/temp3.seq
> @temp4/temp4.ind
> @temp5/temp5.trg
> ******************

I believe you can do it:
    <pathconvert property="all.files"
from="${basedir}${file.separator}*" to="@*"/>

> I also want to know if we can use some Ant task to
> rearrange line the
> target file (or should I write my custom ANT task).
> For example in the
> following way
> ******** Final "master.sql"*****
> @temp/
> @temp1/temp1.ind
> @temp4/temp4.ind
> @temp2/temp2.trg
> @temp5/temp5.trg
> @temp3/temp3.seq
> ********
> In the above file, I have to rearrange lines based
> on the extension.

In the examples above, we use <fileset>s which
collects the files in a random way, which is not
controlled by Ant, but by the underlying OS. If you
deal only with not so many different extensions you
can define <fileset>s for each of them and repeat
pathconvert + mapper trick for each <fileset> (and
that sounds like a  <macrodef>)


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

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

This message, including any attachments, contains confidential information intended for a
specific individual and purpose, and is protected by law.  If you are not the intended recipient,
please contact sender immediately by reply e-mail and destroy all copies.  You are hereby
notified that any disclosure, copying, or distribution of this message, or the taking of any
action based on it, is strictly prohibited.

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

View raw message