mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-25 09:40:57 -05:00
Detect GE plugin applied in settingsEvaluated
The `PluginManager.hasPlugin` method was not detecting the GE plugin when it was applied during settingsEvaluated. Switching to `PluginManager.withPlugin` fixes this. Fixes #626
This commit is contained in:
parent
a13870c94e
commit
a580d9bd57
1 changed files with 14 additions and 10 deletions
|
@ -16,26 +16,29 @@ if (isTopLevelBuild) {
|
|||
if (atLeastGradle6) {
|
||||
def useBuildService = version >= GradleVersion.version("6.6")
|
||||
settingsEvaluated { settings ->
|
||||
// The `buildScanPublished` hook is the only way to capture the build scan URI.
|
||||
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
||||
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
|
||||
}
|
||||
// We also need to add hooks in case the plugin is applied but no build scan is published
|
||||
// The `buildScanPublished` results will NOT be overwritten by these calls
|
||||
// By default, use standard mechanisms to capture build results
|
||||
if (useBuildService) {
|
||||
captureUsingBuildService(settings, invocationId)
|
||||
} else {
|
||||
captureUsingBuildFinished(gradle, invocationId)
|
||||
}
|
||||
|
||||
// The `buildScanPublished` hook allows the capture of the build scan URI.
|
||||
// Results captured this way will overwrite any results from the other mechanism.
|
||||
settings.pluginManager.withPlugin("com.gradle.enterprise") {
|
||||
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
|
||||
}
|
||||
}
|
||||
} else if (atLeastGradle3) {
|
||||
projectsEvaluated { gradle ->
|
||||
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
|
||||
// By default, use 'buildFinished' to capture build results
|
||||
captureUsingBuildFinished(gradle, invocationId)
|
||||
|
||||
// The `buildScanPublished` hook allows the capture of the build scan URI.
|
||||
// Results captured this way will overwrite any results from 'buildFinished'.
|
||||
gradle.rootProject.pluginManager.withPlugin("com.gradle.build-scan") {
|
||||
captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject, invocationId)
|
||||
}
|
||||
// Always attempt to capture in buildFinished in case the plugin is applied but no build scan is published
|
||||
// The `buildScanPublished` results will NOT be overwritten by this call
|
||||
captureUsingBuildFinished(gradle, invocationId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +73,7 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProject, invocationId
|
|||
|
||||
def captureUsingBuildFinished(gradle, invocationId) {
|
||||
gradle.buildFinished { result ->
|
||||
println "Got buildFinished: ${result}"
|
||||
def buildResults = new BuildResults(invocationId, gradle, gradle.rootProject)
|
||||
buildResults.setBuildResult(result)
|
||||
buildResults.writeToResultsFile(false)
|
||||
|
|
Loading…
Reference in a new issue