tasks.register('createDocs') {
def docs = layout.buildDirectory.dir('docs')
outputs.dir docs
doLast {
docs.get().asFile.mkdirs()
docs.get().file('readme.txt').asFile.write('Read me!')
distributions {
main {
contents {
from(createDocs) {
into 'docs'
By specifying that the distribution should include the task’s output files (see incremental builds), Gradle knows that the task that produces the files must be invoked before the distribution can be assembled and will take care of this for you.
You can run gradle installDist
to create an image of the application in build/install/projectName
. You can run gradle distZip
to create a ZIP containing the distribution, gradle distTar
to create an application TAR or gradle assemble
to build both.
The application plugin can generate Unix (suitable for Linux, macOS etc.) and Windows start scripts out of the box.
The start scripts launch a JVM with the specified settings defined as part of the original build and runtime environment (e.g. JAVA_OPTS
env var).
The default script templates are based on the same scripts used to launch Gradle itself, that ship as part of a Gradle distribution.
The start scripts are completely customizable.
Please refer to the documentation of CreateStartScripts for more details and customization examples.
Depends on: jar
, startScripts
Creates a full distribution ZIP archive including runtime libraries and OS specific scripts.
distTar
— Tar
Depends on: jar
, startScripts
Creates a full distribution TAR archive including runtime libraries and OS specific scripts.
The Application Plugin adds an extension to the project, which you can use to configure its behavior. See the JavaApplication DSL documentation for more information on the properties available on the extension.
You can configure the extension via the application {}
block shown earlier, for example using the following in your build script:
This plugin also adds some convention properties to the project, which you can use to configure its behavior. These are deprecated and superseded by the extension described above. See the Project DSL documentation for information on them.
Unlike the extension properties, these properties appear as top-level project properties in the build script. For example, to change the application name you can just add the following to your build script: