Ant — copying files and subdirectories from only one subdirectory on a tree

前端 未结 2 494
鱼传尺愫
鱼传尺愫 2021-01-12 22:20

I\'d like to copy files and subdirectories using Ant from a single subdirectory without copying the rest of the directory structure and contents. For example, I\'d like to

2条回答
  •  情书的邮戳
    2021-01-12 22:47

    It's not that difficult...

    
         
             
         
    
    

    When you use the include directive, it will only include the files that match the pattern you give it. In this case, I'm copying only those files that have /dir3/ somewhere in their full path name. This includes sub-directories under dir3 and all files under dir3.

    You can use the exclude directive to override the include directives:

    
         
             
             
         
    
    

    This will copy all sub-directories and files in those sub directories, but not the files under dir3 itself. The * matches all files in the directory while ** matches the all the files in the entire directory tree.

    Notice this will create a directory temp/dir2/dir3. If I want temp/dir3, I have to set my fileset to the parent directory of dir3:

    
         
             
         
    
    

    Doing this:

    
         
    
    

    Will create a directory temp with all the files directly under dir3 directly under temp. There will also be a temp/dir4 and temp/dir5 directory containing all the files (and directory trees) under those directories.

提交回复
热议问题