build: add support for Visual Studio Code #5563
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for Visual Studio Code as development environment for the Kura codebase... again.
Q: What's different this time?
Thanks for asking!
As you might remember we tried integrating VSCode as our development environment in #4573 but ultimately gave up since it required us either to track the
.classpath
/.project
files created by Eclipse IDE or open the project with Eclipse IDE first. As already discussed (#5198 #5521) Eclipse IDE is quite hard to setup and not the most loved tool in our toolbox.After a brief discussion with @testforstephen (thank you again!) in testforstephen/vscode-pde#56 I realised we didn't need Eclipse IDE to generate these files. They are simple enough to be automatically generated. Cue Kura metadata generator, the script responsible for generating these files (and a little more).
Q: What does this
kura-gen
tool do?javaConfig.json
filekura-equinox_3.16.0.target
with the correct variables.classpath
/.project
files for all of this to work (they won't show in the diff since on other branches these files are not tracked)Q: What's the big deal?
kura-gen
tool so that it can be ran for Kura plugins too. I tested it for the ITxPT bundle and everything works great. We should be able to convert all our plugins to VSCode development in this way (more testing required obviously)Q: What's next?
kura-gen
tool we need to decide where to host it. I think that having it under thekura-eclipse
organization might be a good idea since it should work for all Kura/ESF pluginsTesting
I tested the setup on the following platforms:
I encountered some issue on ARM but they don't seem to be related to the
kura-gen
tool. Some further investigation is required. I'd like to ask anyone interested in running this setup as described in the instruction below. It should work on Windows too but I didn't test it.What's working on VSCode?
What's not working?
Requirements
VSCode extensions:
Kura metadata generator: https://github.com/mattdibi/metadata-generator
Installation:
Note: the code is quite messy ATM but, before investing more time into it, I wanted to see if the approach can work.
Instructions
1. Clone the Kura repository in a new folder (Eclipse IDE gets angry if it shares the sources with VSCode)
vscode-kura
folder2. Build the code following the README or with:
3. Run the Kura metadata generator tool
Change the current working directory to the
kura
foldercd kura/
and then run the tool with the following command
4. Open VSCode in the
kura
directorycode .
5. Follow the on-screen instructions
Troubleshooting
LSP Out of memory error:
Looks like the JVM running the LSP server requires some additional RAM to parse through Kura. Add a
.vscode/settings.json
file in the root workspace directory containing the following:VSCode build gets stuck:
To fix this press: Ctrl + Shift + P (Cmd + Shift + P for Mac users) and run the "Developer: Reload Window" command. If the issue is bad enough you'll also need to clean the LSP workspace cache with "Java: Clean Java Language Server Workspace" and re-run the maven build.
Maven build fails when VSCode is open in the same folder
It looks like the VSCode LSP is interfering(?) with the Maven build when they're running on the same repo. I suggest to close VSCode when running the whole Kura build. If you build a single bundle (which is usually the use-case) it should be fine.
Also @sfiorani feel free to provide feedback on this!