Jlink

Creates a Java Runtime image using Jlink.

Cross platform Java runtime images may be created however you must ensure that all configured JDKs have the same matching major version.
You have to install additional JDKs to enable cross-platform images. JReleaser will not install these JDKS for you. You may configure the JDKs Maven Plugin or the JDKs Gradle Plugin to downloads JDKS.

Legend:

  • required

  • optional

  • may use environment variable

  • accepts Name Templates

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

# 
assemble:
  # 
  jlink:
    # Assemblers require a name.
    # 
    app:

      # Enables or disables the assembler.
      # Valid 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

      # Name of the executable launcher.
      # If left undefined, will use ${assembler.name}.
      # 
      executable: app

      # Directory with file templates used to prepare the Jlink assembler.
      # Defaults to `src/jreleaser/assemblers/${distribution.name}/jlink`.
      # If specified, path must exist.
      # 
      templateDirectory: path/to/jlink/templates

      # Name of the generated image.
      # If left undefined, will use
      # ${project.java.groupId}.${project.java.artifactId}.${project.version}.
      # Generated artifacts always have the platform as suffix.
      #  
      imageName: 'app-{{projectVersion}}'

      # Name transformation of the generated image.
      # Transformed artifacts always have the platform as suffix.
      #  
      imageNameTransform: 'app-{{projectEffectiveVersion}}'

      # Name of main module (if any).
      # Define only if the application is modular.
      # 
      moduleName: com.acme.demo

      # List of module names.
      # Define only if jdeps can't find all required modules.
      # 
      moduleNames:
        - java.base
        - com.acme.demo

      # List of JDKs for generating cross-platform images.
      #  
      targetJdks:
        - path: path/to/jdk
          platform: osx
        - path: path/to/jdk
          platform: linux

      # The JDK to use.
      # If undefined, will use the current JDK running JReleaser.
      #  
      jdk:
        path: path/to/jdk
        platform: linux

      # A list of build arguments.
      # Defaults are shown.
      # 
      args:
        - "--no-header-files"
        - "--no-man-pages"
        - "--compress=2"
        - "--strip-debug"

      # 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

      # 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

      # Additional properties used when evaluating templates.
      #  
      extraProperties:
        # Key will be capitalized and prefixed with `jlink`, i.e, `jlinkFoo`.
        foo: bar

      # 
      java:
        # Maven coordinates: groupId.
        # If left undefined, will use ${project.java.groupId}.
        # 
        groupId: com.acme

        # Maven coordinates: artifactId.
        # If left undefined, will use ${project.java.artifactId}.
        # 
        artifactId: app

        # The minimum Java version required by consumers to run the application.
        # If left undefined, will use ${project.java.version}.
        # 
        version: 8

        # The application's entry point.
        # If left undefined, will use ${project.java.mainClass}.
        # 
        mainClass: com.acme.Main

        # Identifies the project as being member of a multi-project build.
        # If left undefined, will use ${project.java.multiProject}.
        # 
        multiProject: false

        # Additional properties used when evaluating templates.
        # 
        extraProperties:
          # Key will be capitalized and prefixed with `java`, i.e, `javaFoo`.
          foo: bar
