distZip rename rootFolder and artifact


( Hang Zhang(hzhang2)) #1

I learned the way from the post below to make Zip file and root folder have different name :

Now:
my zip file name is : sampleFile-1.0.0.ZIP
my root folder name is: sampleFile
The problem is : Since i set the archiveName to sampleFile, artifact is looking for sampleFile instead of “sampleFile-1.0.0.ZIP”, how shall i handle this case?

configurations {
  dist
}

artifacts {
  dist distZip
}

distZip {
  archiveName "sampleFile"

  doLast {
    String zipFinalPath = $destinationDir + baseName + '.zip'
    file("$destinationDir/$archiveName").renameTo(zipFinalPath)
   
  }
}