From d919ba71ea4c3b1e60f2d21473ba31ff0f6857ab Mon Sep 17 00:00:00 2001 From: Marc Philipp Date: Sun, 14 Jan 2024 10:38:38 +0100 Subject: [PATCH] Namespace user-specific build parameters --- .github/workflows/cross-version.yml | 2 +- .github/workflows/main.yml | 2 +- .../plugins/build-parameters/build.gradle.kts | 49 ++++++++++--------- .../junitbuild.testing-conventions.gradle.kts | 8 +-- settings.gradle.kts | 7 +-- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.github/workflows/cross-version.yml b/.github/workflows/cross-version.yml index 0d966923433..125b051d008 100644 --- a/.github/workflows/cross-version.yml +++ b/.github/workflows/cross-version.yml @@ -10,7 +10,7 @@ on: - '*' env: - DEVELOCITY_TESTDISTRIBUTION_ENABLED: true + JUNIT_DEVELOCITY_TESTDISTRIBUTION_ENABLED: true GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} jobs: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 838012b38d2..7a449b0c697 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ on: - '*' env: - DEVELOCITY_TESTDISTRIBUTION_ENABLED: true + JUNIT_DEVELOCITY_TESTDISTRIBUTION_ENABLED: true GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} jobs: diff --git a/gradle/plugins/build-parameters/build.gradle.kts b/gradle/plugins/build-parameters/build.gradle.kts index 529976b3c01..3a1f95263c7 100644 --- a/gradle/plugins/build-parameters/build.gradle.kts +++ b/gradle/plugins/build-parameters/build.gradle.kts @@ -14,11 +14,6 @@ buildParameters { integer("javaToolchainVersion") { description = "Defines the Java toolchain version to use for compiling code" } - group("buildCache") { - string("server") { - description = "Remote build cache server address (protocol and hostname), e.g. https://eu-build-cache-ge.junit.org" - } - } group("documentation") { description = "Parameters controlling how the documentation is built" bool("replaceCurrentDocs") { @@ -26,26 +21,34 @@ buildParameters { defaultValue = false } } - group("develocity") { - description = "Parameters controlling Gradle Enterprise features" - group("predictiveTestSelection") { - bool("enabled") { - description = "Whether or not to use Predictive Test Selection for selecting tests to execute" - defaultValue = true - } - } - group("testDistribution") { - bool("enabled") { - description = "Whether or not to use Test Distribution for executing tests" - defaultValue = false - fromEnvironment() + group("junit") { + group("develocity") { + description = "Parameters controlling Develocity features" + group("buildCache") { + string("server") { + description = + "Remote build cache server address (protocol and hostname), e.g. https://eu-build-cache-ge.junit.org" + } } - integer("maxLocalExecutors") { - description = "How many local executors to use for executing tests" - defaultValue = 1 + group("predictiveTestSelection") { + bool("enabled") { + description = "Whether or not to use Predictive Test Selection for selecting tests to execute" + defaultValue = true + } } - integer("maxRemoteExecutors") { - description = "How many remote executors to request for executing tests" + group("testDistribution") { + bool("enabled") { + description = "Whether or not to use Test Distribution for executing tests" + defaultValue = false + fromEnvironment() + } + integer("maxLocalExecutors") { + description = "How many local executors to use for executing tests" + defaultValue = 1 + } + integer("maxRemoteExecutors") { + description = "How many remote executors to request for executing tests" + } } } } diff --git a/gradle/plugins/common/src/main/kotlin/junitbuild.testing-conventions.gradle.kts b/gradle/plugins/common/src/main/kotlin/junitbuild.testing-conventions.gradle.kts index e0edfb317ef..9a969dec236 100644 --- a/gradle/plugins/common/src/main/kotlin/junitbuild.testing-conventions.gradle.kts +++ b/gradle/plugins/common/src/main/kotlin/junitbuild.testing-conventions.gradle.kts @@ -22,9 +22,9 @@ tasks.withType().configureEach { maxRetries = buildParameters.testing.retries.orElse(if (buildParameters.ci) 2 else 0) } distribution { - enabled.convention(buildParameters.develocity.testDistribution.enabled && (!buildParameters.ci || System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY").isNotBlank())) - maxLocalExecutors = buildParameters.develocity.testDistribution.maxLocalExecutors - maxRemoteExecutors = buildParameters.develocity.testDistribution.maxRemoteExecutors + enabled.convention(buildParameters.junit.develocity.testDistribution.enabled && (!buildParameters.ci || System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY").isNotBlank())) + maxLocalExecutors = buildParameters.junit.develocity.testDistribution.maxLocalExecutors + maxRemoteExecutors = buildParameters.junit.develocity.testDistribution.maxRemoteExecutors if (buildParameters.ci) { when { OperatingSystem.current().isLinux -> requirements.add("os=linux") @@ -34,7 +34,7 @@ tasks.withType().configureEach { } } predictiveSelection { - enabled = buildParameters.develocity.predictiveTestSelection.enabled + enabled = buildParameters.junit.develocity.predictiveTestSelection.enabled // Ensure PTS works when publishing Build Scans to scans.gradle.com this as PredictiveTestSelectionExtensionInternal diff --git a/settings.gradle.kts b/settings.gradle.kts index 25bb18fd4d0..9c9c22a202e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -52,7 +52,7 @@ gradleEnterprise { } } - if (buildParameters.develocity.testDistribution.enabled) { + if (buildParameters.junit.develocity.testDistribution.enabled) { tag("test-distribution") } } @@ -62,15 +62,16 @@ buildCache { local { isEnabled = !buildParameters.ci } + val buildCacheServer = buildParameters.junit.develocity.buildCache.server if (useDevelocityInstance) { remote(gradleEnterprise.buildCache) { - server = buildParameters.buildCache.server.orNull + server = buildCacheServer.orNull val authenticated = System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY") != null isPush = buildParameters.ci && authenticated } } else { remote { - url = uri(buildParameters.buildCache.server.getOrElse(develocityServer)).resolve("/cache/") + url = uri(buildCacheServer.getOrElse(develocityServer)).resolve("/cache/") } } }