mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Fix build-scan-init script to work with build-in build-scan plugins
This commit is contained in:
parent
9b7c81f8f6
commit
60b1ffac6b
3 changed files with 11 additions and 13 deletions
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -18,31 +18,29 @@ import org.gradle.util.GradleVersion
|
||||||
def isTopLevelBuild = gradle.getParent() == null
|
def isTopLevelBuild = gradle.getParent() == null
|
||||||
if (isTopLevelBuild) {
|
if (isTopLevelBuild) {
|
||||||
def version = GradleVersion.current().baseVersion
|
def version = GradleVersion.current().baseVersion
|
||||||
def atLeastGradle5 = version >= GradleVersion.version("5.0")
|
def atLeastGradle4 = version >= GradleVersion.version("4.0")
|
||||||
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
def atLeastGradle6 = version >= GradleVersion.version("6.0")
|
||||||
|
|
||||||
if (atLeastGradle6) {
|
if (atLeastGradle6) {
|
||||||
settingsEvaluated { settings ->
|
settingsEvaluated { settings ->
|
||||||
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
|
||||||
registerCallbacks(settings.extensions["gradleEnterprise"], settings.rootProject.name)
|
registerCallbacks(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (atLeastGradle5) {
|
} else if (atLeastGradle4) {
|
||||||
projectsEvaluated { gradle ->
|
projectsEvaluated { gradle ->
|
||||||
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
|
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) {
|
||||||
registerCallbacks(gradle.rootProject.extensions["gradleEnterprise"], gradle.rootProject.name)
|
registerCallbacks(gradle.rootProject.extensions["buildScan"], gradle.rootProject.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def registerCallbacks(gradleEnterprise, rootProjectName) {
|
def registerCallbacks(buildScanExtension, rootProjectName) {
|
||||||
gradleEnterprise.with {
|
buildScanExtension.with {
|
||||||
buildScan {
|
def scanFile = new File("gradle-build-scan.txt")
|
||||||
def scanFile = new File("gradle-build-scan.txt")
|
buildScanPublished { buildScan ->
|
||||||
buildScanPublished { buildScan ->
|
scanFile.text = buildScan.buildScanUri
|
||||||
scanFile.text = buildScan.buildScanUri
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue