Version 0.0.8 of the Java extension for Visual Studio Code (a.k.a. vscode-java) has been unleashed onto the world. It's available in the Visual Studio Code Marketplace and can be found and installed directly from within Code.
Highlights of this release can be seen in this screencast:
vscode-java finally provides basic Gradle support for Java projects. Basically, you just need to open a folder containing a build.gradle file in its root and wait for the Java support to kick in. Code completion, Navigation, References and all the other existing features of the Java support will work as long as the Gradle project can be successfully imported.
However, please be aware that Gradle-based Android projects are not supported, because of a limitation in BuildShip, the upstream project in which this Gradle support is based on.
Update project configuration
Whenever a build configuration file is modified and saved, a project re-configuration (eg. Java compilation level update) or classpath change (dependencies or source paths) might be required, so the VS Code internal model stays in sync with the build descriptor.
So, a warning will pop up whenever a Maven pom.xml or Gradle (*.gradle) file is saved:
Never will discard the message so it won't show up on subsequent build file changes. Clicking
Now will trigger a project update command, but the message will show up again on the next change. Selecting
Always will trigger configuration updates every time the build file is saved.
Please be aware a project update can be a long-running, CPU-intensive operation. For large projects, it might be preferable to keep the option turned off and instead call the
Update project configuration command manually (via
Cmd+Alt+U on MacOS) when the editor is focused on a Maven pom.xml or a Gradle file.
Whenever you need to change the behavior, you can open the workspace settings and look for the
java.configuration.updateBuildConfiguration key. It specifies how modifications on build files update the Java classpath/configuration. Supported values are:
disabled: never updates automatically on save, doesn't show a warning.
interactive: asks about updating on every build file save.
automatic: updating is automatically triggered on build file save.
Mute "Incomplete classpath" warnings
Whenever a java file is opened, that does not belong to a project (what we call a standalone Java file), vscode-java is unable to compute a proper classpath. It makes it useless to report compilation errors, as the UI would be filled with distracting red errors all over the file. But vscode-java is still able to provide content-assist for base JDK classes, and report syntax errors, so the following warning is displayed:
It's now possible to discard the message permanently, by clicking the Don't show again option.
Should you change your mind, it's possible to modify that choice in VS Code's user settings: The
java.errors.incompleteClasspath.severity key specifies the severity of the message when the classpath is incomplete for a Java file. Supported values are
This release represents an important milestone for this small project as it finally provides basic Gradle support for Java projects, by far, the most requested feature by the community along with some important usability features.
A complete changelog for this version is available there.
This Java extension is powered by two components, a front-end part, the VS Code client, and a back-end part, the headless Java Language Server, based on Eclipse JDT, The M2E project (for Maven support) and now BuildShip (for Gradle support). Both components are developed under the open source Eclipse Public License. All contributions are welcome, whether it's code, feedback, bug reports. Please do so under any of these Github repositories:
- vscode-java: https://github.com/redhat-developer/vscode-java/
- java-language-server: https://github.com/gorkem/java-language-server (will soon move to the Eclipse Foundation)
Last updated: March 22, 2023