The Che-Theia IDE allows users to define custom commands in a devfile that are then available when working in a workspace.
The following is an example of the commands section of a devfile.
commands:
- name: theia:build
actions:
- type: exec
component: che-dev
command: >
yarn
workdir: /projects/theia
- name: run
actions:
- type: vscode-task
referenceContent: |
{
"version": "2.0.0",
"tasks":
[
{
"label": "theia:watch",
"type": "shell",
"options": {"cwd": "/projects/theia"},
"command": "yarn",
"args": ["watch"]
}
]
}
- name: debug
actions:
- type: vscode-launch
referenceContent: |
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
}
]
}
- Che commands
-
theia:build-
The
exectype implies that the Che runner is used for command execution. The user can specify the component in whose container the command is executed. -
The
commandfield contains the command line for execution. -
The
workdiris the working directory in which the command is executed.
-
- Visual Studio Code (VS Code) tasks
-
run-
The type is
vscode-task. -
For this type of command, the
referenceContentfield must contain content with task configurations in the VS Code format. -
For more information about VS Code tasks, see the Task section on the Visual Studio User Guide page.
-
- VS Code launch configurations
-
debug-
The type is
vscode-launch. -
It contains the launch configurations in the VS Code format.
-
For more information about VS Code launch configurations, see the Debugging section on the Visual Studio documentation page.
-
For a list of available tasks and launch configurations, see the tasks.json and the launch.json configuration files in the /workspace/.theia directory where the configuration from the devfile is exported to.
Che-Theia task types
There are two types of tasks in a devfile: tasks in the VS Code format and Che commands. Tasks from the devfile are copied to the configuration file when the workspace is started. Depending on the type of the task, the task is then available for running:
-
Che commands: From the Terminal → Run Task menu in the configured tasks section, or from the My Workspace panel
-
Tasks in the VS Code format: From the Run Tasks menu
To run the task definitions provided by plug-ins, select the Terminal → Run Task menu option. The tasks are placed in the detected tasks section.
Running and debugging
Che-Theia supports the Debug Adapter Protocol. This protocol defines a generic way for how a development tool can communicate with a debugger. It means Che-Theia works with all implementations.
-
A running instance of Eclipse Che. To install an instance of Eclipse Che, see Che 'quick-starts'.
To debug an application:
-
Click Debug → Add Configuration to add debugging or launch configuration to the project.
-
From the pop-up menu, select the appropriate configuration for the application that you want to debug.
-
Update the configuration by modifying or adding attributes.
-
Breakpoints can be toggled by clicking the editor margin.
-
Open the context menu of the breakpoint to add conditions.
-
To start debugging, click View → Debug.
-
In the Debug view, select the configuration and press F5 to debug the application. Or, start the application without debugging by pressing Ctrl+F5.
Editing a task and launch configuration
To customize the configuration file:
-
Edit the
tasks.jsonorlaunch.jsonconfiguration files. -
Add new definitions to the configuration file or modify the existing ones.
The changes are stored in the configuration file. -
To customize the task configuration provided by plug-ins, select the Terminal → Configure TasksS menu option, and choose the task to configure. The configuration is then copied to the
tasks.jsonfile and is available for editing.