From 9ceb8711531b1db831b92fd4e33a88ba547d5c91 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Tue, 2 May 2023 12:10:32 +0200 Subject: [PATCH] Build/CI: pass `test.log.level` via `CommandLineArgumentProvider` and populate quarkus console log level Allows passing for example `-Dtest.log.level=DEBUG` on the Gradle command line and all relevant logging configs use this value as well. Using a `CommandLineArgumentProvider` prevents the log-level setting from influencing the Gradle cache. --- buildSrc/src/main/kotlin/Testing.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/Testing.kt b/buildSrc/src/main/kotlin/Testing.kt index ee936cad523..58e8aad7418 100644 --- a/buildSrc/src/main/kotlin/Testing.kt +++ b/buildSrc/src/main/kotlin/Testing.kt @@ -33,6 +33,7 @@ import org.gradle.kotlin.dsl.named import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.register import org.gradle.kotlin.dsl.withType +import org.gradle.process.CommandLineArgumentProvider import org.gradle.testing.base.TestingExtension class NessieTestingPlugin : Plugin { @@ -100,15 +101,23 @@ class NessieTestingPlugin : Plugin { systemProperty("user.language", "en") systemProperty("user.country", "US") systemProperty("user.variant", "") - systemProperty("test.log.level", testLogLevel()) + jvmArgumentProviders.add( + CommandLineArgumentProvider { listOf("-Dtest.log.level=${testLogLevel()}") } + ) environment("TESTCONTAINERS_REUSE_ENABLE", "true") if (plugins.hasPlugin("io.quarkus")) { jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED") // Log-levels are required to be able to parse the HTTP listen URL - systemProperty("quarkus.log.level", "INFO") - systemProperty("quarkus.log.console.level", "INFO") - systemProperty("http.access.log.level", testLogLevel()) + jvmArgumentProviders.add( + CommandLineArgumentProvider { + listOf( + "-Dquarkus.log.level=${testLogLevel()}", + "-Dquarkus.log.console.level=${testLogLevel()}", + "-Dhttp.access.log.level=${testLogLevel()}" + ) + } + ) minHeapSize = if (testHeapSize != null) testHeapSize as String else "512m" maxHeapSize = if (testHeapSize != null) testHeapSize as String else "1536m"