Documentation around PlantUML and how to setup (especially when you don't typically work in Java) leave a lot to be desired. Here's a quick run down of how to get plantuml setup and running so you can create, edit, preview and export the diagrams (including C4 Model) in VS Code.
First, ensure you have homebrew installed and updated: https://brew.sh/.
Install the temurin
JDK, graphviz
and plantuml
in that order.
brew install --cask temurin
brew install graphviz
brew install plantuml
Next, install the PlantUML extension for VS Code: https://github.com/qjebbs/vscode-plantuml
You'll want to configure the extension so its using the correct Java binary and PlantUML jar file you just installed. To do this, open up your VS Code settings.json
: CMD + SHIFT + P
and find "Preferences: Open User Settings (JSON)". Add the following entries to your json object.
"plantuml.java": "/Library/Java/JavaVirtualMachines/temurin-20.jdk/Contents/Home/bin/java",
"plantuml.jar": "/opt/homebrew/Cellar/plantuml/1.2023.7/libexec/plantuml.jar"
Ensure these match the versions you've just installed, version folders may change over time to locate /opt/homebrew/Cellar/plantuml
or /Library/Java/JavaVirtualMachines
and go from there.
Finally, make sure you do not have the -DRELATIVE_INCLUDE
flag included when plantuml runs Java. To check, make sure any of the following is deleted from your VS Code settings.json
:
"plantuml.jarArgs": [
"-DRELATIVE_INCLUDE=."
],
"plantuml.commandArgs": [
"-DRELATIVE_INCLUDE=."
]