Search code examples
gradlebuild.gradlegradlewgradle-plugingradle-dependencies

Gradle distribution plugin


I have to create zip, tar.gz and tar.bz2 and include src, build.gradle and exclude .* files..

    <format>zip</format>
    <format>tar.gz</format>
    <format>tar.bz2</format>

so I have created below distribution in build.gradle but this will create sample.zip and sample.tar. **how to create tar.gz and tar.bz2 using distribution plugin **

distributions {
main {
baseName = 'Sample'
contents {
from { '.' }
exclude "build"
exclude ".*"
exclude "target"

        }
    }
    }

Thanks.


Solution

  • You can customize the Tar with:

    mainDistTar.compression = Compression.GZIP
    mainDistTar.extension = 'tar.gz'
    

    OR

    // Common distribution plugin settings for sub-modules
    plugins.withType(DistributionPlugin) {
        distTar {
            compression = Compression.GZIP
            extension = 'tar.gz'
        }
    }