# Assemblers require a name.
# 
[assemble.jlink.app]

  # Enables or disables the assembler.
  # Valid 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

  # Name of the executable launcher.
  # If left undefined, will use ${assembler.name}.
  # 
  executable = "app"

  # Directory with file templates used to prepare the Jlink assembler.
  # Defaults to `src/jreleaser/assemblers/${distribution.name}/jlink`.
  # If specified, path must exist.
  # 
  templateDirectory = "path/to/jlink/templates"

  # Name of the generated image.
  # If left undefined, will use
  # ${project.java.groupId}.${project.java.artifactId}.${project.version}.
  # Generated artifacts always have the platform as suffix.
  #  
  imageName = "app-{{projectVersion}}"

  # Name transformation of the generated image.
  # Transformed artifacts always have the platform as suffix.
  #  
  imageNameTransform = "app-{{projectEffectiveVersion}}"

  # Name of main module (if any).
  # Define only if the application is modular.
  # 
  moduleName = "com.acme.demo"

  # List of module names.
  # Define only if jdeps can't find all required modules.
  # 
  moduleName = [
    "java.base",
    "com.acme.demo"]

  # List of JDKs for generating cross-platform images.
  #  
  targetJdks = [
    { path = "path/to/jdk", platform = "osx" },
    { path = "path/to/jdk", platform = "linux" }]

  # The JDK to use.
  # If undefined, will use the current JDK running JReleaser.
  #  
  jdk = { path = "path/to/jdk", platform = "linux" }

  # A list of build arguments.
  # Defaults are shown
  # 
  args = ["--no-header-files",
    "--no-man-pages",
    "--compress=2",
    "--strip-debug"]

  # 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"

  # Defines a list of additional files as globs.
  # These files will be added to the assembled Zip file.
  # 
  [[assemble.jlink.app.files]]
    # The pattern to use.
    # May use glob or regex pattern syntax.
    #  
    pattern = "path/to/**/*.txt"

  # Additional properties used when evaluating templates.
  #  
  extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `jlink`, i.e, `jlinkFoo`.

  # Maven coordinates: groupId.
  # If left undefined, will use ${project.java.groupId}.
  # 
  java.groupId = "com.acme"

  # Maven coordinates: artifactId.
  # If left undefined, will use ${project.java.artifactId}.
  # 
  java.artifactId = "app"

  # The minimum Java version required by consumers to run the application.
  # If left undefined, will use ${project.java.version}.
  # 
  java.version = "8"

  # The application's entry point.
  # If left undefined, will use ${project.java.mainClass}.
  # 
  java.mainClass = "com.acme.Main"

  # Identifies the project as being member of a multi-project build.
  # If left undefined, will use ${project.java.multiProject}.
  # 
  java.multiProject = false

  # Additional properties used when evaluating templates.
  # 
  java.extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `java`, i.e, `javaFoo`.
{
  // 
  "assemble": {
    // 
    "jlink": {
      // Assemblers require a name.
      // 
      "app": {

        // Enables or disables the assembler.
        // Valid 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,

        // Name of the executable launcher.
        // If left undefined, will use ${assembler.name}.
        // 
        "executable": "app",

        // Directory with file templates used to prepare the Jlink assembler.
        // Defaults to `src/jreleaser/assemblers/${distribution.name}/jlink`.
        // If specified, path must exist.
        // 
        "templateDirectory": "path/to/jlink/templates",

        // Name of the generated image.
        // If left undefined, will use
        // ${project.java.groupId}.${project.java.artifactId}.${project.version}.
        // Generated artifacts always have the platform as suffix.
        //  
        "imageName": "app-{{projectVersion}}",

        // Name transformation of the generated image.
        // Transformed artifacts always have the platform as suffix.
        //  
        "imageNameTransform": "app-{{projectEffectiveVersion}}",

        // Name of main module (if any).
        // Define only if the application is modular.
        // 
        "moduleName": "com.acme.demo",

        // List of module names.
        // Define only if jdeps can't find all required modules.
        // 
        "moduleNames": [
           "java.base",
           "com.acme.demo"
         ],

        // List of JDKs for generating cross-platform images.
        //  
        "targetJdks": [
          {
            "path": "path/to/jdk",
            "platform": "osx"
          },
          {
            "path": "path/to/jdk",
            "platform": "linux"
          }
        ],

        // The JDK to use.
        // If undefined, will use the current JDK running JReleaser.
        //  
        "jdk": {
          "path": "path/to/jdk",
          "platform": "linux"
        },

        // A list of build arguments.
        // Defualts are shown.
        // 
        "args": [
          "--no-header-files",
          "--no-man-pages",
          "--compress=2",
          "--strip-debug"
        ],

        // 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"
          }
        ],

        // 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"
          }
        ],

        // Additional properties used when evaluating templates.
        //  
        "extraProperties": {
          // Key will be capitalized and prefixed with `jlink`, i.e, `jlinkFoo`.
          "foo": "bar"
        },

        // 
        "java": {
          // Maven coordinates: groupId.
          // If left undefined, will use ${project.java.groupId}.
          // 
          "groupId": "com.acme",

          // Maven coordinates: artifactId.
          // If left undefined, will use ${project.java.artifactId}.
          // 
          "artifactId": "app",

          // The minimum Java version required by consumers to run the application.
          // If left undefined, will use ${project.java.version}.
          // 
          "version": "8",

          // The application's entry point.
          // If left undefined, will use ${project.java.mainClass}.
          // 
          "mainClass": "com.acme.Main",

          // Identifies the project as being member of a multi-project build.
          // If left undefined, will use ${project.java.multiProject}.
          // 
          "multiProject": false,

          // Additional properties used when evaluating templates.
          // 
          "extraProperties": {
            // Key will be capitalized and prefixed with `java`, i.e, `javaFoo`.
            "foo": "bar"
          }
        }
      }
    }
  }
}
<jreleaser>
  <!--
    
  -->
  <assemble>
    <!--
      
    -->
    <jlink>
      <!--
        Assemblers require a name.
        
      -->
      <app>
        <!--
          Enables or disables the distribution.
          Valid 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>

        <!--
          Name of the executable launcher.
          If left undefined, will use ${distribution.name}.
          
        -->
        <executable>app</executable>

        <!--
          Directory with file templates used to prepare the Jlink assembler.
          Defaults to `src/jreleaser/assemblers/${distribution.name}/jlink`.
          If specified, path must exist.
          
        -->
        <templateDirectory>>path/to/brew/templates</templateDirectory>

        <!--
          Name of the generated image.
          If left undefined, will use
          ${project.java.groupId}.${project.java.artifactId}.${project.version}.
          Generated artifacts always have the platform as suffix.
           
        -->
        <imageName>app-{{projectVersion}}</imageName>

        <!--
          Name transformation of the generated image.
          Transformed artifacts always have the platform as suffix.
           
        -->
        <imageNameTransform>app</imageNameTransform>

        <!--
          Name of main module (if any).
          Define only if the application is modular.
          
        -->
        <moduleName>com.acme.demo</moduleName>

        <!--
          List of module names.
          Define only if jdeps can't find all required modules.
          
        -->
        <moduleNames>
          <moduleName>java.base</moduleName>
          <moduleName>com.acme.demo</moduleName>
        </moduleNames>

        <!--
          List of JDKs for generating cross-platform images.
           
        -->
        <targetJdks>
        <targetJdk>
          <path>path/to/jdk</path>
          <platform>osx</platform>
        </targetJdk>
        <targetJdk>
          <path>path/to/jdk</path>
          <platform>linux</platform>
        </targetJdk>
        </targetJdks>

        <!--
          The JDK to use.
          If undefined, will use the current JDK running JReleaser.
           
        -->
        <jdk>
          <path>path/to/jdk</path>
          <platform>linux</platform>
        </jdk>

        <!--
          The executable JAR that contains the application.
           
        -->
        <mainJar>
          <path>path/to/app.jar</path>
        </mainJar>

        <!--
          A list of build arguments.
          Defaults are shown.
          
        -->
        <args>
          <arg>--no-header-files</arg>
          <arg>--no-man-pages</arg>
          <arg>--compress=2</arg>
          <arg>--strip-debug</arg>
        </args>

        <!--
          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>

        <!--
          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>
          </jar>
          </file>
        </files>

        <!--
          Additional properties used when evaluating templates.
           
        -->
        <extraProperties>
          <!--
            Key will be capitalized and prefixed with `jlink`, i.e, `jlinkFoo`.
          -->
          <foo>bar</foo>
        </extraProperties>

        <!--
          
        -->
        <java>
          <!--
            Maven coordinates>groupId.
            If left undefined, will use ${project.java.groupId}.
            
          -->
          <groupId>com.acme</groupId>

          <!--
            Maven coordinates>artifactId.
            If left undefined, will use ${project.java.artifactId}.
            
          -->
          <artifactId>app</artifactId>

          <!--
            The minimum Java version required by consumers to run the application.
            If left undefined, will use ${project.java.version}.
            
          -->
          <version>8</version>

          <!--
            The application's entry point.
            If left undefined, will use ${project.java.mainClass}.
            
          -->
          <mainClass>com.acme.Main</mainClass>

          <!--
            Identifies the project as being member of a multi-project build.
            If left undefined, will use ${project.java.multiProject}.
            
          -->
          <multiProject>false</multiProject>

          <!--
            Additional properties used when evaluating templates.
            
          -->
          <extraProperties>
            <!--
              Key will be capitalized and prefixed with `java`, i.e, `javaFoo`.
            -->
            <foo>bar</foo>
          </extraProperties>
        </java>
      </app>
    </jlink>
  </assemble>
