@@ -32,31 +32,41 @@ if (isTopLevelBuild) {
32
32
33
33
// Use the Develocity plugin to also capture build scan links, when available
34
34
settingsEvaluated { settings ->
35
- settings. pluginManager. withPlugin(GE_PLUGIN_ID ) {
36
- // Only execute if develocity plugin isn't applied.
37
- if (! settings. extensions. findByName(DEVELOCITY_EXTENSION )) {
35
+ def captureBuildScanLink = {
36
+ // Prefer the 'develocity' extension, if available
37
+ if (settings. extensions. findByName(DEVELOCITY_EXTENSION )) {
38
+ captureUsingBuildScanPublished(settings. extensions[DEVELOCITY_EXTENSION ]. buildScan, invocationId, resultsWriter)
39
+ } else {
38
40
captureUsingBuildScanPublished(settings. extensions[GE_EXTENSION ]. buildScan, invocationId, resultsWriter)
39
41
}
40
42
}
41
-
43
+ settings . pluginManager . withPlugin( GE_PLUGIN_ID , captureBuildScanLink)
42
44
settings. pluginManager. withPlugin(DEVELOCITY_PLUGIN_ID ) {
43
- captureUsingBuildScanPublished(settings. extensions[DEVELOCITY_EXTENSION ]. buildScan, invocationId, resultsWriter)
45
+ // Develocity plugin applies GE plugin: avoid duplicate call
46
+ if (settings. pluginManager. hasPlugin(GE_PLUGIN_ID )) return
47
+ captureBuildScanLink()
44
48
}
45
49
}
46
50
} else if (atLeastGradle3) {
47
51
projectsEvaluated { gradle ->
48
52
// By default, use 'buildFinished' to capture build results
49
53
captureUsingBuildFinished(gradle, invocationId, resultsWriter)
50
54
51
- gradle. rootProject. pluginManager. withPlugin(BUILD_SCAN_PLUGIN_ID ) {
52
- // Only execute if develocity plugin isn't applied.
53
- if (! gradle. rootProject. extensions. findByName(DEVELOCITY_EXTENSION )) {
55
+ def captureBuildScanLink = {
56
+ // Prefer the 'develocity' extension, if available
57
+ if (gradle. rootProject. extensions. findByName(DEVELOCITY_EXTENSION )) {
58
+ captureUsingBuildScanPublished(gradle. rootProject. extensions[DEVELOCITY_EXTENSION ]. buildScan, invocationId, resultsWriter)
59
+ } else {
54
60
captureUsingBuildScanPublished(gradle. rootProject. extensions[BUILD_SCAN_EXTENSION ], invocationId, resultsWriter)
55
61
}
56
62
}
57
63
64
+ gradle. rootProject. pluginManager. withPlugin(BUILD_SCAN_PLUGIN_ID , captureBuildScanLink)
65
+
58
66
gradle. rootProject. pluginManager. withPlugin(DEVELOCITY_PLUGIN_ID ) {
59
- captureUsingBuildScanPublished(gradle. rootProject. extensions[DEVELOCITY_EXTENSION ]. buildScan, invocationId, resultsWriter)
67
+ // Develocity plugin applies Build Scan plugin: avoid duplicate call
68
+ if (gradle. rootProject. pluginManager. hasPlugin(BUILD_SCAN_PLUGIN_ID )) return
69
+ captureBuildScanLink()
60
70
}
61
71
}
62
72
}
0 commit comments