Loading src/job-summary.ts +4 −2 Changes for src/job-summary.ts: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -4,9 +4,11 @@ import path from 'path' import {logCachingReport, CacheListener} from './cache-reporting' interface BuildResult { get rootProject(): string get rootProjectName(): string get rootProjectDir(): string get requestedTasks(): string get gradleVersion(): string get gradleHomeDir(): string get buildFailed(): boolean get buildScanUri(): string } Loading Loading @@ -50,7 +52,7 @@ function writeSummaryTable(results: BuildResult[]): void { {data: 'Outcome', header: true} ], ...results.map(result => [ result.rootProject, result.rootProjectName, result.requestedTasks, result.gradleVersion, renderOutcome(result) Loading src/resources/build-result-capture-service.plugin.groovy +9 −3 Changes for src/resources/build-result-capture-service.plugin.groovy: 9 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ import org.gradle.util.GradleVersion // But projectsEvaluated is good enough, since the build service won't catch configuration failures anyway projectsEvaluated { def projectTracker = gradle.sharedServices.registerIfAbsent("gradle-build-action-buildResultsRecorder", BuildResultsRecorder, { spec -> spec.getParameters().getRootProject().set(gradle.rootProject.name) spec.getParameters().getRootProjectName().set(gradle.rootProject.name) spec.getParameters().getRootProjectDir().set(gradle.rootProject.rootDir.absolutePath) spec.getParameters().getRequestedTasks().set(gradle.startParameter.taskNames.join(" ")) spec.getParameters().getGradleHomeDir().set(gradle.gradleHomeDir.absolutePath) spec.getParameters().getInvocationId().set(gradle.ext.invocationId) }) Loading @@ -17,8 +19,10 @@ projectsEvaluated { abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder.Params>, OperationCompletionListener, AutoCloseable { private boolean buildFailed = false interface Params extends BuildServiceParameters { Property<String> getRootProject() Property<String> getRootProjectName() Property<String> getRootProjectDir() Property<String> getRequestedTasks() Property<String> getGradleHomeDir() Property<String> getInvocationId() } Loading @@ -31,9 +35,11 @@ abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder @Override public void close() { def buildResults = [ rootProject: getParameters().getRootProject().get(), rootProjectName: getParameters().getRootProjectName().get(), rootProjectDir: getParameters().getRootProjectDir().get(), requestedTasks: getParameters().getRequestedTasks().get(), gradleVersion: GradleVersion.current().version, gradleHomeDir: getParameters().getGradleHomeDir().get(), buildFailed: buildFailed, buildScanUri: null ] Loading src/resources/build-result-capture.init.gradle +12 −5 Changes for src/resources/build-result-capture.init.gradle: 12 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ if (isTopLevelBuild) { 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.name, invocationId) 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 if (useBuildService) { Loading @@ -30,7 +30,7 @@ if (isTopLevelBuild) { } else if (atLeastGradle3) { projectsEvaluated { gradle -> if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) { captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject.name, invocationId) captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject, invocationId) } // We need to capture in buildFinished in case the plugin is applied but no build scan is published captureUsingBuildFinished(gradle, invocationId) Loading @@ -38,10 +38,13 @@ if (isTopLevelBuild) { } } def captureUsingBuildScanPublished(buildScanExtension, rootProjectName, invocationId) { def captureUsingBuildScanPublished(buildScanExtension, rootProject, invocationId) { buildScanExtension.with { def requestedTasks = gradle.startParameter.taskNames.join(" ") def rootProjectName = rootProject.name def rootProjectDir = rootProject.projectDir.absolutePath def gradleVersion = GradleVersion.current().version def gradleHomeDir = gradle.gradleHomeDir.absolutePath def buildFailed = false buildFinished { result -> Loading @@ -52,9 +55,11 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProjectName, invocati def buildScanUri = buildScan.buildScanUri.toASCIIString() def buildResults = [ rootProject: rootProjectName, rootProjectName: rootProjectName, rootProjectDir: rootProjectDir, requestedTasks: requestedTasks, gradleVersion: gradleVersion, gradleHomeDir: gradleHomeDir, buildFailed: buildFailed, buildScanUri: buildScanUri ] Loading @@ -78,9 +83,11 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProjectName, invocati def captureUsingBuildFinished(gradle, invocationId) { gradle.buildFinished { result -> def buildResults = [ rootProject: gradle.rootProject.name, rootProjectName: gradle.rootProject.name, rootProjectDir: gradle.rootProject.rootDir.absolutePath, requestedTasks: gradle.startParameter.taskNames.join(" "), gradleVersion: GradleVersion.current().version, gradleHomeDir: gradle.gradleHomeDir.absolutePath, buildFailed: result.failure != null, buildScanUri: null ] Loading test/test-init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy +3 −1 Changes for test/test-init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -120,9 +120,11 @@ class TestBuildResultRecorder extends BaseInitScriptTest { void assertResults(String task, TestGradleVersion testGradleVersion, boolean hasFailure, boolean hasBuildScan) { def results = new JsonSlurper().parse(buildResultFile) assert results['rootProject'] == ROOT_PROJECT_NAME assert results['rootProjectName'] == ROOT_PROJECT_NAME assert results['rootProjectDir'] == testProjectDir.canonicalPath assert results['requestedTasks'] == task assert results['gradleVersion'] == testGradleVersion.gradleVersion.version assert results['gradleHomeDir'] != null assert results['buildFailed'] == hasFailure assert results['buildScanUri'] == (hasBuildScan ? "${mockScansServer.address}s/${PUBLIC_BUILD_SCAN_ID}" : null) } Loading Loading
src/job-summary.ts +4 −2 Changes for src/job-summary.ts: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -4,9 +4,11 @@ import path from 'path' import {logCachingReport, CacheListener} from './cache-reporting' interface BuildResult { get rootProject(): string get rootProjectName(): string get rootProjectDir(): string get requestedTasks(): string get gradleVersion(): string get gradleHomeDir(): string get buildFailed(): boolean get buildScanUri(): string } Loading Loading @@ -50,7 +52,7 @@ function writeSummaryTable(results: BuildResult[]): void { {data: 'Outcome', header: true} ], ...results.map(result => [ result.rootProject, result.rootProjectName, result.requestedTasks, result.gradleVersion, renderOutcome(result) Loading
src/resources/build-result-capture-service.plugin.groovy +9 −3 Changes for src/resources/build-result-capture-service.plugin.groovy: 9 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ import org.gradle.util.GradleVersion // But projectsEvaluated is good enough, since the build service won't catch configuration failures anyway projectsEvaluated { def projectTracker = gradle.sharedServices.registerIfAbsent("gradle-build-action-buildResultsRecorder", BuildResultsRecorder, { spec -> spec.getParameters().getRootProject().set(gradle.rootProject.name) spec.getParameters().getRootProjectName().set(gradle.rootProject.name) spec.getParameters().getRootProjectDir().set(gradle.rootProject.rootDir.absolutePath) spec.getParameters().getRequestedTasks().set(gradle.startParameter.taskNames.join(" ")) spec.getParameters().getGradleHomeDir().set(gradle.gradleHomeDir.absolutePath) spec.getParameters().getInvocationId().set(gradle.ext.invocationId) }) Loading @@ -17,8 +19,10 @@ projectsEvaluated { abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder.Params>, OperationCompletionListener, AutoCloseable { private boolean buildFailed = false interface Params extends BuildServiceParameters { Property<String> getRootProject() Property<String> getRootProjectName() Property<String> getRootProjectDir() Property<String> getRequestedTasks() Property<String> getGradleHomeDir() Property<String> getInvocationId() } Loading @@ -31,9 +35,11 @@ abstract class BuildResultsRecorder implements BuildService<BuildResultsRecorder @Override public void close() { def buildResults = [ rootProject: getParameters().getRootProject().get(), rootProjectName: getParameters().getRootProjectName().get(), rootProjectDir: getParameters().getRootProjectDir().get(), requestedTasks: getParameters().getRequestedTasks().get(), gradleVersion: GradleVersion.current().version, gradleHomeDir: getParameters().getGradleHomeDir().get(), buildFailed: buildFailed, buildScanUri: null ] Loading
src/resources/build-result-capture.init.gradle +12 −5 Changes for src/resources/build-result-capture.init.gradle: 12 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ if (isTopLevelBuild) { 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.name, invocationId) 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 if (useBuildService) { Loading @@ -30,7 +30,7 @@ if (isTopLevelBuild) { } else if (atLeastGradle3) { projectsEvaluated { gradle -> if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) { captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject.name, invocationId) captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject, invocationId) } // We need to capture in buildFinished in case the plugin is applied but no build scan is published captureUsingBuildFinished(gradle, invocationId) Loading @@ -38,10 +38,13 @@ if (isTopLevelBuild) { } } def captureUsingBuildScanPublished(buildScanExtension, rootProjectName, invocationId) { def captureUsingBuildScanPublished(buildScanExtension, rootProject, invocationId) { buildScanExtension.with { def requestedTasks = gradle.startParameter.taskNames.join(" ") def rootProjectName = rootProject.name def rootProjectDir = rootProject.projectDir.absolutePath def gradleVersion = GradleVersion.current().version def gradleHomeDir = gradle.gradleHomeDir.absolutePath def buildFailed = false buildFinished { result -> Loading @@ -52,9 +55,11 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProjectName, invocati def buildScanUri = buildScan.buildScanUri.toASCIIString() def buildResults = [ rootProject: rootProjectName, rootProjectName: rootProjectName, rootProjectDir: rootProjectDir, requestedTasks: requestedTasks, gradleVersion: gradleVersion, gradleHomeDir: gradleHomeDir, buildFailed: buildFailed, buildScanUri: buildScanUri ] Loading @@ -78,9 +83,11 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProjectName, invocati def captureUsingBuildFinished(gradle, invocationId) { gradle.buildFinished { result -> def buildResults = [ rootProject: gradle.rootProject.name, rootProjectName: gradle.rootProject.name, rootProjectDir: gradle.rootProject.rootDir.absolutePath, requestedTasks: gradle.startParameter.taskNames.join(" "), gradleVersion: GradleVersion.current().version, gradleHomeDir: gradle.gradleHomeDir.absolutePath, buildFailed: result.failure != null, buildScanUri: null ] Loading
test/test-init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy +3 −1 Changes for test/test-init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -120,9 +120,11 @@ class TestBuildResultRecorder extends BaseInitScriptTest { void assertResults(String task, TestGradleVersion testGradleVersion, boolean hasFailure, boolean hasBuildScan) { def results = new JsonSlurper().parse(buildResultFile) assert results['rootProject'] == ROOT_PROJECT_NAME assert results['rootProjectName'] == ROOT_PROJECT_NAME assert results['rootProjectDir'] == testProjectDir.canonicalPath assert results['requestedTasks'] == task assert results['gradleVersion'] == testGradleVersion.gradleVersion.version assert results['gradleHomeDir'] != null assert results['buildFailed'] == hasFailure assert results['buildScanUri'] == (hasBuildScan ? "${mockScansServer.address}s/${PUBLIC_BUILD_SCAN_ID}" : null) } Loading