user5771310
user5771310

Reputation:

Customize Gradle distribution plugin to generate tar.gz

i have to create tar.gz , below is my distribution setting in build.gradle

distributions { 
  main { 
   contents {
     into ("/")
     from libsDir
     include ‘.jar’
     rename '..jar’, “${project.name}.jar”
     from “env”
     include ‘*.conf’
    }
  }
}

Please suggest what changes i need to make to build.gradle in order to generate tar.gz file

Upvotes: 5

Views: 3611

Answers (4)

Tomas F
Tomas F

Reputation: 7596

gradle 7.6 with kotlin DSL

tasks.distTar {
    compression = Compression.GZIP
    archiveExtension.set("tar.gz")
}

Upvotes: 0

Mariano Ruiz
Mariano Ruiz

Reputation: 4749

Similar to the other solutions, this works for me:

tasks.withType(Tar) {
    compression = Compression.GZIP
    archiveExtension = 'tar.gz'
}

Tested with Gradle 6.8.

Upvotes: 1

Atais
Atais

Reputation: 11275

With Gradle 6.x

just add to build.gradle

distTar {
    compression = Compression.GZIP
    archiveExtension = "tar.gz"
}

Upvotes: 3

Thomas Decaux
Thomas Decaux

Reputation: 22671

You can add:

plugins.withType(DistributionPlugin) {
    distTar {
        compression = Compression.GZIP
        extension = 'tar.gz'
    }
}

This will configure the Tar class.

Upvotes: 5

Related Questions