How do I flatten when copy?

I am trying to port our ant build scripts to groovy. I am having trouble figuring out how to flatten a directory structure when copying. Here is the equivalent ant:

<copy todir="destDir" flatten="true">
    <fileset dir="srcDir" />
</copy>

Apologies if this question has already been answered. I did several google searches but the only definitive answer I got was for a method that is no longer available on the Copy task type: remapTarget.

is there an easy way to do this (besides using the ant task directly)?

Thanks!

“to” should be “into” in the above sample

Fixed. Thanks.

task copy(type: Copy) {
    from fileTree("srcDir").files
    into "destDir"
}
1 Like