VS Code Gradle Tasks
Run Gradle tasks in VS Code.
This extension provides a visual interface for your Gradle build. You can view Gradle projects and run Gradle tasks.
This extension supports whatever Gradle supports and is language/project agnostic, but it can work nicely alongside other extensions like the Java language support extension.
👉 All Features
This extension contributes the following settings:
gradle.autoDetect: Automatically detect Gradle tasks
gradle.enableTasksExplorer: Enable an explorer view for Gradle tasks
gradle.focusTaskInExplorer: Focus the task in the explorer when running a task
gradle.javaDebug: Debug JavaExec tasks (see below for usage)
gradle.debug: Show extra debug info in the output panel
To provide better compatibility with the Java language support extension, this extension supports the following settings:
java.home: Absolute path to JDK home folder used to launch the gradle daemons
java.import.gradle.user.home: Setting for
java.import.gradle.jvmArguments: JVM arguments to pass to Gradle
java.import.gradle.wrapper.enabled: Enable/disable the Gradle wrapper
java.import.gradle.version: Gradle version, used if the gradle wrapper is missing or disabled
If you're not using the Java language support extension, you can use the standard Java & Gradle environment variables (see below), or standard Gradle settings (eg via
gradle.properties or task configuration), to configure your tasks and/or Gradle settings.
Supported Environment Variables
Most of the standard Java & Gradle environment variables are supported:
JAVE_HOME (overridden by
GRADLE_USER_HOME (overridden by
Setting Project Environment Variables
You can use an environment manager like direnv to set project specific environment variables, or set the variables in the terminal settings within
.vscode/settings.json, for example:
Note, the VS Code settings take precedence over the environment variables.
Debug JavaExec Tasks
This extension provides an experimental feature to debug JavaExec tasks. Before using this feature you need to install the Debugger for Java and Language Support for Java extensions.
To enable this feature you need to specify which tasks can be debugged within your project
You should now see a
debug command next to the
run command in the Gradle Tasks view. The
debug command will start the Gradle task with jdwp
jvmArgs and start the vscode Java debugger.
This extension provides an API which you can use in your own 3rd-party vscode extension.
👉 Extension API
View logs by selecting "Gradle Tasks" in the output panel
Task output will be shown in the Terminal panel
Task output is truncated
The integrated terminal has a limited buffer size and will not show the full output for tasks that generate a large output. Increase the terminal buffer size in your settings, for example:
Gradle: Configure project
When you open a Gradle project for the first time, the Gradle wrapper will start downloading the Gradle distribution. This process can take a while. As there's no progress events emitted via the Tooling API for this process, the extension will simply report "Gradle: Configure project". You can however view progress by selecting the "Gradle Tasks Server" process in the terminal panel to view download progress.
Set the "gradle.debug" setting to "true" to view debug logs in the output panel
"No connection to the gradle server. Try restarting the server"
This error means the Gradle Task server has stopped, or there was an error starting it. Click on "Restart Server" to restart it.
If you continue to get this error, view the task error messages by selecting "Gradle Tasks Server" in the Terminal panel.
The task server is started using a shell script generated by CreateStartScripts. The script uses
#!/usr/bin/env sh and is as portable as the gradle wrapper script. If there are any problems executing the start script then it's likely an issue either with your
$PATH, or java was not installed.
The following error demonstrates a typical issue with your
env: sh: No such file or directory
The terminal process terminated with exit code: 127
Use the following task to debug your shell environment within vscode:
"label": "Print task shell info",
"command": "echo \"Path: $PATH \nShell: $SHELL\"",
Check your dotfiles (eg
~/.zshrc) and fix any broken
PATH exports, or override the
PATH env var by setting
terminal.integrated.env in your vscode settings, for example:
Java path problems
You might see an error like:
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
The start script should find the path to Java in the usual locations. If you get this error it suggests an issues with your
$PATH or you simply haven't installed Java. Run the gradle wrapper script (eg
./gradlew tasks) to debug further.
Incompatibility with other extensions
This extension is incompatible with the following extensions:
The reason for the incompatibility is due to the extensions providing the same tasks types (
gradle) with different task definitions.
For general support queries, use the #gradle-tasks channel in the slack development community workspace, or
Refer to CONTRIBUTING.md for instructions on how to run the project.
👉 Architecture Overview