How to rename a new directory created as result of unzip?

(Rick Bryant) #1

Am unzipping a tomcat distribution into the buildDir which results in a new directory being created (apache-tomcat-8.0.32) that contains the contents of the zip file. Need to rename this newly created directory from the tomcat specific directory name to a generic name (tomcat-prep) for subsequent processing.

So far we’ve only been able to achieve this with the following task:

task unzipTomcat() {
  doLast {
    copy {
      into buildDir
    copy {
    delete "$buildDir/apache-tomcat-8.0.32"

So instead of copying the source directory to the target directory and then deleting the source directory, is there any way to simply just rename the source directory (apache-tomcat-8.0.32) to the target directory (tomcat-prep)???

(Benjamin Muschko) #2

I believe you could use eachFile to modify the path similar to the way it was described in this post. It doesn’t necessarily make your logic more readable or maintainable - rather more complex.