Skip to content

Commit

Permalink
Build/CI: pass test.log.level via CommandLineArgumentProvider and…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
snazy committed May 2, 2023
1 parent ef9f726 commit 9ceb871
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions buildSrc/src/main/kotlin/Testing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Project> {
Expand Down Expand Up @@ -100,15 +101,23 @@ class NessieTestingPlugin : Plugin<Project> {
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"
Expand Down

0 comments on commit 9ceb871

Please sign in to comment.