-
How can I stop passing a specific flag to jlink (specifically avoid passing My app needs to bundle java executables because my app needs to launch another java process from my app. It looks like I'm able to add a flag to jlink by https://conveyor.hydraulic.dev/12.0/configs/jvm/#appjvmjlink-flags, but is it possible to stop passing a specific flag? After the
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
Unfortunately that's not possible in current versions of Conveyor, the list of base flags is hard coded. What you could do is just change your main() method to forward to the right entry point based on flag or env var, optionally using a classloader if the sub-program conflicts with the classes of the main program. |
Beta Was this translation helpful? Give feedback.
-
I have a similar use case where I need to launch various secondary apps from my main application (e.g. I need to decouple the GC of a real-time UI from an offline file viewer). I solved it by adding additional launchers to Conveyor and launching them with the process API: extra executable: app.jvm.cli.myOtherApp {
main-class=some.other.App
console = false;
} Finding the directory of the executable: /**
* @return path to directory with executables or empty if not inside conveyor
*/
public static Optional<Path> getBinDirectory() {
return Optional.ofNullable(System.getProperty("app.dir"))
.map(Paths::get)
.map(Path::toAbsolutePath)
.map(p -> p.resolve(getRelativeBinPath()))
.map(Path::normalize);
}
private static String getRelativeBinPath() {
if (OS.isWindows()) {
return "../bin/";
} else if (OS.isMac()) {
return "../MacOS/";
} else if (OS.isUnix()) {
return "../../bin/";
} else {
throw new UnsupportedOperationException("unknown OS: " + System.getProperty("os.name"));
}
} That approach is also safer because users could use |
Beta Was this translation helpful? Give feedback.
-
Thanks both! Although it's unfortunate that Conveyor doesn't support modifying the default flags passed to jlink, I'll see if @ennerf 's suggestion works with my use case. My use case is to run a gradle process with JAVA_HOME set to the directory where java executable is located. Thus, it might be a different use case, though. |
Beta Was this translation helpful? Give feedback.
-
Bear in mind that Conveyor will attempt to shrink the bundled Java, and it also does various other things designed for desktop app distribution in the code signing context. It sounds like what you're after is really just downloading a full blown JDK and then be able to point Gradle at it. |
Beta Was this translation helpful? Give feedback.
-
Yes, that's true, but I believe it's a legit use case for apps like IDEs given that jlink has an option to toggle if the executables are included in the bundle (--strip-native-commands). And the impact of the app size seems to be negligible. When I compared the sizes of the apps between with/without stripNativeCommands flag to jlink using Compose Multiplatform plugin, the app size looked like:
Also JFYI there is a similar feature request to Compose Multiplatform at https://youtrack.jetbrains.com/issue/CMP-3946 (the previous comparison was made by using the same workaround in the link) |
Beta Was this translation helpful? Give feedback.
-
The issue is the CMP plugin isn't optimizing download size :) Try a small simple app in Conveyor and you'll find it's much smaller than 263MB because it identifies which modules you're using and removes the rest. You can disable that, though. |
Beta Was this translation helpful? Give feedback.
-
The experiment in my previous post was not a starter project created from scratch. Anyway, since including java executables in the bundle is one of our core functionalities, unfortunately it seems I need to figure out other way of distributing our app although the other parts were working greatly. Thanks for your support! |
Beta Was this translation helpful? Give feedback.
I have a similar use case where I need to launch various secondary apps from my main application (e.g. I need to decouple the GC of a real-time UI from an offline file viewer). I solved it by adding additional launchers to Conveyor and launching them with the process API:
extra executable:
Finding the directory of the executable: