Sakai Debug using Visual Studio Code IDE

Description

It would be helpful to add any folder named .vscode to the .gitignore, as these contain configurations and launch files for debugging Sakai, which can vary depending on the user. This way, we can avoid unnecessary issues.

 

To debug a tool in Sakai using Visual Studio Code, we first need to open the corresponding folder for the tool, in this case, "Assignments > Tool"

SEE SCREENSHOT 1

Once accessed, we should open the debug tab (Run and Debug Ctrl + Shift + D) and create the launch.json file

SEE SCREENSHOT 2

Configuring it as follows:

SEE SCREENSHOT 3

{     "version": "0.2.0",     "configurations": [         {             "type": "java",             "name": "Debug (Attach)",             "projectName": "Sakai",             "request": "attach",             "hostName": "localhost",             "port": 8000         }     ] }

This configuration essentially defines the type (in this case, Java), the name and project name (these are not relevant unless you have more configurations defined), the request (in this case, "attach," since we will start Sakai via console or service and then Visual Studio Code will attach to it), and finally the hostname and port (which we'll modify according to our Sakai configurations).

Finally, we just need to start the debug process, and then we can create breakpoints.

SEE SCREENSHOT 4

On the left side, we’ll be able to observe everything that happens.

An utility bar will appear where we can navigate through the breakpoints. (1) The variables of the functions will be displayed on the left side (2), and the breakpoints will appear in the bottom left corner (3).

SEE SCREENSHOT 5

It's important to remember that since Visual Studio Code is attached to the Sakai service, whenever we want to debug a piece of code, the Sakai deploy folder must be updated with the changes made in the IDE. If we don't do this, some parts of the code may be skipped during debugging because they are not synchronized.

Lastly, adding or removing breakpoints does not require any extra action, such as restarting Sakai or the IDE.

Attachments

1
  • 03 Sep 2024, 07:45 AM

Activity

Show:

Earle Nietzel September 23, 2024 at 3:11 PM

Yeah makes sense to ignore any IDE’s config directory, shouldn’t it be add to the global .gitignore in the project root where the other IDE config files are?

Automation for Jira September 20, 2024 at 10:55 AM

A pull request has been created, "SAK-50453: Sakai Debug using Visual Studio Code IDE", you can see it at https://github.com/sakaiproject/sakai/pull/12901

Fixed

Details

Priority

Fix versions

Components

Assignee

Reporter

Created September 3, 2024 at 7:45 AM
Updated September 24, 2024 at 2:55 PM
Resolved September 24, 2024 at 2:55 PM

Flag notifications