Tasks

Hi folks, I’m looking around the tasks support and in particular support for global tasks: it seems global tasks cannot be configured in Theia, but if I look at the workspace file that VS Code writes, there seems to be a section for task configurations in there. Can someone tell me what the current implemented state is there? @marc-dumais maybe?

[original thread by Thomas Mäder]

@elaihau I remember we discussed something like that while working on tasks as preferences? Is it right that one can define tasks section in user or workspace preferences for reusable tasks?

@vince-fugnitto Would you know?

I’ve just tried to add a task to user settings and it works.

{
    "tasks": {
        "tasks": [
            {
                "label": "User Task",
                "type": "process",
                "command": "echo 'test'"
            }
        ]
    }
}

Adding to setting.json works as well, but we don’t support in workspace file. Not sure whether it is supported by VS Code.

if global means defined on user level in this sense it is supported

Hmh…the behaviour is quite weird: when I add a task to the user settings, and then do “configure task” for the first time, I end up with both the configured task, but also with task from the user settings in /.theia/tasks.json

But subsequent changes to the task in the user preferences are not reflected in tasks.json

Also, tasks added to the user prefs after tasks.json is created will not show up in tasks.json

Preferences are resolved by merging from global to workpace folder scope, so there cannot be 2 tasks with the same label, but workspace folder settings can override some properties of the global task.

It works the same way for all preferences, including launch configurations and tasks.

But subsequent changes to the task in the user preferences are not reflected in tasks.json

If they are overridden on the workspace level then it is expected.

Also, tasks added to the user prefs after tasks.json is created will not show up in tasks.json

But I did not override anything, the first task showed up in tasks.json, but the next one did not.

It sounds like a bug, new tasks which are not defined in the workspace folder should appear. But maybe I’m wrong and tasks object on the workspace level completely overrides the user level. Someone has to check.

what do you mean “workspace level”? tasks.json is specific to a workspace root , not a workspace.

I meant the workspace root, sorry

There are VS Code compatibility tests for it: https://github.com/eclipse-theia/theia/blob/0e5cb883ad2fc64186bd66aed1284a6ad0e5604f/examples/api-tests/src/launch-preferences.spec.js#L269-L317