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

It’s easy enough to implement (do it now if someone doesn’t find a real answer), but I always prefer reuse over implementation.

How can I recursively copy a folder to groovy, excluding some folders / paths? I know that this can be done using ant, but I think that simple native groovy code is good too.

+6
source share
1 answer

Posting code to use AntBuilder (link to my comment above) in case the page disappears later:

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, but ...

+7
source

Source: https://habr.com/ru/post/896775/


All Articles