Run Gradle tasks in VS Code.
- VS Code >= 1.45.0
- Java >= 8
- Local Gradle wrapper executables must exist at the root of the workspace folders
This extension provides a visual interface for your Gradle build. It supports whatever Gradle supports and is language agnostic, but can work nicely alongside other extensions like the Java language support extension.
Access the Gradle views by clicking on the Gradle icon the activity bar.
List projects and tasks
A Gradle build can have one or more projects. Projects are listed in a flat list with the root project listed first, and sub-projects listed alphabetically thereafter.
When you expand a project, tasks are listed in a tree, grouped by the task group. You can toggle the display of the tasks by clicking on the Show Flat List
/Show Tree
button in the treeview header.

Run tasks
Tasks can be run via:
Gradle Tasks
,Pinned Tasks
orRecent Tasks
treeviewsRun Task
commandRun a Gradle Build
command
A running task will be shown with an animated "spinner" icon in the treeviews, along with Cancel Task
& Restart Task
buttons. The Cancel Task
button will gracefully cancel the task. The Restart Task
button will first cancel the task, then restart it.

A task will be run a vscode terminal where you can view the task output.
Send a SIGINT signal (ctrl/cmd + c) in the terminal to gracefully cancel it.

Tasks run via the Run a Gradle Build
command are not reflected in any of the treeviews. Use this command to specify your own Gradle build arguments, for example to run multiple tasks or to exclude tasks.

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 .vscode/settings.json
.
You also need to specify whether you want to clean output cache before debugging, to ensure Gradle doesn't skip any tasks due to output caching (this is most useful when debugging tests).
Output cache is cleaned by adding a
cleanTaskName
task (egcleanTest
) to the build.
Example config:
"gradle.javaDebug": {
"tasks": [
"run",
"test",
"subproject:customJavaExecTask"
],
"clean": true
}
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.
Pin tasks
As there could be many tasks in a Gradle project, it can be useful to pin commonly used tasks. Pinned tasks will be shown in a seperate view. Pin a task by accessing the task context menu (by right-clicking a task). You can also pin a task with specific arguments.

To remove a pinned a task, access the task context menu and select Remove Pinned Task
, or clear all pinned tasks by clicking on the Clear Pinned Tasks
button in the treeview header.

Protip: for easier access to pinned tasks, drag and drop the
Pinned Gradle Tasks
view into the explorer view.
List recent tasks
Recently run Gradle tasks are listed in a seperate treeview. This can be useful to see a history of tasks and to easily access the associated task terminals.
The number shown next to the task is the amount of times the task has been run. Click on the Show Terminal
button next to a task to view the most recent terminal for that task. Click on the Close Terminal/s
button to close the terminal/s for that task.
Click on the Clear Recent Tasks
button in the treeview header to remove all recent tasks from the list, or click on the Close All Terminals
button to close all task terminals.

List & kill Gradle daemons
Gradle daemon processes are listed by their process ID in a seperate treeview and can have the following states: IDLE
, BUSY
, STOPPED
, STOPPING
, CANCELED
.
Stop individual daemons by clicking on the Stop Daemon
button next to the listed daemon.
Stop all daemons by clicking on the Stop Daemons
button in the treeview header.

