From de637f83c22129dbb1e5db88a44c7d5840b16241 Mon Sep 17 00:00:00 2001 From: Phil Pinel <35564100+EdgewareRoad@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:25:21 +0100 Subject: [PATCH] Copy fonts from JVM lib folder, to attempt standalone behaviour --- build.gradle | 21 ++++++++++++++++--- .../trivysummary/TrivySummaryApp.java | 6 ++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 3251b3f..0e6b412 100644 --- a/build.gradle +++ b/build.gradle @@ -17,9 +17,6 @@ version = appProps.getProperty("trivysummary.version") def javaHome = System.properties['java.home'] -nativeCompile.dependsOn test -nativeTestCompile.dependsOn test - repositories { mavenCentral() } @@ -158,6 +155,24 @@ graalvmNative { } } +nativeCompile.dependsOn(test) +nativeTestCompile.dependsOn(test) + +task copyFontsToNativeCompile(dependsOn: nativeCompile, type: Copy) { + from javaHome + '/lib' + into "build/native/nativeCompile/lib" + include "*font*" +} + +task copyFontsToNativeTestCompile(dependsOn: nativeTestCompile, type: Copy) { + from javaHome + '/lib' + into "build/native/nativeTestCompile/lib" + include "*font*" +} + +nativeCompile.finalizedBy(copyFontsToNativeCompile) +nativeTestCompile.finalizedBy(copyFontsToNativeTestCompile) + // Publishing the output to GitHub (standard JAR, sources plus POM file, distribution ZIP) publishing { publications { diff --git a/src/main/java/com/fujitsu/edgewareroad/trivysummary/TrivySummaryApp.java b/src/main/java/com/fujitsu/edgewareroad/trivysummary/TrivySummaryApp.java index 1944ed7..e4430e1 100644 --- a/src/main/java/com/fujitsu/edgewareroad/trivysummary/TrivySummaryApp.java +++ b/src/main/java/com/fujitsu/edgewareroad/trivysummary/TrivySummaryApp.java @@ -37,6 +37,12 @@ public class TrivySummaryApp implements ApplicationRunner, ExitCodeGenerator { public static void main(String[] args) { // Suppress logging and banner output that otherwise we can't control System.setProperty("spring.main.banner-mode", "off"); + + if (System.getProperty("java.home") == null) + { + System.setProperty("java.home", TrivySummaryApp.class.getProtectionDomain().getCodeSource().getLocation().getPath()); + } + XRLog.setLoggerImpl(new Slf4jLogger()); System.exit(SpringApplication.exit(SpringApplication.run(TrivySummaryApp.class, args)));