From 32bb209d6559040fba386af980c561c70384f823 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Tue, 23 Jul 2024 18:17:06 +0200 Subject: [PATCH] Native image fixes (required for Java 22) (#9028) - initialize features at build time (used to discover features that do not support AOT) - initialize logging at build time (used explicitly to be able to log) Fixed a few problems in Quickstart that I used to test this --- .../native-image.properties | 18 ++++++++++++++++++ .../quickstarts/helidon-quickstart-se/pom.xml | 5 +++++ .../src/main/resources/logging.properties | 6 +++--- .../native-image.properties | 19 +++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 common/features/features/src/main/resources/META-INF/native-image/io.helidon.common.features/helidon-common-features/native-image.properties create mode 100644 logging/common/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-common/native-image.properties diff --git a/common/features/features/src/main/resources/META-INF/native-image/io.helidon.common.features/helidon-common-features/native-image.properties b/common/features/features/src/main/resources/META-INF/native-image/io.helidon.common.features/helidon-common-features/native-image.properties new file mode 100644 index 00000000000..9e70fbb16f9 --- /dev/null +++ b/common/features/features/src/main/resources/META-INF/native-image/io.helidon.common.features/helidon-common-features/native-image.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Needed at build time, as we validate all used features are usable with native-image +Args=--initialize-at-build-time=io.helidon.common.features diff --git a/examples/quickstarts/helidon-quickstart-se/pom.xml b/examples/quickstarts/helidon-quickstart-se/pom.xml index 35568184eca..2011b6b974c 100644 --- a/examples/quickstarts/helidon-quickstart-se/pom.xml +++ b/examples/quickstarts/helidon-quickstart-se/pom.xml @@ -73,6 +73,11 @@ jakarta.json jakarta.json-api + + io.helidon.logging + helidon-logging-jul + runtime + org.junit.jupiter junit-jupiter-api diff --git a/examples/quickstarts/helidon-quickstart-se/src/main/resources/logging.properties b/examples/quickstarts/helidon-quickstart-se/src/main/resources/logging.properties index 175767778e7..51d343b5df1 100644 --- a/examples/quickstarts/helidon-quickstart-se/src/main/resources/logging.properties +++ b/examples/quickstarts/helidon-quickstart-se/src/main/resources/logging.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Oracle and/or its affiliates. +# Copyright (c) 2023, 2024 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ # limitations under the License. # -handlers=java.util.logging.ConsoleHandler -java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS.%1$tL %5$s%6$s%n +handlers=io.helidon.logging.jul.HelidonConsoleHandler +java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$s %5$s%6$s%n # Global logging level. Can be overridden by specific loggers .level=INFO diff --git a/logging/common/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-common/native-image.properties b/logging/common/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-common/native-image.properties new file mode 100644 index 00000000000..409e7f78f08 --- /dev/null +++ b/logging/common/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-common/native-image.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Logging is used from our native image extension, as we need to correctly initialize it both at build time +# and at run time +Args=--initialize-at-build-time=io.helidon.logging