Packaging
This section describes the primary options for packaging and distributing your Jooby application.
Single Jar (Fat/Uber Jar)
The most common deployment option is creating a single executable "Fat Jar" that contains your application code along with all its dependencies.
|
Tip
|
The Jooby CLI automatically configures your project for single jar distribution. The examples below show how to configure it manually if needed. |
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.2</version>
<executions>
<execution>
<id>uber-jar</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${application.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
To build the package:
-
Maven:
mvn clean package -
Gradle:
./gradlew shadowJar
Stork
Stork is a specialized packaging, launch, and deployment tool for Java applications. It generates platform-specific native launchers (shell scripts or batch files) and organizes your dependencies in a clean directory structure.
|
Note
|
The Stork integration is currently only available for Maven projects. |
To configure Stork:
-
Create the configuration: Define a
src/etc/stork/stork.ymlfile.
# Application name (no spaces)
name: "${project.artifactId}"
display_name: "${project.name}"
# Type of launcher (CONSOLE or DAEMON)
type: DAEMON
main_class: "${application.class}"
# Platforms to generate (LINUX, WINDOWS, MAC_OSX)
platforms: [ LINUX ]
# Directory mode: RETAIN (current) or APP_HOME (switch to app root)
working_dir_mode: RETAIN
# Runtime Requirements
min_java_version: "17"
min_java_memory: 512
max_java_memory: 512
# Create a symbolic link to java as "<app_name>-java" for easier process tracking
symlink_java: true
-
Add the Maven Tiles plugin: Use the Jooby Stork tile to automate the build.
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.43</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.jooby:jooby-stork:4.2.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
-
Build the package: Run
mvn package. The resulting Stork.zipfile will be located in thetargetdirectory.