Unzipping an archive in custom task?

In regular task inside build.gradle.kts file we can do

copy {
    from(zipTree("${zipfilepath}"))
    into("${destinationPath}")
}

but it doesn’t work in custom task implementation. Are there any convenience methods or the only way is to do regular implementation?

As a start, you would most often want to not use copy { ... }, but sync { ... } to not have stale files lying around.

Besides that, in a full task class you would inject an instance of ArchiveOperations which have the sync and copy methods.

Thanks a lot! With this I managed to create custom tasks (though there are some problems with config-cache but I disabled those for now…)

Which problems are there?