@@ -260,6 +260,48 @@ class TestDevelocityInjection extends BaseInitScriptTest {
260260 [testGradle, testDvPlugin] << getVersionsToTestForExistingDvPlugin()
261261 }
262262
263+ @Requires ({data.testGradle.compatibleWithCurrentJvm})
264+ def " can configure uploadInBackground when Develocity plugin is applied by the init script" () {
265+ when :
266+ def result = run(testGradle, testConfig(testDvPlugin. version). withUploadInBackground(true ))
267+
268+ then :
269+ if (testGradle. gradleVersion < GRADLE_5 ) {
270+ // Gradle 4.x and earlier will always inject build-scan-plugin 1.16 which doesn't have uploadInBackground
271+ outputMissesUploadInBackground(result)
272+ } else {
273+ outputContainsUploadInBackground(result, true )
274+ }
275+
276+ and :
277+ outputContainsBuildScanUrl(result)
278+
279+ where :
280+ [testGradle, testDvPlugin] << getVersionsToTestForPluginInjection()
281+ }
282+
283+ @Requires ({data.testGradle.compatibleWithCurrentJvm})
284+ def " can configure uploadInBackground when Develocity plugin already applied" () {
285+ given :
286+ declareDvPluginApplication(testGradle, testDvPlugin, null , mockScansServer. address)
287+
288+ when :
289+ def result = run(testGradle, testConfig(). withoutDevelocityPluginVersion())
290+
291+ then :
292+ if (testDvPlugin. compatibleWithUploadInBackground) {
293+ outputContainsUploadInBackground(result, true )
294+ } else {
295+ outputMissesUploadInBackground(result)
296+ }
297+
298+ and :
299+ outputContainsBuildScanUrl(result)
300+
301+ where :
302+ [testGradle, testDvPlugin] << getVersionsToTestForExistingDvPlugin()
303+ }
304+
263305 @Requires ({data.testGradle.compatibleWithCurrentJvm})
264306 def " can configure alternative repository for plugins when Develocity plugin is applied by the init script" () {
265307 when :
@@ -485,6 +527,18 @@ class TestDevelocityInjection extends BaseInitScriptTest {
485527 assert 1 == result. output. count(message)
486528 }
487529
530+ void outputContainsUploadInBackground (BuildResult result , boolean uploadInBackground ) {
531+ def message = " Setting uploadInBackground: $uploadInBackground "
532+ assert result. output. contains(message)
533+ assert 1 == result. output. count(message)
534+ }
535+
536+ void outputMissesUploadInBackground (BuildResult result ) {
537+ def message = " Setting uploadInBackground:"
538+ assert ! result. output. contains(message)
539+ assert 0 == result. output. count(message)
540+ }
541+
488542 private BuildResult run (TestGradleVersion testGradle , DvInjectionTestConfig config , List<String > args = [" help" ]) {
489543 return run(args, testGradle, config. envVars)
490544 }
@@ -508,6 +562,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
508562 boolean captureFileFingerprints = false
509563 String termsOfUseUrl = null
510564 String termsOfUseAgree = null
565+ boolean uploadInBackground = true // Need to upload in background since our Mock server doesn't cope with foreground upload
511566
512567 DvInjectionTestConfig (URI serverAddress , String develocityPluginVersion ) {
513568 this . serverUrl = serverAddress. toString()
@@ -552,13 +607,18 @@ class TestDevelocityInjection extends BaseInitScriptTest {
552607 return this
553608 }
554609
610+ DvInjectionTestConfig withUploadInBackground (boolean uploadInBackground ) {
611+ this . uploadInBackground = uploadInBackground
612+ return this
613+ }
614+
555615 Map<String , String > getEnvVars () {
556616 Map<String , String > envVars = [
557617 DEVELOCITY_INJECTION_INIT_SCRIPT_NAME : " develocity-injection.init.gradle" ,
558618 DEVELOCITY_INJECTION_ENABLED : " true" ,
559619 DEVELOCITY_URL : serverUrl,
560620 DEVELOCITY_ALLOW_UNTRUSTED_SERVER : " true" ,
561- DEVELOCITY_BUILD_SCAN_UPLOAD_IN_BACKGROUND : " true " , // Need to upload in background since our Mock server doesn't cope with foreground upload
621+ DEVELOCITY_BUILD_SCAN_UPLOAD_IN_BACKGROUND : String . valueOf(uploadInBackground),
562622 DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE : ' gradle-actions'
563623 ]
564624 if (enforceUrl) envVars. put(" DEVELOCITY_ENFORCE_URL" , " true" )
0 commit comments