Gradle zip: how to include and rename one file easily?

Viewed 5107

Create a zip adding file "hello/world.xml" under directory "foo/bar" as "hello/universe.xml"

task myZip(type: Zip) {
     from ("foo/bar") {
         include "hello/world.xml"
         filesMatching("hello/*") {
             it.path = "hello/universe.xml"
         }
     }
}

filesMatching(...) will impact performance obviously. What is a better way? like:

task myZip(type: Zip) {
     from ("foo/bar") {
         include ("hello/world.xml") {
              rename "hello/universe.xml"
         }         
     }
}

But rename is not supported with include.

2 Answers

If the last one did not work, try:

rename ('a.java', 'b.java')
Related