# The Distribution Plugin

The distribution plugin is currently incubating. Please be aware that the DSL and other configuration may change in later Gradle versions.

The distribution plugin facilitates building archives that serve as distributions of the project. Distribution archives typically contain the executable application and other supporting files, such as documentation.

## Usage

To use the distribution plugin, include the following in your build script:

The plugin adds an extension named “`distributions`” of type to the project. It also creates a single distribution in the distributions container extension named “`main`”. If your build only produces one distribution you only need to configure this distribution (or use the defaults).

You can run “`gradle distZip`” to package the main distribution as a ZIP, or “`gradle distTar`” to create a TAR file. To build both types of archives just run `gradle assembleDist`. The files will be created at “``$buildDir`/distributions/`$project.name`-`$project.version`.`«ext»``”.

You can run “`gradle installDist`” to assemble the uncompressed distribution into “``$buildDir`/install/`main``”.

## Tasks

The Distribution plugin adds the following tasks to the project:

## Distribution plugin - tasks

Task name | Depends on | Type | Description
`distZip` | `-` |  | Creates a ZIP archive of the distribution contents
`distTar` | `-` |  | Creates a TAR archive of the distribution contents
`assembleDist` | `distTar`, `distZip` |  | Creates ZIP and TAR archives with the distribution contents
`installDist` | `-` |  | Assembles the distribution content and installs it on the current machine

For each extra distribution set you add to the project, the distribution plugin adds the following tasks:

## Multiple distributions - tasks

Task name | Depends on | Type | Description
``${distribution.name}`DistZip` | `-` |  | Creates a ZIP archive of the distribution contents
``${distribution.name}`DistTar` | `-` |  | Creates a TAR archive of the distribution contents
`assemble`${distribution.name.capitalize()}`Dist` | ``${distribution.name}`DistTar`, ``${distribution.name}`DistZip` |  | Assembles all distribution archives
`install`${distribution.name.capitalize()}`Dist` | `-` |  | Assembles the distribution content and installs it on the current machine

This will add following tasks to the project:

- customDistZip
- customDistTar
- assembleCustomDist
- installCustomDist

Given that the project name is “`myproject`” and version “`1.2`”, running “`gradle customDistZip`” will produce a ZIP file named “`myproject-custom-1.2.zip`”.

Running “`gradle installCustomDist`” will install the distribution contents into “``$buildDir`/install/custom`”.

## Distribution contents

All of the files in the “`src/`$distribution.name`/dist`” directory will automatically be included in the distribution. You can add additional files by configuring the object that is part of the container.

In the example above, the content of the “`src/readme`” directory will be included in the distribution (along with the files in the “`src/main/dist`” directory which are added by default).

The “`baseName`” property has also been changed. This will cause the distribution archives to be created with a different name.

## Publishing distributions

The distribution plugin adds the distribution archives as candidate for default publishing artifacts. With the `maven` plugin applied the distribution zip file will be published when running uploadArchives if no other default artifact is configured