ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Atherton <>
Subject Re: Help with selectors
Date Wed, 11 Sep 2002 21:24:34 GMT
At 10:50 AM 9/11/2002 -0500, Dominique Devienne wrote:

>1) I have ~5000 Java source files in ${ds.home}/src.
>2) I copy part of these into different modules (A, B, C, etc...),
>    in modulename/src. Module A gets 200 files, module B 15, module C 853,
>3) I want to get all the sources I didn't get earlier in the other modules
>    in a final 'misc' module.
>4) Finally, I want to check I didn't copy any file to more than one module.
>To achieve (3), I tried the following:
>   <fileset id="misc-sources"
>            dir="${ds.home}/src">
>     <!-- This fileset selects all files not selected by all
>          the different modules. It should be empty!!! -->
>     <none>
>       <present present="both" targetdir="A/src" />
>       <present present="both" targetdir="B/src" />
>       <present present="both" targetdir="C/src" />
>     </none>
>   </fileset>
>I tried using either 'both' or 'srconly', and I get all files, or none of
>I *know* for sure there are files of ${ds.home}/src I didn't copy in either
>A, B, or C!

Hmm. Annoying though the response "it works for me" is for someone 
struggling with a problem, I have to say that it works for me. First, I 
created this directory tree:


Then I ran ant on this buildfile:

   <project default="all" basedir=".">
     <target name="all">
       <copy todir="dest">
         <fileset dir="orig/src">
             <present present="both" targetdir="a/src" />
             <present present="both" targetdir="b/src" />
             <present present="both" targetdir="c/src" />

and the result was:

   Buildfile: build.xml

        [copy] Copying 1 file to /home/bruce/test/dest


Sure enough, as expected is the only file in the ./dest directory.

So I'm not exactly sure what is going on in your case.

>I have no clue how to achieve (4). Help would be greatly appreciated. --DD

Tricky. Off the top of my head, if the combinatorial explosion isn't too 
large, you could do something like:

   <fileset dir=".">
         <filename name="A/src/**" />
           <present present="both" targetdir="B/src" />
           <present present="both" targetdir="C/src" />
         <filename name="B/src/**" />
           <present present="both" targetdir="A/src" />
           <present present="both" targetdir="C/src" />
         <filename name="C/src/**" />
           <present present="both" targetdir="A/src" />
           <present present="both" targetdir="B/src" />

You don't say what action you want performed if there are duplicated files. 
If it is just reporting, you could do a pathconvert and echo the property 
out. Both instances of a duplicated file will be detected this way, though, 
so don't pass the fileset into <delete>.

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

View raw message