Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support compound tasks #5517

Closed
elaihau opened this issue Jun 19, 2019 · 13 comments
Closed

Support compound tasks #5517

elaihau opened this issue Jun 19, 2019 · 13 comments
Labels
help wanted issues meant to be picked up, require help tasks issues related to the task system vscode issues related to VSCode compatibility

Comments

@elaihau
Copy link
Contributor

elaihau commented Jun 19, 2019

Description

VS Code supports having tasks that are dependent on other tasks.

See https://code.visualstudio.com/docs/editor/tasks#_compound-tasks for details

@elaihau elaihau added the tasks issues related to the task system label Jun 19, 2019
@akosyakov akosyakov added the vscode issues related to VSCode compatibility label Aug 7, 2019
@akosyakov
Copy link
Member

@elaihau @RomanNikitenko if you can find a moment to write down how it can be done it would helpful. @idoprz would like to have a look into it

@akosyakov akosyakov added the help wanted issues meant to be picked up, require help label Aug 8, 2019
@elaihau
Copy link
Contributor Author

elaihau commented Aug 17, 2019

All tasks can be retrieved from the task-service.ts.

Configured tasks can be retrieved from task-configurations.ts, and detected tasks from provided-task-configurations.ts.

Take this compound task for example:

        {
            "label": "Build",
            "dependsOn": ["Client Build", "Server Build"]
        }

with all the task data in memory, I believe we are able to find Client Build task and Server Build task, and start them sequentially.

In current theia, we open a separate terminal window for each and every task. In my opinion, the difficult part of this feature is figuring out a good way to use ONE terminal for all the smaller tasks.

@idoprz
Copy link

idoprz commented Aug 18, 2019

task-service.ts and task-configurations.ts are both in the browser.
Looking at the code it seems that the correct place to run tasks are from task-server, which is in the node part.

Regarding the behavior you suggested, VSCode runs each dependent task on a new terminal.

@elaihau
Copy link
Contributor Author

elaihau commented Aug 18, 2019

task-service.ts and task-configurations.ts are both in the browser.
Looking at the code it seems that the correct place to run tasks are from task-server, which is in the node part.

yep, that's how things work in theia. we just resolve the task config in browser and pass it to the node part.

Regarding the behavior you suggested, VSCode runs each dependent task on a new terminal.

running each dependent task in a new terminal sounds good. sorry for the misleading comment.

@idoprz
Copy link

idoprz commented Aug 20, 2019

task-service.ts and task-configurations.ts are both in the browser.
Looking at the code it seems that the correct place to run tasks are from task-server, which is in the node part.

yep, that's how things work in theia. we just resolve the task config in browser and pass it to the node part.

The dependencies can create a DAG, which should be converted to a tree. Do you suggest I will read all tasks in the browser and create the tree by adding to TaskCustomization interface:
dependentTasks: TaskCustomization[];

Regarding the behavior you suggested, VSCode runs each dependent task on a new terminal.

running each dependent task in a new terminal sounds good. sorry for the misleading comment.

@elaihau
Copy link
Contributor Author

elaihau commented Aug 21, 2019

The dependencies can create a DAG, which should be converted to a tree. Do you suggest I will read all tasks in the browser and create the tree by adding to TaskCustomization interface:
dependentTasks: TaskCustomization[];

i have no issues with that :)

@ShimonBenYair
Copy link
Contributor

ShimonBenYair commented Nov 14, 2019

@akosyakov @elaihau
I am taking this issue and trying to implement it.
I will send a PR in few days

@akosyakov
Copy link
Member

@ShimonBenYair ok, please don't forget to follow PR checklist

@ShimonBenYair
Copy link
Contributor

ShimonBenYair commented Nov 20, 2019

@elaihau @akosyakov

I want the "dependsOn" array, to be of type : string (the tasks labels) and also of type TaskIdentifier (like in VSCode) :

 taskIdentifier: IJSONSchema = {
    type: 'object',
    additionalProperties: true,
    properties: {
        type: {
            type: 'string',
            description: 'The task identifier.' }
          }
    };

