From 22bf85df9d2e94c7d0ce4d51061c2e07334b8b8e Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Thu, 11 May 2023 17:08:27 -0400 Subject: [PATCH] fix(java): add native image configurations for logging-logback (#1075) * fix(java): add native image configurations for logging-logback * add exclusion to build script --- .kokoro/build.sh | 6 +-- owlbot.py | 1 + .../reflect-config.json | 52 +++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-logging-logback/reflect-config.json diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 1104d1e36..8deb35478 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -70,13 +70,13 @@ integration) RETURN_CODE=$? ;; graalvm) - # Run Unit and Integration Tests with Native Image - mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative test + # Run Unit and Integration Tests with Native Image. Skip tests that use mocking libs + mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative test "-Dtest=!LoggingAppenderTest" RETURN_CODE=$? ;; graalvm17) # Run Unit and Integration Tests with Native Image - mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative test + mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative test "-Dtest=!LoggingAppenderTest" RETURN_CODE=$? ;; samples) diff --git a/owlbot.py b/owlbot.py index 58368fdda..52797fb5e 100644 --- a/owlbot.py +++ b/owlbot.py @@ -25,6 +25,7 @@ 'CONTRIBUTING.md', '.github/auto-label.yaml', ".github/release-please.yml", + ".kokoro/build.sh" ]) # -------------------------------------------------------------------------- diff --git a/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-logging-logback/reflect-config.json b/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-logging-logback/reflect-config.json new file mode 100644 index 000000000..68b566d6e --- /dev/null +++ b/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-logging-logback/reflect-config.json @@ -0,0 +1,52 @@ +[ + { + "name":"ch.qos.logback.classic.Level", + "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] + }, + { + "name":"ch.qos.logback.classic.filter.ThresholdFilter", + "queryAllPublicMethods":true, + "methods":[ + {"name":"","parameterTypes":[] }, + {"name":"setLevel","parameterTypes":["java.lang.String"] } + ] + }, + { + "name":"ch.qos.logback.core.UnsynchronizedAppenderBase", + "methods":[{"name":"addFilter","parameterTypes":["ch.qos.logback.core.filter.Filter"] }] + }, + { + "name":"com.google.cloud.logging.logback.LogbackBatchingSettings", + "queryAllPublicMethods":true, + "methods":[ + {"name":"","parameterTypes":[] }, + {"name":"setDelayThreshold","parameterTypes":["java.lang.Long"] }, + {"name":"setElementCountThreshold","parameterTypes":["java.lang.Long"] }, + {"name":"setLimitExceededBehavior","parameterTypes":["com.google.api.gax.batching.FlowController$LimitExceededBehavior"] }, + {"name":"setMaxOutstandingElementCount","parameterTypes":["java.lang.Long"] }, + {"name":"setMaxOutstandingRequestBytes","parameterTypes":["java.lang.Long"] }, + {"name":"setRequestByteThreshold","parameterTypes":["java.lang.Long"] } + ] + }, + { + "name":"com.google.cloud.logging.logback.LoggingAppender", + "queryAllPublicMethods":true, + "methods":[ + {"name":"","parameterTypes":[] }, + {"name":"setAutoPopulateMetadata","parameterTypes":["boolean"] }, + {"name":"setCredentialsFile","parameterTypes":["java.lang.String"] }, + {"name":"setFlushLevel","parameterTypes":["ch.qos.logback.classic.Level"] }, + {"name":"setLog","parameterTypes":["java.lang.String"] }, + {"name":"setLogDestinationProjectId","parameterTypes":["java.lang.String"] }, + {"name":"setLogbackBatchingSettings","parameterTypes":["com.google.cloud.logging.logback.LogbackBatchingSettings"] }, + {"name":"setPartialSuccess","parameterTypes":["boolean"] }, + {"name":"setRedirectToStdout","parameterTypes":["boolean"] }, + {"name":"setResourceType","parameterTypes":["java.lang.String"] }, + {"name":"setWriteSynchronicity","parameterTypes":["com.google.cloud.logging.Synchronicity"] } + ] + }, + { + "name":"java.lang.Long", + "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] + } +]