11/*
22 * Initscript for injection of Develocity into Gradle builds.
3- * Version: v1.1.1
3+ * Version: 1.2
44 */
55
66import org.gradle.util.GradleVersion
@@ -110,7 +110,6 @@ if (buildScanCaptureEnabled) {
110110}
111111
112112void enableDevelocityInjection () {
113- def BUILD_SCAN_PLUGIN_ID = ' com.gradle.build-scan'
114113 def BUILD_SCAN_PLUGIN_CLASS = ' com.gradle.scan.plugin.BuildScanPlugin'
115114
116115 def GRADLE_ENTERPRISE_PLUGIN_ID = ' com.gradle.enterprise'
@@ -153,6 +152,12 @@ void enableDevelocityInjection() {
153152 logger. lifecycle(" Accepting Gradle Terms of Use: $buildScanTermsOfUseUrl " )
154153 }
155154
155+ // finish early if DV plugin version is unsupported (v3.6.4 is the minimum version tested and supports back to DV 2021.1)
156+ if (develocityPluginVersion && isNotAtLeast(develocityPluginVersion, ' 3.6.4' )) {
157+ logger. warn(" Develocity Gradle plugin must be at least 3.6.4. Configured version is $develocityPluginVersion . " )
158+ return
159+ }
160+
156161 // finish early if configuration parameters passed in via system properties are not valid/supported
157162 if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, ' 1.7' )) {
158163 logger. warn(" Common Custom User Data Gradle plugin must be at least 1.7. Configured version is $ccudPluginVersion . " )
@@ -190,8 +195,6 @@ void enableDevelocityInjection() {
190195 // Develocity plugin publishes scans by default
191196 buildScanExtension. publishAlways()
192197 }
193- // uploadInBackground not available for build-scan-plugin 1.16
194- if (buildScanExtension. metaClass. respondsTo(buildScanExtension, ' setUploadInBackground' , Boolean )) buildScanExtension. uploadInBackground = buildScanUploadInBackground
195198 buildScanExtension. value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME , ciAutoInjectionCustomValueValue
196199 if (isAtLeast(develocityPluginVersion, ' 2.1' ) && atLeastGradle5) {
197200 logger. lifecycle(" Setting captureFileFingerprints: $develocityCaptureFileFingerprints " )
@@ -221,6 +224,9 @@ void enableDevelocityInjection() {
221224 develocity. buildScan. termsOfUseUrl = buildScanTermsOfUseUrl
222225 develocity. buildScan. termsOfUseAgree = buildScanTermsOfUseAgree
223226 }
227+
228+ logger. lifecycle(" Setting uploadInBackground: $buildScanUploadInBackground " )
229+ develocity. buildScan. uploadInBackground = buildScanUploadInBackground
224230 },
225231 { buildScan ->
226232 afterEvaluate {
@@ -241,6 +247,12 @@ void enableDevelocityInjection() {
241247 buildScan. licenseAgree = buildScanTermsOfUseAgree
242248 }
243249 }
250+
251+ // uploadInBackground available for build-scan-plugin 3.3.4 and later only
252+ if (buildScan. metaClass. respondsTo(buildScan, ' setUploadInBackground' , Boolean )) {
253+ logger. lifecycle(" Setting uploadInBackground: $buildScanUploadInBackground " )
254+ buildScan. uploadInBackground = buildScanUploadInBackground
255+ }
244256 }
245257 )
246258
@@ -276,7 +288,6 @@ void enableDevelocityInjection() {
276288 }
277289
278290 eachDevelocitySettingsExtension(settings) { ext ->
279- ext. buildScan. uploadInBackground = buildScanUploadInBackground
280291 ext. buildScan. value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME , ciAutoInjectionCustomValueValue
281292 }
282293
@@ -313,6 +324,9 @@ void enableDevelocityInjection() {
313324 develocity. buildScan. termsOfUseUrl = buildScanTermsOfUseUrl
314325 develocity. buildScan. termsOfUseAgree = buildScanTermsOfUseAgree
315326 }
327+
328+ logger. lifecycle(" Setting uploadInBackground: $buildScanUploadInBackground " )
329+ develocity. buildScan. uploadInBackground = buildScanUploadInBackground
316330 },
317331 { gradleEnterprise ->
318332 if (develocityUrl && develocityEnforceUrl) {
@@ -332,6 +346,12 @@ void enableDevelocityInjection() {
332346 gradleEnterprise. buildScan. termsOfServiceUrl = buildScanTermsOfUseUrl
333347 gradleEnterprise. buildScan. termsOfServiceAgree = buildScanTermsOfUseAgree
334348 }
349+
350+ // uploadInBackground available for gradle-enterprise-plugin 3.3.4 and later only
351+ if (gradleEnterprise. buildScan. metaClass. respondsTo(gradleEnterprise. buildScan, ' setUploadInBackground' , Boolean )) {
352+ logger. lifecycle(" Setting uploadInBackground: $buildScanUploadInBackground " )
353+ gradleEnterprise. buildScan. uploadInBackground = buildScanUploadInBackground
354+ }
335355 }
336356 )
337357
0 commit comments