question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run Layrry on a custom runtime image

See original GitHub issue

Idea Outline

Motivation: https://twitter.com/AlmasBaim/status/1336685347795857409

Applications: Game A | Game B | ...
-- Layrry --
Custom Runtime Image: java.base, ..., javafx.base, ..., com.almas.fxgl.all, ..., + natives

Let Layrry run and manage applications on a prepared custom runtime image that provides a set of shared modules as system modules.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aalmiraycommented, Dec 10, 2020

Alright, so I did some investigation and I found the following:

  • built a custom jlink image with the following module descriptor (app is just a simple JavaFX app to test it works)
module app {
    exports app;
    requires javafx.base;
    requires javafx.graphics;
    requires javafx.controls;
    requires javafx.web;
    requires javafx.media;
    requires java.logging;
    requires jdk.jfr;
}
  • javafx.base = required by modular-tiles
  • javafx.graphics = required by modular-tiles
  • javafx.controls = required by modular-tiles
  • javafx.web = required by modular-tiles
  • javafx.media = required by modular-tiles
  • java.logging = required by mustache (layrry-config)
  • jdk.jfr = required by layrry (layrry-core)

Then ran latest Layrry against modular-tiles with the following configuration

[layers.core]
    modules = [
        "org.kordamp.tiles:modular-tiles-model:{{project_version}}",
        "org.kordamp.tiles:modular-tiles-core:{{project_version}}",
        "org.kordamp.tiles:modular-tiles-app:{{project_version}}",
        "org.moditect.layrry:layrry-platform:{{layrry_version}}",
        "eu.hansolo:tilesfx:{{tilesfx_version}}"]
[layers.plugins]
    parents = ["core"]
    directory = "plugins"
[main]
  module = "org.kordamp.tiles.app"
  class = "org.kordamp.tiles.app.Main"

And … it works! Which means all modules found in the image can be used by any layer. This means it’s possible to build a custom FXGL image and have it launch a layered application.

However, it has to be done by invoking the layrry-launcher JAR from the outside as this artifact is not yet modular, thus

/path/to/jlinked/image/bin/java -jar path/to/layrry-launcher-1.0-SNAPSHOT-all.jar \
  --layers-config staging/layers.toml \
  --properties staging/versions.properties

If Layrry were to be modularized (see #12) then the launcher could be embedded into the image and make it part of the main class, thus resulting in

/path/to/jlinked/image/bin/layrry-fxgl-base \
  --layers-config staging/layers.toml \
  --properties staging/versions.properties

This is great as once we have #37 ready we could launch apps from anywhere, such as

/path/to/jlinked/image/bin/layrry-fxgl-base \
  --layers-config https://server:port/path/to/layers.toml \
  --properties https://server:port/path/to/versions.properties

Or implementing the “capsule”* deployment approach (a capsule contains the layers config file plus all required external JARs, packaged using either flat or default repo format)

/path/to/jlinked/image/bin/layrry-fxgl-base --capsule https://server:port/path/to/app.lar

note: Assuming the capsule launcher is built of course, currently only a wild idea.

1reaction
aalmiraycommented, Dec 9, 2020

Adding @AlmasB

For this to work the Layrry API would have to support defining module ids as inputs in its configuration. Right now only Maven coordinates are allowed, for example

[layers.javafx]
    modules = [
        "org.openjfx:javafx-base:jar:{{os.detected.jfxname}}:{{javafx_version}}",
        "org.openjfx:javafx-controls:jar:{{os.detected.jfxname}}:{{javafx_version}}",
        "org.openjfx:javafx-graphics:jar:{{os.detected.jfxname}}:{{javafx_version}}",
        "org.openjfx:javafx-web:jar:{{os.detected.jfxname}}:{{javafx_version}}",
        "org.openjfx:javafx-media:jar:{{os.detected.jfxname}}:{{javafx_version}}"]
[layers.core]
    modules = [
        "org.kordamp.tiles:modular-tiles-model:{{project_version}}",
        "org.kordamp.tiles:modular-tiles-core:{{project_version}}",
        "org.kordamp.tiles:modular-tiles-app:{{project_version}}",
        "org.moditect.layrry:layrry-platform:{{layrry_version}}",
        "eu.hansolo:tilesfx:{{tilesfx_version}}"]
    parents = ["javafx"]
[layers.plugins]
    parents = ["core"]
    directory = "plugins"
[main]
  module = "org.kordamp.tiles.app"
  class = "org.kordamp.tiles.app.Main"

Assuming there was a base jlink image with JavaFX modules then the previous example could be rewritten as

[layers.javafx]
    modules = [
        "javafx.base",
        "javafx.controls",
        "javafx.graphics",
        "javafx.web",
        "javafx.media"]
[layers.core]
    modules = [
        "org.kordamp.tiles:modular-tiles-model:{{project_version}}",
        "org.kordamp.tiles:modular-tiles-core:{{project_version}}",
        "org.kordamp.tiles:modular-tiles-app:{{project_version}}",
        "org.moditect.layrry:layrry-platform:{{layrry_version}}",
        "eu.hansolo:tilesfx:{{tilesfx_version}}"]
    parents = ["javafx"]
[layers.plugins]
    parents = ["core"]
    directory = "plugins"
[main]
  module = "org.kordamp.tiles.app"
  class = "org.kordamp.tiles.app.Main"
Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaFX 11+ jlink: Modular Runtime Image - YouTube
We build a modular runtime image of a JavaFX application using the JavaFX Maven plugin, available at: ...
Read more >
Creating Custom JDK9 Runtime Images - YouTube
This video runs through a simple example of how to utilize a new feature with the upcoming JDK9 release: the ability to create...
Read more >
Create a custom runtime image with jlink #19 - fonoster/routr
The following steps can be used to create a custom run-time image: Get the jmods list for the server's dependency with $JAVA_HOME/bin/jdeps --list-deps ......
Read more >
What Is a Custom Runtime Image in Java 9? - Developer.com
It opens the door for a custom built application right from the platform on which it runs. The Java platform has increasing its...
Read more >
Creating custom runtime image dedicated for specific modular ...
I have their modular JAR files in some bin directory. And I want to prepare lightweight JRE to run it. So obviously, I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found