After stopping a daemon, it will remain in the STOPPED
state for a while, but the underlying process won't exist. This is the default Gradle behaviour.
Most of the time there should be no reason to stop a daemon. View more info on the Gradle Daemon from the Gradle website.
The extension uses the Gradle wrapper to list daemons, and is quite a slow process. If the daemon view is not useful for you, you can simply collapse the view, or disable it completely.
Full features list
- List Gradle Tasks & Projects
- Run Gradle tasks as VS Code tasks
- Supports massive Gradle projects (eg with 10000+ tasks)
- Uses the Gradle Tooling API to discover and run Gradle tasks
- Uses a long running gRPC server which provides good performance
- Supports Kotlin & Groovy build files
- Supports multi-project builds
- Supports multi-root workspaces
- Supports nested projects (enabled via setting)
- Show flat or nested tasks in the explorer
- Gracefully cancel a running task
- Debug JavaExec tasks
- Run/debug a task with arguments (supports both build & task args, eg
gradle tasks --all --info
) - Pin tasks
- List recent tasks
- List & stop daemons
- Reports Gradle dist download progress
This extension contributes the following settings:
gradle.autoDetect
: Automatically detect Gradle tasksgradle.focusTaskInExplorer
: Focus the task in the explorer when running a taskgradle.nestedProjects
: Process nested projects (boolean or an array of directories)gradle.javaDebug
: Debug JavaExec tasks (see below for usage)gradle.debug
: Show extra debug info in the output panelgradle.disableConfirmations
: Disable the warning confirm messages when performing batch actions (eg clear tasks, stop daemons etc)
Set Gradle & Java options with standard environment variables or standard Gradle settings (eg via gradle.properties
or task configuration).
JAVE_HOME
GRADLE_USER_HOME
Note, the VS Code settings take precedence over the environment variables.
Use an environment manager like direnv to set project specific environment variables
Compatibility with the Java language support extension
This extension supports the following settings which are contributed by the Java language support extension:
java.home
: Absolute path to JDK home folder used to launch the Gradle daemonsjava.import.gradle.java.home
: Absolute path to JDK home folder used to launch the Gradle daemons (if set, this value takes precedence overjava.home
)java.import.gradle.user.home
: Setting forGRADLE_USER_HOME
java.import.gradle.jvmArguments
: JVM arguments to pass to Gradlejava.import.gradle.wrapper.enabled
: Enable/disable the Gradle wrapperjava.import.gradle.version
: Gradle version, used if the Gradle wrapper is missing or disabled
There are cases where Gradle tasks will generate Java classes. To ensure these Java classes are indexed correctly by the Java language server, you need to ensure the paths are added to the .classpath
, and this is typically achieved using Gradle sourceSets
.
Once you've configured your sourceSets
correctly, follow these steps:
- Generate your classes by running the relevant Gradle Task
- Force the Language Server to index the generated classes by right-clicking on
build.gradle
and selectingUpdate project configuration
.
At this point the Gradle sourceSet
paths will be added to the .classpath
and the Language Server will automatically update references when those classes change.
This extension provides an API which can be used by 3rd-party vscode extensions.
π Extension API
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:
{
"terminal.integrated.scrollback": 5000
}
"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" in the output 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 is not installed.
The following error demonstrates a typical issue with your PATH
:
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:
{
"version": "2.0.0",
"tasks": [
{
"label": "Print task shell info",
"type": "shell",
"command": "echo \"Path: $PATH \nShell: $SHELL\"",
"problemMatcher": []
}
]
}
Check your dotfiles (eg ~/.bash_profile
, ~/.bashrc
, ~/.zshrc
) and fix any broken PATH
exports. See Issues with environment vars
below for more information.
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, or see Issues with environment vars
below for more information.
Another potential problem is that the PATH
or JAVA_HOME
environment vars have been defined within .bashrc
. See Issues with environment vars
below for more information.
Issues with environment vars
(The following is only relevant for MacOS & Linux.)
The Gradle Server is launched inside a non-interactive non-login shell, which loads the profile script (not the rc script). This means the shell will not load, for example, ~/.bashrc
. If you've defined PATH
or other environment variables within ~/.bashrc
, they will not be available for the server startup script and not be available to Gradle.
Generally, environment settings should be defined in in ~/.bash_profile
, but as a workaround, you can load ~/.bashrc
from within ~/.bash_profile
for example:
if [ -r ~/.bashrc ]; then
source ~/.bashrc
fi
"Orphaned" Java processes after quitting VS Code
You might notice some Java processes are not closed after existing VS Code. These processes are the Gradle Daemons that Gradle spawns. This is the default behaviour of Gradle.
You'll have N
processes per Gradle version. Eventually Gradle will shut them down. Read more about the Gradle Daemon.
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
- π Submit a bug report
- π Submit a feature request
Refer to CONTRIBUTING.md for instructions on how to run the project.
- Originally forked from Cazzar/vscode-gradle
- Inspired by the built-in npm extension
- Thanks to @hanct for providing feature suggestions and BETA testing
- Thanks to @dcermak for providing inspiration to write some unit tests
- Thanks to all who have submitted bug reports and feedback
Check out vscode-spotless-gradle which formats your source files using Spotless & Gradle.
See CHANGELOG.md.
See LICENSE.md.