Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a folder, with exclusions, with native groovy?

Tags:

groovy

This is easy enough to implement (will do it now unless someone answers real quick), but I'd always rather reuse than implement.

How can one recursively copy a folder in groovy, while excluding some folders/paths? I know this can be done with ant, but I think a simple native groovy code is nice to have as well.

like image 201
ripper234 Avatar asked Sep 07 '11 09:09

ripper234


1 Answers

Posting the code to use AntBuilder (Linked to from my comment above) in case the page disappears at a later date:

new AntBuilder().copy(todir: "dstFolder") {
    fileset(dir : "srcFolder") {
        include(name:"**/*.java")
        exclude(name:"**/*Test.java")
    }
}

Not sure if you meant that for some reaon you wanted to avoid using Ant completely however...

like image 105
tim_yates Avatar answered Oct 22 '22 06:10

tim_yates