Skip to content

Commit

Permalink
doc: add jlink plugin documentation
Browse files Browse the repository at this point in the history
Add initial documentation for the jlink plugin.
  • Loading branch information
vpa1977 committed Jan 6, 2025
1 parent c12302c commit cf7a732
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions docs/common/craft-parts/reference/plugins/jlink_plugin.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
.. _craft_parts_jlink_plugin:

JLink plugin
=============

The JLink plugin can be used for Java projects where you would want to
deploy Java runtime specific for your application or install a minimal
Java runtime.


Keywords
--------

This plugin uses the common :ref:`plugin <part-properties-plugin>` keywords as
well as those for :ref:`sources <part-properties-sources>`.

Additionally, this plugin provides the plugin-specific keywords defined in the
following sections.

jlink-java-version
~~~~~~~~~~~~~~~~~~~
**Type:** str

Java package version to use for the build (e.g. 21 will install openjdk-21-jdk).

jlink-jars
~~~~~~~~~~~~~~~~~~
**Type:** list of strings

List of paths to jar files of your application. If not specified, plugin
will find all jar files in the staging area.

Dependencies
------------

By default this plugin uses openjdk-21-jdk from the build base.

The user is expected to stage openjdk dependencies either by installing
an appropriate openjdk slice:

.. code-block:: yaml
parts:
runtime:
plugin: jlink
after:
- deps
deps:
plugin: nil
stage-packages:
- openjdk-21-jre-headless_security
or by installing the dependencies directly:

.. code-block:: yaml
parts:
runtime:
plugin: jlink
after:
- deps
deps:
plugin: nil
stage-packages:
- libc6_libs
- libgcc-s1_libs
- libstdc++6_libs
- zlib1g_libs
- libnss3_libs
How it works
------------

During the build step, the plugin performs the following actions:

* Finds all jar files in the staging area or selects jars specified in
``jlink_jars``.
* Unpacks jar files to the temporary location and concatenates all embedded jars
into `jdeps <jdeps_>`_ classpath.
* Runs `jdeps <jdeps_>`_ to discover Java modules required for the staged jars.
* Runs `jlink <jlink_>`_ to create a runtime image from the build JDK.


.. _`jdeps`: https://docs.oracle.com/en/java/javase/21/docs/specs/man/jdeps.html
.. _`jlink`: https://docs.oracle.com/en/java/javase/21/docs/specs/man/jlink.html

0 comments on commit cf7a732

Please sign in to comment.