Skip to content

Commit d69ec7d

Browse files
authored
Merge pull request #672 from gradle/erichaagdev/enforce-url
Common Develocity injection script is used when setting Develocity server URL
2 parents dad0a0e + 8be1229 commit d69ec7d

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

build.gradle.kts

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ allprojects {
6868
}
6969

7070
val argbash by configurations.creating
71-
val develocityInjection = configurations.dependencyScope("develocityInjection").get()
71+
val develocityInjection = configurations.dependencyScope("develocityInjection") {
72+
attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named("develocity-injection-script"))
73+
}.get()
7274
val develocityInjectionResolvable = configurations.resolvable("${develocityInjection.name}Resolvable") {
7375
extendsFrom(develocityInjection)
76+
attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named("develocity-injection-script"))
7477
}
7578
val develocityComponents by configurations.creating {
7679
attributes.attribute(
@@ -84,7 +87,7 @@ val develocityMavenComponents by configurations.creating
8487

8588
dependencies {
8689
argbash("argbash:argbash:2.10.0@zip")
87-
develocityInjection("com.gradle:develocity-injection:1.0")
90+
develocityInjection("com.gradle:develocity-injection:1.1")
8891
develocityComponents("com.gradle:build-scan-summary:$buildScanSummaryVersion")
8992
develocityMavenComponents("com.gradle:gradle-enterprise-maven-extension:1.18.4")
9093
mavenComponents(project(path = ":configure-gradle-enterprise-maven-extension", configuration = "shadow"))

components/scripts/gradle/gradle-init-scripts/configure-build-validation.gradle

-25
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
1717
def DEVELOCITY_PLUGIN_ID = 'com.gradle.develocity'
1818
def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin'
1919

20-
def develocityUrl = getInputParam('develocity.build-validation.url')
21-
def develocityAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.build-validation.allow-untrusted-server'))
22-
2320
def expDir = getInputParam('develocity.build-validation.expDir')
2421
def expId = getInputParam('develocity.build-validation.expId')
2522
def runId = getInputParam('develocity.build-validation.runId')
@@ -113,12 +110,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
113110
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
114111
// only execute if Develocity plugin isn't applied
115112
if (pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) return
116-
117-
if (develocityUrl) {
118-
buildScan.server = develocityUrl
119-
buildScan.allowUntrustedServer = develocityAllowUntrustedServer
120-
}
121-
122113
if (!buildScan.server) {
123114
failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/legacy#gradle_5_x_2')
124115
}
@@ -129,11 +120,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
129120
}
130121

131122
pluginManager.withPlugin(DEVELOCITY_PLUGIN_ID) {
132-
if (develocityUrl) {
133-
develocity.server = develocityUrl
134-
develocity.allowUntrustedServer = develocityAllowUntrustedServer
135-
}
136-
137123
if (!develocity.server.present) {
138124
develocity.buildScan.publishing.onlyIf { false } // prevent publishing to scans.gradle.com
139125
failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/current/#connecting_to_develocity')
@@ -157,12 +143,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
157143
settings.pluginManager.withPlugin(GRADLE_ENTERPRISE_PLUGIN_ID) {
158144
// only execute if Develocity plugin isn't applied
159145
if (settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) return
160-
161-
if (develocityUrl) {
162-
settings.gradleEnterprise.server = develocityUrl
163-
settings.gradleEnterprise.allowUntrustedServer = develocityAllowUntrustedServer
164-
}
165-
166146
if (!settings.gradleEnterprise.server) {
167147
failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/legacy/#gradle_6_x_and_later_2')
168148
}
@@ -173,11 +153,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
173153
}
174154

175155
settings.pluginManager.withPlugin(DEVELOCITY_PLUGIN_ID) {
176-
if (develocityUrl) {
177-
settings.develocity.server = develocityUrl
178-
settings.develocity.allowUntrustedServer = develocityAllowUntrustedServer
179-
}
180-
181156
if (!settings.develocity.server.present) {
182157
settings.develocity.buildScan.publishing.onlyIf { false } // prevent publishing to scans.gradle.com
183158
failMissingDevelocityServerURL('https://docs.gradle.com/develocity/gradle-plugin/current/#connecting_to_develocity')

components/scripts/lib/gradle.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ invoke_gradle() {
2929

3030
if [ -n "${ge_server}" ]; then
3131
args+=(
32-
-Ddevelocity.build-validation.url="${ge_server}"
33-
-Ddevelocity.build-validation.allow-untrusted-server=false
32+
-Ddevelocity.url="${ge_server}"
33+
-Ddevelocity.enforce-url=true
34+
-Ddevelocity.allow-untrusted-server=false
3435
)
3536
fi
3637

settings.gradle.kts

+9
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,12 @@ rootProject.name = "build-validation-scripts"
2929
include("components/configure-gradle-enterprise-maven-extension")
3030

3131
project(":components/configure-gradle-enterprise-maven-extension").name = "configure-gradle-enterprise-maven-extension"
32+
33+
val develocityCiInjectionProjectDir = providers.gradleProperty("develocityCiInjectionProjectDir")
34+
if (develocityCiInjectionProjectDir.isPresent) {
35+
includeBuild(develocityCiInjectionProjectDir) {
36+
dependencySubstitution {
37+
substitute(module("com.gradle:develocity-injection")).using(project(":"))
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)