# The Java Library Distribution Plugin

version 9.4.0-20260128061951+0000

The Java library distribution plugin adds support for building a distribution ZIP for a Java library. The distribution contains the JAR file for the library and its dependencies.

## Usage

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

Example 1. Using the Java library distribution plugin
build.gradle.kts

    plugins {
        `java-library-distribution`
    }

build.gradle

    plugins {
        id 'java-library-distribution'
    }

To define the name for the distribution you have to set the `baseName` property as shown below:

Example 2. Configure the distribution name
build.gradle.kts

    distributions {
        main {
            distributionBaseName = "my-name"
        }
    }

build.gradle

    distributions {
        main {
            distributionBaseName = 'my-name'
        }
    }

The plugin builds a distribution for your library. The distribution will package up the runtime dependencies of the library. All files stored in `src/main/dist` will be added to the root of the archive distribution. You can run “gradle distZip” to create a ZIP file containing the distribution.

## Tasks

The Java library distribution plugin adds the following tasks to the project.

`distZip` — Zip

  Depends on: `jar`

  Creates a full distribution ZIP archive including runtime libraries.

## Including other resources in the distribution

All of the files from the `src/dist` directory are copied. To include any static files in the distribution, simply arrange them in the `src/dist` directory, or add them to the content of the distribution.

Example 3. Include files in the distribution
build.gradle.kts

    distributions {
        main {
            distributionBaseName = "my-name"
            contents {
                from("src/dist")
            }
        }
    }

build.gradle

    distributions {
        main {
            distributionBaseName = 'my-name'
            contents {
                from 'src/dist'
            }
        }
    }