Java Archive
Creates an archive for a Java Binary distribution.
Legend:
-
required
-
optional
-
may use environment variable
-
accepts Name Templates
#
assemble:
#
javaArchive:
# Assemblers require a name.
#
app:
# Enables or disables the assembler.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active: ALWAYS
# Export the assembled artifacts as a matching named distribution.
# Defaults to `true`.
#
exported: true
# The stereotype of this assembler.
# Supported values are [`NONE`, `CLI`, `DESKTOP`, `WEB`, `MOBILE`].
# Defaults to `${project.stereotype}`.
#
stereotype: CLI
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `javaArchive`, i.e, `javaArchiveFoo`.
foo: bar
# Name of the archive.
# If left undefined, will use {{distributionName}}-{{projectVersion}}.
#
archiveName: 'app-{{projectVersion}}'
# Directory with file templates used to prepare the Jpackage assembler.
# Defaults to `src/jreleaser/assemblers/${distribution.name}/java-archive`.
# If specified, path must exist.
#
templateDirectory: path/to/java-archive/templates
#
executable:
# Name of the executable launcher.
# If left undefined, will use ${distribution.name}.
#
name: app
# Executable extension on Linux/MacOS.
# If left undefined, value will be left empty.
#
unixExtension: sh
# Executable extension on Windows.
# If left undefined, will use `bat`.
#
windowsExtension: cmd
# Set of archive formats to use.
# Supported values are [`ZIP`, `TAR`, `TAR_BZ2`, `TAR_GZ`, `TAR_XZ`, `TAR_ZST`, `TBZ2`, `TGZ`, `TXZ`].
#
formats:
- ZIP
- TGZ
# The executable JAR that contains the application.
#
mainJar:
path: path/to/app.jar
# Defines a list of additional JARs as globs.
#
jars:
# The pattern to use.
# May use glob or regex pattern syntax.
#
- pattern: path/to/**/*.jar
#
java:
# Name of main module (if any).
# Define only if the application is modular.
#
mainModule: com.acme.demo
# The application's entry point.
# If left undefined, will use ${project.java.mainClass}.
#
mainClass: com.acme.Main
# Options to pass to the Java runtime
#
options: [-Xmx2048m]
# Defines a list of additional files as globs.
# These files will be added to the assembled Zip file.
#
files:
# The pattern to use.
# May use glob or regex pattern syntax.
#
- pattern: path/to/**/*.txt
#
fileSets:
# The input directory to copy files from.
#
- input: path/to/input/directory
# The target path inside the archive.
# If left undefined, defaults to the root of the archive.
#
output: path/to/archive/entry
# Fail if the given `input` does not exist.
# Defaults to `true`.
#
failOnMissingInput: false
# A set of files and directory to include.
#
includes:
- 'name_or_regex'
# A set of files and directory to exclude.
#
excludes:
- 'name_or_regex'
# Additional properties used when evaluating templates.
#
extraProperties:
# Key will be capitalized and prefixed with `artifact`, i.e, `artifactFoo`.
foo: bar
# Assemblers require a name.
#
[assemble.javaArchive.app]
# Enables or disables the assembler.
# Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
# Defaults to `NEVER`.
#
active = "ALWAYS"
# Export the assembled artifacts as a matching named distribution.
# Defaults to `true`.
#
exported = true
# The stereotype of this assembler.
# Supported values are [`NONE`, `CLI`, `DESKTOP`, `WEB`, `MOBILE`].
# Defaults to `${project.stereotype}`.
#
stereotype = "CLI"
# Additional properties used when evaluating templates.
#
extraProperties.foo = "bar"
# Key will be capitalized and prefixed with `javaArchive`, i.e, `javaArchiveFoo`.
# Name of the archive.
# If left undefined, will use {{distributionName}}-{{projectVersion}}.
#
archiveName = "app-{{projectVersion}}"
# Directory with file templates used to prepare the JavaArchive assembler.
# Defaults to `src/jreleaser/assemblers/${distribution.name}/java-archive`.
# If specified, path must exist.
#
templateDirectory = "path/to/java-archive/templates"
#
[assemble.javaArchive.app.executable]
# Name of the executable launcher.
# If left undefined, will use ${distribution.name}.
#
name = "app"
# Executable extension on Linux/MacOS.
# If left undefined, value will be left empty.
#
unixExtension = "sh"
# Executable extension on Windows.
# If left undefined, will use `bat`.
#
windowsExtension = "cmd"
# Set of archive formats to use.
# Supported values are [`ZIP`, `TAR`, `TAR_BZ2`, `TAR_GZ`, `TAR_XZ`, `TAR_ZST`, `TBZ2`, `TGZ`, `TXZ`].
#
formats = [ "ZIP", "TGZ"]
# The executable JAR that contains the application.
#
mainJar = { path = "path/to/app.jar" }
# Defines a list of additional JARs as globs.
#
[[assemble.jlink.app.jars]]
# The pattern to use.
# May use glob or regex pattern syntax.
#
pattern = "path/to/**/*.jar"
# Name of main module (if any).
# Define only if the application is modular.
#
java.mainModule = "com.acme.demo"
# The application's entry point.
# If left undefined, will use ${project.java.mainClass}.
#
java.mainClass = "com.acme.Main"
# Options to pass to the Java runtime
#
java.options = ["-Xmx2048m"]
# Defines a list of additional files as globs.
# These files will be added to the assembled Zip file.
#
[[assemble.javaArchive.app.files]]
# The pattern to use.
# May use glob or regex pattern syntax.
#
pattern = "path/to/**/*.txt"
#
[[assemble.javaArchive.app.fileSets]]
# The input directory to copy files from.
#
input = "path/to/input/directory"
# The target path inside the archive.
# If left undefined, defaults to the root of the archive.
#
output = "path/to/archive/entry"
# Fail if the given `input` does not exist.
# Defaults to `true`.
#
failOnMissingInput = false
# A set of files and directory to include.
#
includes = ["name_or_regex"]
# A set of files and directory to exclude.
#
excludes = ["name_or_regex"]
# Additional properties used when evaluating templates.
#
[[assemble.javaArchive.app.fileSets.extraProperties]]
# Key will be capitalized and prefixed with `artifact`, i.e, `artifactFoo`.
foo: bar
{
//
"assemble": {
//
"javaArchive": {
// Assemblers require a name.
//
"app": {
// Enables or disables the assembler.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
"active": "ALWAYS",
// Export the assembled artifacts as a matching named distribution.
// Defaults to `true`.
//
"exported": true,
// The stereotype of this assembler.
// Supported values are [`NONE`, `CLI`, `DESKTOP`, `WEB`, `MOBILE`].
// Defaults to `${project.stereotype}`.
//
"stereotype": "CLI",
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `javaArchive`, i.e, `javaArchiveFoo`.
"foo": "bar"
},
// Name of the archive.
// If left undefined, will use {{distributionName}}-{{projectVersion}}.
//
"archiveName": "app-{{projectVersion}}",
// Directory with file templates used to prepare the JavaArchive assembler.
// Defaults to `src/jreleaser/assemblers/${distribution.name}/java-archive`.
// If specified, path must exist.
//
"templateDirectory": "path/to/java-archive/templates",
//
"executable": {
// Name of the executable launcher.
// If left undefined, will use ${distribution.name}.
//
"name": "app",
// Executable extension on Linux/MacOS.
// If left undefined, value will be left empty.
//
"unixExtension": "sh",
// Executable extension on Windows.
// If left undefined, will use `bat`.
//
"windowsExtension": "cmd"
},
// Set of archive formats to use.
// Supported values are [`ZIP`, `TAR`, `TAR_BZ2`, `TAR_GZ`, `TAR_XZ`, `TAR_ZST`, `TBZ2`, `TGZ`, `TXZ`].
//
"formats": [
"ZIP",
"TGZ"
],
// The executable JAR that contains the application.
//
"mainJar": {
"path": "path/to/app.jar"
},
// Defines a list of additional JARs as globs.
//
"jars": [
{
// The pattern to use.
// May use glob or regex pattern syntax.
//
"pattern": "path/to/**/*.jar"
}
],
//
"java": {
// Name of main module (if any).
// Define only if the application is modular.
//
"mainModule": "com.acme.demo",
// The application's entry point.
// If left undefined, will use ${project.java.mainClass}.
//
"mainClass": "com.acme.Main",
// Options to pass to the Java runtime
//
"options": ["-Xmx2048m"],
},
// Defines a list of additional files as globs.
// These files will be added to the assembled Zip file.
//
"files": [
{
// The pattern to use.
// May use glob or regex pattern syntax.
//
"pattern": "path/to/**/*.txt"
}
],
//
"fileSets": [
{
// The input directory to copy files from.
//
"input": "path/to/input/directory",
// The target path inside the archive.
// If left undefined, defaults to the root of the archive.
//
"output": "path/to/archive/entry",
// Fail if the given `input` does not exist.
// Defaults to `true`.
//
"failOnMissingInput": false,
// A set of files and directory to include.
//
"includes": ["name_or_regex"],
// A set of files and directory to exclude.
//
"excludes": ["name_or_regex"],
// Additional properties used when evaluating templates.
//
"extraProperties": {
// Key will be capitalized and prefixed with `artifact`, i.e, `artifactFoo`.
"foo": "bar"
}
}
]
}
}
}
}
<jreleaser>
<!--
-->
<assemble>
<!--
-->
<javaArchive>
<!--
Assemblers require a name.
-->
<app>
<!--
Enables or disables the distribution.
Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
Defaults to `ALWAYS`.
-->
<active>ALWAYS</active>
<!--
Export the assembled artifacts as a matching named distribution.
Defaults to `true`.
-->
<exported>true</exported>
<!--
The stereotype of this assembler.
Supported values are [`NONE`, `CLI`, `DESKTOP`, `WEB`, `MOBILE`].
Defaults to `${project.stereotype}`.
-->
<stereotype>CLI</stereotype>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `javaArchive`, i.e, `javaArchiveFoo`.
-->
<foo>bar</foo>
</extraProperties>
<!--
Name of the archive.
If left undefined, will use {{distributionName}}-{{projectVersion}}.
-->
<archiveName>app-{{projectVersion}}</archiveName>
<!--
Directory with file templates used to prepare the JavaArchive assembler.
Defaults to `src/jreleaser/assemblers/${distribution.name}/java-archive`.
If specified, path must exist.
-->
<templateDirectory>path/to/brew/templates</templateDirectory>
<!--
-->
<executable>
<!--
Name of the executable launcher.
If left undefined, will use ${distribution.name}.
-->
<name>app</name>
<!--
Executable extension on Linux/MacOS.
If left undefined, value will be left empty.
-->
<unixExtension>sh</unixExtension>
<!--
Executable extension on Windows.
If left undefined, will use `bat`.
-->
<windowsExtension>cmd</windowsExtension>
</executable>
<!--
Set of archive formats to use.
Supported values are [`ZIP`, `TAR`, `TAR_BZ2`, `TAR_GZ`, `TAR_XZ`, `TAR_ZST`, `TBZ2`, `TGZ`, `TXZ`].
-->
<formats>
<format>ZIP</format>
<format>TGZ</format>
</formats>
<!--
The executable JAR that contains the application.
-->
<mainJar>
<path>path/to/app.jar</path>
</mainJar>
<!--
Defines a list of additional JARs as globs.
-->
<jars>
<jar>
<!--
The pattern to use.
May use glob or regex pattern syntax.
-->
<pattern>path/to/**/*.jar</pattern>
</jar>
</jars>
<!--
-->
<java>
<!--
Name of main module (if any).
Define only if the application is modular.
-->
<mainModule>com.acme.demo</mainModule>
<!--
The application's entry point.
If left undefined, will use ${project.java.mainClass}.
-->
<mainClass>com.acme.Main</mainClass>
<!--
Options to pass to the Java runtime
-->
<options>-Xmx2048m</options>
</java>
<!--
Defines a list of additional files as globs.
These files will be added to the assembled Zip file.
-->
<files>
<file>
<!--
The pattern to use.
May use glob or regex pattern syntax.
-->
<pattern>path/to/**/*.txt</pattern>
</file>
</files>
<!--
-->
<fileSets>
<fileSet>
<!--
The input directory to copy files from.
-->
<input>path/to/input/directory</input>
<!--
The target path inside the archive.
If left undefined, defaults to the root of the archive.
-->
<output>path/to/archive/entry</output>
<!--
Fail if the given `input` does not exist.
Defaults to `true`.
-->
<failOnMissingInput>false</failOnMissingInput>
<!--
A set of files and directory to include.
-->
<includes>
<include>name_or_regex</include>
</includes>
<!--
A set of files and directory to exclude.
-->
<excludes>
<exclude>name_or_regex</exclude>
</excludes>
<!--
Additional properties used when evaluating templates.
-->
<extraProperties>
<!--
Key will be capitalized and prefixed with `artifact`, i.e, `artifactFoo`.
-->
<foo>bar</foo>
</extraProperties>
</fileSet>
</fileSets>
</app>
</javaArchive>
</assemble>
</jreleaser>
jreleaser {
//
assemble {
//
javaArchive {
// Assemblers require a name.
//
app {
// Enables or disables the assembler.
// Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
// Defaults to `NEVER`.
//
active = 'ALWAYS'
// Export the assembled artifacts as a matching named distribution.
// Defaults to `true`.
//
exported = true
// The stereotype of this assembler.
// Supported values are [`NONE`, `CLI`, `DESKTOP`, `WEB`, `MOBILE`].
// Defaults to `${project.stereotype}`.
//
stereotype = 'CLI'
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `javaArchive`, i.e, `javaArchiveFoo`.
//
extraProperties.put('foo', 'bar')
// Name of the archive.
// If left undefined, will use {{distributionName}}-{{projectVersion}}.
//
archiveName = 'app-{{projectVersion}}'
// Directory with file templates used to prepare the JavaArchive assembler.
// Defaults to `src/jreleaser/assemblers/${distribution.name}/java-archive`.
// If specified, path must exist.
//
templateDirectory = 'path/to/java-archive/templates'
//
executable {
// Name of the executable launcher.
// If left undefined, will use ${distribution.name}.
//
name = 'app'
// Executable extension on Linux/MacOS.
// If left undefined, value will be left empty.
//
unixExtension = 'sh'
// Executable extension on Windows.
// If left undefined, will use `bat`.
//
windowsExtension = 'cmd'
}
// Set of archive formats to use.
// Supported values are [`ZIP`, `TAR`, `TAR_BZ2`, `TAR_GZ`, `TAR_XZ`, `TAR_ZST`, `TBZ2`, `TGZ`, `TXZ`].
//
formats = [
'ZIP',
'TGZ'
]
// The executable JAR that contains the application.
//
mainJar {
path = 'path/to/app.jar'
}
// Defines a list of additional JARs as globs.
//
jars {
// The pattern to use.
// May use glob or regex pattern syntax.
//
pattern = 'path/to/**/*.jar'
}
//
java {
// Name of main module (if any).
// Define only if the application is modular.
//
mainModule = 'com.acme.demo'
// The application's entry point.
// If left undefined, will use ${project.java.mainClass}.
//
mainClass = 'com.acme.Main'
// Options to pass to the Java runtime
//
options = ['-Xmx2048m']
}
// Defines a list of additional files as globs.
// These files will be added to the assembled Zip file.
//
files {
// The pattern to use.
// May use glob or regex pattern syntax.
//
pattern = 'path/to/**/*.txt'
}
//
fileSet {
// The input directory to copy files from.
//
input = 'path/to/input/directory'
// The target path inside the archive.
// If left undefined, defaults to the root of the archive.
//
output = 'path/to/archive/entry'
// Fail if the given `input` does not exist.
// Defaults to `true`.
//
failOnMissingInput = false
// A set of files and directory to include.
//
includes = ['name_or_regex']
// A set of files and directory to exclude.
//
excludes = ['name_or_regex']
// Additional properties used when evaluating templates.
// Key will be capitalized and prefixed with `artifact`, i.e, `artifactFoo`.
//
extraProperties.put('foo', 'bar')
}
}
}
}
}
Example
Given the following file structure
.
├── BUILD
├── LICENSE
├── README
└── target
└── app-1.0.0.jar
And this assembly configuration
project:
version: 1.0.0
assemble:
javaArchive:
app:
active: ALWAYS
fileSets:
- input: '.'
includes:
- 'LICENSE'
- 'README'
mainJar:
path: target/{{distributionName}}-{{projectVersion}}.jar
java:
mainClass: com.acme.Main
[project]
version = "1.0.0"
[assemble.javaArchive.app]
active = "ALWAYS"
[[assemble.archive.app.fileSets]]
input = "."
includes = ["LICENSE", "README"]
[[assemble.archive.app.mainJar]]
path = "target/{{distributionName}}-{{projectVersion}}.jar"
[[assemble.archive.app.java]]
mainClass = "com.acme.Main"
{
"project": {
"version": "1.0.0"
},
"assemble": {
"javaArchive": {
"app": {
"active": "ALWAYS",
"fileSets": [
{
"input": ".",
"includes": ["LICENSE", "README"]
}
],
"mainJar": [
{
"path": "target/{{distributionName}}-{{projectVersion}}.jar"
}
],
"java": {
"mainClass": "com.acme.Main"
}
}
}
}
}
<jreleaser>
<project>
<version>1.0.0</version>
</project>
<assemble>
<javaArchive>
<app>
<active>ALWAYS</active>
<fileSets>
<fileSet>
<input>.</input>
<includes>
<include>LICENSE</include>
<include>README</include>
</includes>
</fileSet>
</fileSets>
<mainJar>
<path>target/{{distributionName}}-{{projectVersion}}.jar</path>
</mainJar>
<java>
<mainClass>com.acme.Main</mainClass>
</java>
</app>
</javaArchive>
</assemble>
</jreleaser>
jreleaser {
project {
version = '1.0.0'
}
assemble {
javaArchive {
app {
active = 'ALWAYS'
fileSet {
input = '.'
includes = ['LICENSE', 'README']
}
mainJar {
path = 'target/{{distributionName}}-{{projectVersion}}.jar'
}
java {
mainClass('com.acme.Main')
}
}
}
}
}
Results in an assembled Zip archive named app-1.0.0.zip
with the following entries
.
├── LICENSE
├── README
├── bin
│ ├── app
│ └── app.bat
└── lib
└── app-1.0.0.jar