'Replacement in Gradle for Ant's zipfileset

I am trying to migrate Ant targets to Gradle tasks, but I'm having an issue. In Ant, zipfileset allows us to specify a prefix folder to all files inside jar or zip. How can we achieve this in Gradle?

How can we replace the Ant code below in Gradle?

<jar destfile="${jarDestination}">
  <zipfileset dir="${dir}" prefix="${prefix}"/>
</jar>

Notice: I know that we can use ant inside Gradle. I seeking for clear gradle/groovy solution.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source