Skip to content

Commit c0932e8

Browse files
committed
Delay GE server URL check for Gradle >=6
Now that we check in the shell scripts for the presence of the GE server url when instrumenting the build with GE, we should rarely get to the scenario where there is no server GE URL specified by the time the Gradle init script is invoked. In the case it happens, a buildFinished warning caused by the CCUD plugin will be shown on the cmd line but has no negative effect. This change makes it easier to reason about the code flow for different Gradle versions.
1 parent e8119b4 commit c0932e8

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

components/scripts/gradle/gradle-init-scripts/configure-gradle-enterprise.gradle

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
203203
if (geUrl) buildScan.server = geUrl
204204
if (geAllowUntrustedServer) buildScan.allowUntrustedServer = geAllowUntrustedServer
205205

206-
// abort in afterEvaluate since any exceptions thrown in afterResolve are caught and not propagated,
207-
// which means the build would try to publish a build scan to scans.gradle.com
208206
if (!buildScan.server && !omitServerUrlValidation) {
209207
logErrorMissingGradleEnterpriseServerURL()
210208
throw new IllegalStateException("The Gradle Enterprise server URL is not configured.\n" +
@@ -228,15 +226,6 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
228226
extensionsWithPublicType(settings, GRADLE_ENTERPRISE_EXTENSION_CLASS).collect { settings[it.name] }.each { ext ->
229227
if (geUrl) ext.server = geUrl
230228
if (geAllowUntrustedServer) ext.allowUntrustedServer = geAllowUntrustedServer
231-
232-
// abort immediately to avoid that the CCUD plugin tries to register a buildFinished listener
233-
// even though, by then, GE has already marked the build as finished (causes warning in the console)
234-
if (!ext.server && !omitServerUrlValidation) {
235-
logErrorMissingGradleEnterpriseServerURL()
236-
throw new IllegalStateException("The Gradle Enterprise server URL is not configured.\n" +
237-
"Either configure it directly (see https://docs.gradle.com/enterprise/gradle-plugin/#gradle_6_x_and_later_2) in the project,\n" +
238-
"or use `--gradle-enterprise-server` when running the build validation script.")
239-
}
240229
}
241230
}
242231
} else {
@@ -263,6 +252,13 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
263252
if (geUrl) ext.server = geUrl
264253
if (geAllowUntrustedServer) ext.allowUntrustedServer = geAllowUntrustedServer
265254

255+
if (!ext.server && !omitServerUrlValidation) {
256+
logErrorMissingGradleEnterpriseServerURL()
257+
throw new IllegalStateException("The Gradle Enterprise server URL is not configured.\n" +
258+
"Either configure it directly (see https://docs.gradle.com/enterprise/gradle-plugin/#gradle_6_x_and_later_2) in the project,\n" +
259+
"or use `--gradle-enterprise-server` when running the build validation script.")
260+
}
261+
266262
registerBuildScanActions(ext.buildScan)
267263
addBuildScanCustomData(ext.buildScan)
268264
configureBuildScanPublishing(ext.buildScan)

0 commit comments

Comments
 (0)