The "Run Task" command provides a list of recently used tasks. This list also contains the build/test tasks started from the "Bazel Build Targets" tree view. However, trying to rerun any of those tasks resulted in an error message.
The extension already contributed a taskDefinition for bazel tasks. However, trying to actually define such a task in the tasks.json resulted in the same error message.
In both cases, the user was presented with the error message
There is no task provider registered for tasks of type "bazel"
This commit fixes the issue, such that rerunning tasks from the history and configuring tasks through tasks.json now works properly.
Furthermore, the taskDefinition inside the package.json was improved:
It now lists the available command options, such that we have auto-completion within the tasks.json editor.
It properly constraints the targets entries to be string-typed.
It exposes the options argument which allows to specify additional command line parameters.
Code changes
Fixing the issue mainly required registering a TaskProvider for bazel tasks. The TaskProvider currently does not auto-detect the available tasks, but only implements resolveTask.
The notifications in onTaskProcessEnd had to be refactored: So far, the BazelTaskInfo was attached right during task creation. However, this didn't work for the new resolveTask. resolveTask apparently isn't allowed to change a task's definition. To make notifications work, the BazelTaskInfo is now attached in the onTaskStart callback.
Many of the fields of the BazelTaskInfo were unused. This commit removes commandOptions, processId, exitCode all of which were stored but never read. Doing so, it turned out that the onTaskProcessStart was no longer necessary.
Lastly, the callbacks used for task notifications were moved from extension.ts to bazel_task_info.ts and activation of all task-related functionality was centralized in the activateTaskProvider function
BEGIN_COMMIT_OVERRIDE
feat: Support bazel tasks from tasks.json (#346)
END_COMMIT_OVERRIDE
User-facing changes
This commit fixes two user-facing bugs:
taskDefinition
for bazel tasks. However, trying to actually define such a task in thetasks.json
resulted in the same error message.In both cases, the user was presented with the error message
This commit fixes the issue, such that rerunning tasks from the history and configuring tasks through
tasks.json
now works properly.Furthermore, the
taskDefinition
inside thepackage.json
was improved:command
options, such that we have auto-completion within thetasks.json
editor.targets
entries to be string-typed.options
argument which allows to specify additional command line parameters.Code changes
Fixing the issue mainly required registering a
TaskProvider
forbazel
tasks. TheTaskProvider
currently does not auto-detect the available tasks, but only implementsresolveTask
.The notifications in
onTaskProcessEnd
had to be refactored: So far, theBazelTaskInfo
was attached right during task creation. However, this didn't work for the newresolveTask
.resolveTask
apparently isn't allowed to change a task's definition. To make notifications work, theBazelTaskInfo
is now attached in theonTaskStart
callback.Many of the fields of the
BazelTaskInfo
were unused. This commit removescommandOptions
,processId
,exitCode
all of which were stored but never read. Doing so, it turned out that theonTaskProcessStart
was no longer necessary.Lastly, the callbacks used for task notifications were moved from
extension.ts
tobazel_task_info.ts
and activation of all task-related functionality was centralized in theactivateTaskProvider
functionBEGIN_COMMIT_OVERRIDE feat: Support bazel tasks from tasks.json (#346) END_COMMIT_OVERRIDE