Change zip name when creating archive with distribution plugin in gradle

Is there a way to customize the distribution file name when creating the archive using the distribution plugin in gradle?

Here is my build.gradle(I use gradle 2.10) file:

apply plugin: 'distribution'
version '1.2'

distributions {
  custom {
    baseName = 'someName'
    contents {...}
  }
}

And the task call customDistZipcreates a file: $buildDir/distributions/someName-1.2.zipI would like to have the configurd file name for: someName.zip(without version number).

My workaround for this is to create a new task to rename the zip file after creating and using the gradle function finalizedBy:

task renameDist {
  doLast {
    new File("$buildDir/distributions/someName-${project.version}.zip")
            .renameTo("$buildDir/distributions/someName.zip")
  }
}
customDistZip.finalizedBy renameDist

But this does not look like an elegant and pleasant solution.

+4
source share
1 answer

You can:

customDistZip.setVersion('')

, baseName,

customDistZip.setArchiveName('someName.zip')

, alltogether.

+4

Source: https://habr.com/ru/post/1622985/


All Articles