From a5b5df7cdcb1849d8c547546216fb963c336aebe Mon Sep 17 00:00:00 2001 From: Eric Haag Date: Thu, 24 Oct 2024 12:25:03 -0500 Subject: [PATCH 1/2] Allow Develocity CI injection repository to be used as an included build --- build.gradle.kts | 5 ++++- settings.gradle.kts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 90489151..931361eb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -68,9 +68,12 @@ allprojects { } val argbash by configurations.creating -val develocityInjection = configurations.dependencyScope("develocityInjection").get() +val develocityInjection = configurations.dependencyScope("develocityInjection") { + attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named("develocity-injection-script")) +}.get() val develocityInjectionResolvable = configurations.resolvable("${develocityInjection.name}Resolvable") { extendsFrom(develocityInjection) + attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named("develocity-injection-script")) } val develocityComponents by configurations.creating { attributes.attribute( diff --git a/settings.gradle.kts b/settings.gradle.kts index ef2c2361..07658fe6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,3 +29,12 @@ rootProject.name = "build-validation-scripts" include("components/configure-gradle-enterprise-maven-extension") project(":components/configure-gradle-enterprise-maven-extension").name = "configure-gradle-enterprise-maven-extension" + +val develocityCiInjectionProjectDir = providers.gradleProperty("develocityCiInjectionProjectDir") +if (develocityCiInjectionProjectDir.isPresent) { + includeBuild(develocityCiInjectionProjectDir) { + dependencySubstitution { + substitute(module("com.gradle:develocity-injection")).using(project(":")) + } + } +} From 8be122977d8f86ac263a427e2d6caf6c4fd78306 Mon Sep 17 00:00:00 2001 From: Eric Haag Date: Thu, 24 Oct 2024 12:27:55 -0500 Subject: [PATCH 2/2] Rely on Develocity injection script to configure server URL --- build.gradle.kts | 2 +- .../configure-build-validation.gradle | 25 ------------------- components/scripts/lib/gradle.sh | 5 ++-- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 931361eb..ae234547 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -87,7 +87,7 @@ val develocityMavenComponents by configurations.creating dependencies { argbash("argbash:argbash:2.10.0@zip") - develocityInjection("com.gradle:develocity-injection:1.0") + develocityInjection("com.gradle:develocity-injection:1.1") develocityComponents("com.gradle:build-scan-summary:$buildScanSummaryVersion") develocityMavenComponents("com.gradle:gradle-enterprise-maven-extension:1.18.4") mavenComponents(project(path = ":configure-gradle-enterprise-maven-extension", configuration = "shadow")) diff --git a/components/scripts/gradle/gradle-init-scripts/configure-build-validation.gradle b/components/scripts/gradle/gradle-init-scripts/configure-build-validation.gradle index 372b8db6..24b1e84b 100644 --- a/components/scripts/gradle/gradle-init-scripts/configure-build-validation.gradle +++ b/components/scripts/gradle/gradle-init-scripts/configure-build-validation.gradle @@ -17,9 +17,6 @@ def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise' def DEVELOCITY_PLUGIN_ID = 'com.gradle.develocity' def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin' -def develocityUrl = getInputParam('develocity.build-validation.url') -def develocityAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.build-validation.allow-untrusted-server')) - def expDir = getInputParam('develocity.build-validation.expDir') def expId = getInputParam('develocity.build-validation.expId') def runId = getInputParam('develocity.build-validation.runId') @@ -113,12 +110,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) { pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) { // only execute if Develocity plugin isn't applied if (pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) return - - if (develocityUrl) { - buildScan.server = develocityUrl - buildScan.allowUntrustedServer = develocityAllowUntrustedServer - } - if (!buildScan.server) { failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/legacy#gradle_5_x_2') } @@ -129,11 +120,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) { } pluginManager.withPlugin(DEVELOCITY_PLUGIN_ID) { - if (develocityUrl) { - develocity.server = develocityUrl - develocity.allowUntrustedServer = develocityAllowUntrustedServer - } - if (!develocity.server.present) { develocity.buildScan.publishing.onlyIf { false } // prevent publishing to scans.gradle.com failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/current/#connecting_to_develocity') @@ -157,12 +143,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) { settings.pluginManager.withPlugin(GRADLE_ENTERPRISE_PLUGIN_ID) { // only execute if Develocity plugin isn't applied if (settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) return - - if (develocityUrl) { - settings.gradleEnterprise.server = develocityUrl - settings.gradleEnterprise.allowUntrustedServer = develocityAllowUntrustedServer - } - if (!settings.gradleEnterprise.server) { failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/legacy/#gradle_6_x_and_later_2') } @@ -173,11 +153,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) { } settings.pluginManager.withPlugin(DEVELOCITY_PLUGIN_ID) { - if (develocityUrl) { - settings.develocity.server = develocityUrl - settings.develocity.allowUntrustedServer = develocityAllowUntrustedServer - } - if (!settings.develocity.server.present) { settings.develocity.buildScan.publishing.onlyIf { false } // prevent publishing to scans.gradle.com failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/current/#connecting_to_develocity') diff --git a/components/scripts/lib/gradle.sh b/components/scripts/lib/gradle.sh index f9c60721..2adf808d 100644 --- a/components/scripts/lib/gradle.sh +++ b/components/scripts/lib/gradle.sh @@ -29,8 +29,9 @@ invoke_gradle() { if [ -n "${ge_server}" ]; then args+=( - -Ddevelocity.build-validation.url="${ge_server}" - -Ddevelocity.build-validation.allow-untrusted-server=false + -Ddevelocity.url="${ge_server}" + -Ddevelocity.enforce-url=true + -Ddevelocity.allow-untrusted-server=false ) fi