-
Notifications
You must be signed in to change notification settings - Fork 185
VS Code specific development instructions
Marek Czernek edited this page Dec 11, 2023
·
8 revisions
This is a description of how to setup Visual Studio Code for developing Uyuni, particularly to work on the Java code using the Java Extension Pack.
- Install Visual Studio Code. How to do this exactly depends on your operating system and personal preferences. There are repositories available with packages for various Linux distributions from the official download site, e.g. for openSUSE.
- Install the Java Extension Pack from the "Extensions" view (find it in the main menu). This includes the most important extensions needed for Java development, especially the Java language server, but also support for commonly used build tools (like maven), debugging applications and running unit tests.
- The Ant Target Runner needs to be installed separately from the "Extensions" view, and can be used to resolve dependencies or to run build and deploy cycles while we are still using
ant
. You might want to configure it to ignore the originalbuild.xml
file by settingmanager-build.xml
asAnt: Build Filenames
. In case you are running VS Code from a flatpak external commands (likeant
) cannot simply be called from extensions due to the sandboxing, it should work to useflatpak-spawn --host ant
as theAnt: Executable
though. - If you are used to working with Intellij or Eclipse you might want to consider installing the respective keybindings: Eclipse Keymap or IntelliJ IDEA Keybindings.
- Clone the repo from GitHub as described here.
- Configure the development machine as described here.
- Make sure to resolve the dependencies for your current branch from the commandline as described (via
ant -f manager-build.xml ivy
), alljar
file dependencies should be in the/lib
folder before proceeding. Note that switching between branches might require you to repeat this step!
- Start VS Code and from the welcome screen (or the "File" menu) use "Open folder...", choose the
java
subdirectory of the Uyuni repository. - Opening any of the Java files in the editor should automatically enable the Java language server and start the compilation / project setup.
- Referenced libraries will automatically be found in the
/lib
subfolder. - If everything went well you should see 0 errors, only warnings and info messages.
- Navigate to the "Run and Debug" view (find it as the 4th entry on the main menu).
- Click the link there to edit the
launch.json
file, or click the settings icon to openlaunch.json
. - Check if the hostname in the debug configurations is actually matching your environment:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug Uyuni",
"request": "attach",
"hostName": "server.tf.local",
"port": 8003
},
{
"type": "java",
"name": "Debug Taskomatic",
"request": "attach",
"hostName": "server.tf.local",
"port": 8001
}
]
}
- From the dropdown menu next to "Run and Debug", choose the configuration and start by clicking the green arrow. The usual debugging options appear on top after connecting to the VM (step over, step into, disconnect, etc.), and breakpoints can be used.
- Create a config file from the template in
java/buildconf/test
:cp rhn.conf.postgresql-example rhn.conf
- Edit it and set
db_host
to match it with your environment, e.g.server.tf.local
. - In the editor, open the Java file that contains the unit tests that you want to run.
- Click on the arrow next to the class or test method definitions, the test(s) will launch in the
Testing
view.