The Java library distribution plugin is incubating (see Section C.1.2, “Incubating”).
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.
To use the Java library distribution plugin, include in your build script:
Example 45.1. Using the java library distribution plugin
build.gradle
apply plugin: 'java-library-distribution'
To define the name for the distribution you have to set the baseName
property as shown below:
Example 45.2. Configure the distribution name
build.gradle
distributions {
main{
baseName = 'my-name'
}
}
The plugin build 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 containing the distribution.
The Java library distribution plugin adds the following tasks to the project.
Table 45.1. Java library distribution plugin - tasks
Task name | Depends on | Type | Description |
distZip
|
jar
|
Zip
|
Creates a full distribution ZIP archive including runtime libraries. |
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 it to the content of the distribution.
Example 45.3. Include files in the distribution
build.gradle
distributions { main { baseName = 'my-name' contents { from { 'src/dist' } } } }