The distribution plugin is incubating (see Section C.1.2, “Incubating”).
The distribution plugin extends the language plugins with common distribution related tasks. It allows bundling a project including binaries, sources and documentation.
To use the distribution plugin, include in your build script:
To define the name for the distribution you have to set the baseName
property as shown below
Example 43.2. Configure the distribution name
build.gradle
distributions {
main {
baseName = 'my-name'
}
}
The plugin build a distribution for your project. You can run gradle distZip
to create a
ZIP containing the distribution. Given that the project name is myproject and version is 1.2, then running gradle customDistZip will produce a ZIP file called myproject-1.2.zip
The Distribution plugin adds the following tasks to the project.
The distribution plugin allow to configure distributions to include custom files and to change distribution baseName.
Example 43.3. Declare multiple distributions
build.gradle
apply plugin: 'distribution' distributions { main { baseName = 'someName' contents { from { 'src/dist' } } } }
The distribution plugin allow to generate multiple distributions.
Example 43.4. Declare multiple distributions
build.gradle
apply plugin: 'distribution' version = '1.2' distributions { custom { contents { from { 'src/dist' } } } }
This will following tasks to the project : customDistZip, customDistTar, installcustomDist. Given that the project name is myproject, then running gradle customDistZip will produce a ZIP file called myproject-custom-1.2.zip and running customDistTar will produce myproject-custom-1.2.tar. Running installcustomDist will install distribution contents into buildDir/install/custom.
The distribution plugin add an extension to the project, which you can use to configure its behaviour. See Project
.