But if the user will not write (in the dependsOn object) all the task required properties (every type has different required properties e.g. npm, gulp …), then how will I identify the task that is related to what is mention in the taskIdentifier ?
Foe example: the required properties of "npm" are : 'type' and 'script', and the user mentioned only 'type' and 'label' ? (or just 'type')

{
    "tasks": [
      {
         "label": "shimontask1",
         "type": "shell",
         "command": "sleep 5s &&& echo something",
         "dependsOn": ["task2",  {"type": "npm","label":"task1"}  ],
         "dependsOrder": "sequence"
      },
      {
   "label": "task1",
         "type": "npm",
         "script": "test1"
      },
      {
   "label": "task1",
         "type": "npm",
         "script": "test2"
      },
      {
   "label": "task2",
         "type": "npm",
         "script": "test44"
      }
}

@elaihau
Copy link
Contributor Author

elaihau commented Nov 21, 2019

But if the user will not write (in the dependsOn object) all the task required properties (every type has different required properties e.g. npm, gulp …), then how will I identify the task that is related to what is mention in the taskIdentifier ?

The first thing I would try, is passing "taskIdentifier" (e.g., {"type": "npm","label": "task1"}) into TaskDefinitionRegistry.getDefinition(), to see what the function returns.

if the function returns undefined, the "taskIdentifier" does not have enough information. In this case I guess we should notify the user the error.

if the function returns something other than undefined, I would check each and every task config to find the one that matches the "taskIdentifier". If there are more than one matches we could either notify the user to ask for more specific info, or simply run the first matched task. You can try it in vs code and see what it does.

@akosyakov
Copy link
Member

akosyakov commented Nov 21, 2019

Please also make sure that all user facing JSON interfaces (i.e. used to parse data) are have the same shape as in VS Code. For it, please don't guess, but read VS Code codebase.

@ShimonBenYair
Copy link
Contributor

ShimonBenYair commented Nov 21, 2019

@elaihau @akosyakov

Ok, thanks.
In addition, if i have a task in the "dependsOn" array that for example runs tomcat ( so it is running in the background and doesn't seems to have exit code ) , then what should be the behavior of the parent task ? (it will never start)

{
    "tasks": [
      {
         "label": "task1",
         "type": "shell",
         "command": "echo something",
         "dependsOn": ["task2" ],
         "dependsOrder": "sequence or parallel"
      },
      {
   "label": "task2",
         "type": "shell",
         "command": "run tomcat"
      }
}

How can i solve it ?

@elaihau
Copy link
Contributor Author

elaihau commented Nov 25, 2019

@elaihau @akosyakov

Ok, thanks.
In addition, if i have a task in the "dependsOn" array that for example runs tomcat ( so it is running in the background and doesn't seems to have exit code ) , then what should be the behavior of the parent task ? (it will never start)

{
    "tasks": [
      {
         "label": "task1",
         "type": "shell",
         "command": "echo something",
         "dependsOn": ["task2" ],
         "dependsOrder": "sequence or parallel"
      },
      {
   "label": "task2",
         "type": "shell",
         "command": "run tomcat"
      }
}

How can i solve it ?

i am not sure. i would check what vs code does in this case.

at this moment, the property "background" is not supported in Theia. So i am a little skeptical on the feasiblity of running your task1 and task2 in parallell, because Theia does not know if task2 is a background task.

-------------- UPDATE ----------------------

This is what I found from the vscode documentation: https://code.visualstudio.com/docs/editor/tasks

If you specify "dependsOrder": "sequence" then your task dependencies are executed in the order > they are listed in dependsOn. Any background/watch tasks used in dependsOn with
"dependsOrder": "sequence" must have a problem matcher that tracks when they are "done". The > following task runs task Two, task Three, and then task One.

So I guess the trick is defining a problem matcher and pattern, so that Theia knows if the task2 has "ended". (It is your definition of "ended". The task does not have to terminate)

akosyakov pushed a commit to akosyakov/theia that referenced this issue Feb 24, 2020
…lipse-theia#5517 and also Fixes eclipse-theia#6534

Signed-off-by: Shimon Ben Yair <shimon.ben.yair@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted issues meant to be picked up, require help tasks issues related to the task system vscode issues related to VSCode compatibility
Projects
None yet
Development

No branches or pull requests

4 participants