- JDK, version 17 or later
- Ant, latest version
- Maven, latest version
- Node.js, latest LTS (to build VSIX)
$ git clone --recurse-submodules https://github.com/oracle/javavscode.git
$ cd javavscode
# the following target requires git executable to be on PATH:
$ ant apply-patches
$ ant build-netbeans
# Note if you do not wish to have l10n in scope then add no-l10n before any ant invocation target at beginning as below, by default l10n is enabled
$ ant no-l10n apply-patches
$ ant no-l10n build-netbeans
To build the VS Code extension invoke:
ant build-vscode-ext
The resulting extension is then in the build
directory, with the .vsix
extension.
The typical file name is oracle-java-0.1.0.vsix
.
If you're developing the extension, follow these steps to build the project for faster iterations without packaging a .vsix
file:
- Run the following command to build the Language Server Protocol (LSP) server:
$ ant build-lsp-server
- Navigate to the
vscode
folder:$ cd vscode
- Install the necessary Node.js dependencies:
$ npm install
- Start the build watcher to automatically rebuild the extension on file changes:
$ npm run watch
This process is faster than packaging the extension as a .vsix
file, allowing for quicker development cycles.
Follow these steps to debug both the extension's TypeScript code and the NetBeans server code:
- Open the
vscode
folder in VS Code. - Press
F5
to launch and debug the extension.
- Open the Command Palette using
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Search for Preferences: Open User Settings (JSON) and select it.
- Locate or add the
jdk.serverVmOptions
setting in the JSON file and append the following arguments:"jdk.serverVmOptions": [ "-Xdebug", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000" ]
- Start your debugging session. The NetBeans server will suspend execution and wait for a remote debugger to connect at port
8000
.
[NOTE: If you are using multiple profiles in VS Code, then set above configuration in appropriate profile
This configuration will enable you to debug both the extension’s TypeScript code and the NetBeans server-side code.
- Open the Command Palette using
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Search for Preferences: Open User Settings (JSON) and select it.
- In the settings JSON file, add or update the following setting:
"jdk.verbose": true
- Open the Command Palette using
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Search for Preferences: Open User Settings (JSON) and select it.
- Locate or add the
jdk.serverVmOptions
setting and append the following argument to the array:"jdk.serverVmOptions": ["-J-Dnetbeans.logger.console=true"]
Both options will enable logging from the NetBeans server in the VS Code Output Channel.
Often it is also important to properly clean everything. Use:
$ ant clean-vscode-ext
$ cd netbeans/
$ ant clean
The java.lsp.server
module has classical (as other NetBeans modules) tests.
The most important one is ServerTest
which simulates LSP communication and checks expected replies. In addition to
that there are VS Code integration tests - those launch VS Code with the
VS extension and check behavior of the TypeScript integration code:
$ ant build-vscode-ext # first and then
$ ant test-vscode-ext
In case you are behind a proxy, you may want to run the tests with
$ npm_config_https_proxy=http://your.proxy.com:port ant test-vscode-ext
when executing the tests for the first time. That shall overcome the proxy
and download an instance of code
to execute the tests with.
This project uses git submodules . In particular netbeans and netbeans-l10n are submodules pointing to specific commits in their respective repositories .
Add the --recurse-submodules flag to the git checkout command to update the submodules during the checkout.
git checkout --recurse-submodules <branch_name>
Note:- Merging branches with submodules pointing to different commits can be tricky. Refer the git submodules for more details on the same.
# Fetching changes from remote submodule repositories
git submodule update --remote
# Changing the submodule version
cd netbeans
git checkout <commit_hash>
cd ..
# Committing the submodule version
git add netbeans
git commit -m "Updated netbeans"