Skip to content

Commit

Permalink
678: register Severity enum for reflection so native app builds don't…
Browse files Browse the repository at this point in the history
… need to do this themselves
  • Loading branch information
Alan Boshier committed Sep 24, 2024
1 parent ab20595 commit b2fc6fa
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.quarkiverse.googlecloudservices.logging.deployment;

import java.util.ArrayList;
import java.util.List;

import io.quarkiverse.googlecloudservices.logging.runtime.LoggingConfiguration;
import io.quarkiverse.googlecloudservices.logging.runtime.TraceInfoExtractor;
import io.quarkiverse.googlecloudservices.logging.runtime.cdi.LoggingProducer;
Expand All @@ -11,6 +14,7 @@
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.LogHandlerBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;

public class LoggingBuildSteps {

Expand Down Expand Up @@ -38,4 +42,14 @@ public UnremovableBeanBuildItem helperClasses() {
public LogHandlerBuildItem handler(LoggingConfiguration config, LoggingHandlerFactory factory) {
return new LogHandlerBuildItem(factory.create(config));
}

@BuildStep
public List<ReflectiveClassBuildItem> registerReflectiveClasses() {
List<ReflectiveClassBuildItem> items = new ArrayList<>();
// Required for native builds as LoggingHandler uses Gson to serialize severity values
items.add(ReflectiveClassBuildItem.builder("com.google.cloud.logging.Severity")
.fields(true)
.build());
return items;
}
}

0 comments on commit b2fc6fa

Please sign in to comment.