The Java library distribution plugin is incubating and should not be considered stable.
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 43.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 name
property as shown below:
The plugin build a distribution for your library. The distribution will package up the runtime dependencies of the library
All files stored in src/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 43.1. Java library distribution plugin - tasks
Task name | Depends on | Type | Description |
distZip
|
jar
|
Zip
|
Creates a full distribution ZIP archive including runtime libraries. |
The Java library distribution plugin add an extension to the project, which you can use to configure its behaviour. See Project
.
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 task.
Example 43.3. Include files in the distribution
build.gradle
distZip { from('oneFile') //Copy to the root of the distribution from('secondFile') { into('dist') // Copy to the dist directory } }