``````    def spec = copySpec {
with libs
}
``````

Where is `libs` coming from in this case? I assume the result of something like `from { }`?
In that case you’ll need to define that `CopySpec` using `copySpec { }` and then use it in both places via `with()`.