diff --git a/sources/src/resources/init-scripts/gradle-actions.build-result-capture-service.plugin.groovy b/sources/src/resources/init-scripts/gradle-actions.build-result-capture-service.plugin.groovy index 7f6d9da..c2d938b 100644 --- a/sources/src/resources/init-scripts/gradle-actions.build-result-capture-service.plugin.groovy +++ b/sources/src/resources/init-scripts/gradle-actions.build-result-capture-service.plugin.groovy @@ -1,5 +1,10 @@ import org.gradle.tooling.events.* import org.gradle.tooling.events.task.* +import org.gradle.internal.operations.* +import org.gradle.initialization.* +import org.gradle.api.internal.tasks.execution.* +import org.gradle.execution.* +import org.gradle.internal.build.event.BuildEventListenerRegistryInternal import org.gradle.util.GradleVersion settingsEvaluated { settings -> @@ -11,11 +16,12 @@ settingsEvaluated { settings -> spec.getParameters().getInvocationId().set(gradle.ext.invocationId) }) - gradle.services.get(BuildEventsListenerRegistry).onTaskCompletion(projectTracker) + gradle.services.get(BuildEventListenerRegistryInternal).onOperationCompletion(projectTracker) } -abstract class BuildResultsRecorder implements BuildService, OperationCompletionListener, AutoCloseable { +abstract class BuildResultsRecorder implements BuildService, BuildOperationListener, AutoCloseable { private boolean buildFailed = false + private boolean configCacheHit = true interface Params extends BuildServiceParameters { Property getRootProjectName() Property getRootProjectDir() @@ -24,9 +30,19 @@ abstract class BuildResultsRecorder implements BuildService getInvocationId() } - public void onFinish(FinishEvent finishEvent) { - if (finishEvent instanceof TaskFinishEvent && finishEvent.result instanceof TaskFailureResult) { - buildFailed = true + void started(BuildOperationDescriptor buildOperation, OperationStartEvent startEvent) {} + + void progress(OperationIdentifier operationIdentifier, OperationProgressEvent progressEvent) {} + + void finished(BuildOperationDescriptor buildOperation, OperationFinishEvent finishEvent) { + if (buildOperation.details in EvaluateSettingsBuildOperationType.Details) { + // Got EVALUATE SETTINGS event: not a config-cache hit" + configCacheHit = false + } + if (buildOperation.details in RunRootBuildWorkBuildOperationType.Details) { + if (finishEvent.failure != null) { + buildFailed = true + } } } @@ -38,7 +54,8 @@ abstract class BuildResultsRecorder implements BuildService