This is an early work-in-progress extension for vscode-java. It aims at providing support for the JBang scripts written in Java.
Pre-requisites:
- JBang is installed and available in the PATH. Alternatively, you can set the
jbang.home
preference to point to aJBang
installation - vscode-java is installed.
Outstanding issues:
- Modifications to build.jbang files don't trigger autosynchronization nor do they report diagnostics. See jbang-eclipse#25.
- The Java Runtime for current file is not displayed in the status bar. See vscode-java#2552.
- `JDT.LS reimports the JBang project every time the folder is opened in the editor, making startup slower than necessary. See eclipse.jdt.ls#2155
What works (more or less):
- If you open a folder containing JBang scripts, each script will be assigned a specific classpath.
- Snippets are provided for JBang directives.
- Modifying JBang directives in a file will update the classpath of the file.
- Autocompletion for dependencies in
//DEPS
- Autocompletion for
//SOURCES
- Partial autocompletion for
//JAVA_OPTIONS
and//JAVAC_OPTIONS
- JBang scripts can be run from the
Run JBang
codelens, that shows on top of the type declaration or main method, if there is one. - If a (.java) script is included in a Maven or Gradle project's hierarchy, right-clicking on the script and selecting
JBang > Synchronize JBang
will add the script's parent folder to the project's source path and the JBang dependencies will be added to the project's classpath. - Create a new JBang script from an existing template with the
JBang: Create a new script
command. - Annotation processors are automatically detected and configured.
- Partial support for
build.jbang
files: If a folder containingbuild.jbang
is opened, it'll be used to configure the Java settings of its //SOURCES. Currently, changes inbuild.jbang
require manually triggering theJBang > Synchronize JBang
command (via codelens or context menu) to take effect. - Export the script as a native binary, by right-clicking on the script and selecting the
JBang > Export as native binary
menu. This requires GraalVM to be installed with the native-image extension. See https://www.jbang.dev/documentation/guide/latest/usage.html#build-and-run-native-image-experimental
jbang.home
: Specifies the folder path to the JBang directory (not the executable), eg.~/.sdkman/candidates/jbang/current
. On Windows, backslashes must be escaped, egC:\\ProgramData\\chocolatey\\lib\\jbang
. Used by theJBang: Create a new script
wizard and theRun JBang
code lens. Useful in casejbang
is not automatically picked up from the $PATH, for some reason.jbang.wizard.templates.showDescriptions
: When set totrue
(the default), shows JBang template descriptions in theJBang: Create a new script
wizard, else hides them.
Continuous Integration builds can be installed from the Visual Studio Marketplace, as Pre-release builds. Alternatively, you can head to https://github.com/jbangdev/jbang-vscode/releases/tag/latest, download the most recent jbang-vscode-<version>.vsix
file and install it by following the instructions here.
Step 1. Fork and clone this repository
Step 2. Fork and clone the jbangdev/jbang-eclipse repository, which contains the JBang/Eclipse core plugin and its jdt.ls extension
Note: Ensure that the cloned repositories are under the same parent directory:
YOUR_FOLDER/
├──── jbang-vscode/
├──── jbang-eclipse/
Step 3. Navigate into jbang-vscode/
$ cd jbang-vscode/
Step 4. Install npm dependencies
$ npm ci
Step 5. Build the JBang/Eclipse integration plugin and its jdt.ls extension
$ npm run build-ext
This script places the built jars in jbang-vscode/jars/
.
Step 6. Build the VS Code extension
$ npx vsce package
This will generate a jbang-vscode-<version>.vsix
file in the jbang-vscode/
directory.