</jreleaser>
jreleaser {
  // 
  assemble {
    // 
    jlink {
      // Assemblers require a name.
      // 
      app {

        // Enables or disables the assembler.
        // Valid 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

        // Name of the executable launcher.
        // If left undefined, will use ${assembler.name}.
        // 
        executable = 'app'

        // Directory with file templates used to prepare the Jlink assembler.
        // Defaults to `src/jreleaser/assemblers/${distribution.name}/jlink`.
        // If specified, path must exist.
        // 
        templateDirectory = 'path/to/jlink/templates'

        // Name of the generated image.
        // If left undefined, will use
        // ${project.java.groupId}.${project.java.artifactId}.${project.version}.
        // Generated artifacts always have the platform as suffix.
        //  
        imageName = 'app-{{projectVersion}}'

        // Name transformation of the generated image.
        // Transformed artifacts always have the platform as suffix.
        //  
        imageNameTransform = 'app-{{projectEffectiveVersion}}'

        // Name of main module (if any).
        // Define only if the application is modular.
        // 
        moduleName = 'com.acme.demo'

        // List of module names.
        // Define only if jdeps can't find all required modules.
        // 
        moduleNames = [
            'java.base',
            'com.acme.demo'
        ]

        // List of JDKs for generating cross-platform images.
        //  
        targetJdk {
          pat = 'path/to/jdk'
          platform = 'osx'
        }
        targetJdk {
          pat = 'path/to/jdk'
          platform = 'linux'
        }

        // The JDK to use.
        // If undefined, will use the current JDK running JReleaser.
        //  
        jdk {
          path = 'path/to/jdk'
          platform = 'linux'
        }

        // A list of build arguments.
        // Defaults are shown.
        // 
        addArg('--install-exit-handlers')
        addArg('--no-header-files')
        addArg('--no-man-pages')
        addArg('--compress=2')
        addArg('--strip-debug')

        // 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'
        }

        // Defines a list of additional JARs 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'
        }

        // Additional properties used when evaluating templates.
        // Key will be capitalized and prefixed with `jlink`, i.e, `jlinkFoo`.
        //  
        extraProperties.put('foo', 'bar')

        // 
        java {
          // Maven coordinates = groupId.
          // If left undefined, will use ${project.java.groupId}.
          // 
          groupI = 'com.acme'

          // Maven coordinates = artifactId.
          // If left undefined, will use ${project.java.artifactId}.
          // 
          artifactId = 'app'

          // The minimum Java version required by consumers to run the application.
          // If left undefined, will use ${project.java.version}.
          // 
          version = '8'

          // The application's entry point.
          // If left undefined, will use ${project.java.mainClass}.
          // 
          mainClass = 'com.acme.Main'

          // Identifies the project as being member of a multi-project build.
          // If left undefined, will use ${project.java.multiProject}.
          // 
          multiProject = false

          // Additional properties used when evaluating templates.
          // Key will be capitalized and prefixed with `java`, i.e, `javaFoo`.
          // 
          extraProperties.put('foo', 'bar')
        }
      }
    }
  }
}