ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Atherton <br...@callenish.com>
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,
>etc...
>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
>them.
>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:

   ./orig/src
         a.java
         b.java
         c.java
         d.java
   ./a/src
         a.java
   ./b/src
         b.java
   ./c/src
         c.java
   ./dest

Then I ran ant on this buildfile:

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

and the result was:

   Buildfile: build.xml

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

   BUILD SUCCESSFUL

Sure enough, as expected d.java 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=".">
     <or>
       <and>
         <filename name="A/src/**" />
         <or>
           <present present="both" targetdir="B/src" />
           <present present="both" targetdir="C/src" />
         </or>
       </and>
       <and>
         <filename name="B/src/**" />
         <or>
           <present present="both" targetdir="A/src" />
           <present present="both" targetdir="C/src" />
         </or>
       </and>
       <and>
         <filename name="C/src/**" />
         <or>
           <present present="both" targetdir="A/src" />
           <present present="both" targetdir="B/src" />
         </or>
       </and>
     </or>
   </fileset>

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:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message