Distribution plugin
Javadoc:https://docs.gradle.org/current/javadoc/
The distribution plugin is currently incubating. Please be aware that the DSL and other configuration may change in later Gradle versions.
- Using the distribution plugin
apply plugin: 'distribution'
- to package the main distribution
It 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
”.
distributions {
main {
baseName = 'someName'
contents {
from { 'src/readme' }
}
}
}
using baseName
property will cause the distribution archives to be created with a different name.
- tasks of distribution plugin
The Distribution plugin adds the following tasks to the project:
Task name | Depends on | Type | Description |
---|---|---|---|
distZip |
- |
Zip |
Creates a ZIP archive of the distribution contents |
distTar |
- |
Tar |
Creates a TAR archive of the distribution contents |
assembleDist |
distTar ,distZip |
Task |
Creates ZIP and TAR archives with the distribution contents |
installDist |
- |
Sync |
Assembles the distribution content and installs it on the current machine |
using ./gradlew tasks
to see all the tasks.
- Adding extra distributions
distributions {
custom {}
}
This will add following tasks to the project:customDistZip
customDistTar
assembleCustomDist
installCustomDist
using ./gradlew installCustomDist
to install the distribution contents into "$buildDir/install/custom"
Task name | Depends on | Type | Description |
---|---|---|---|
${distribution.name}DistZip |
- |
Zip |
Creates a ZIP archive of the distribution contents |
${distribution.name}DistTar |
- |
Tar |
Creates a TAR archive of the distribution contents |
assemble${distribution.name.capitalize()}Dist |
${distribution.name}DistTar ,${distribution.name}DistZip |
Task |
Assembles all distribution archives |
install${distribution.name.capitalize()}Dist |
- |
Sync |
Assembles the distribution content and installs it on the current machine |
- 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 Distribution object that is part of the container.
distributions {
main {
baseName = 'someName'
contents {
from { 'src/readme' }
}
}
}
- 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
apply plugin:'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://some/repo")
}
}
}