3.10.1 ā€¢ Published 2 years ago

vscode-gradle v3.10.1

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

VS Code Gradle Tasks

Marketplace Version Build status Security Rating Visual Studio Marketplace Installs GitHub bug issues

Run Gradle tasks in VS Code.

Gradle Tasks Screencast

Features

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

Requirements

  • Java >= 8 must be installed
  • Local Gradle wrapper executables must exist at the root of the workspace folders

Settings

This extension contributes the following settings:

  • gradle.autoDetect: Automatically detect Gradle tasks
  • gradle.enableTasksExplorer: Enable an explorer view for Gradle tasks
  • gradle.taskPresentationOptions: Task presentation options, see tasks output behaviour
  • 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 GRADLE_USER_HOME
  • 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 java.home)
  • GRADLE_USER_HOME (overridden by java.import.gradle.user.home)

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:

{
  "terminal.integrated.env.osx": {
    "GRADLE_USER_HOME": "${workspaceFolder}/.gradle"
  }
}

Note, the VS Code settings take precedence over the environment variables.

Debugging JavaExec Tasks

Debug Screencast

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 file:

"gradle.javaDebug": {
    "tasks": [
        "run",
        "test",
        "subproject:customJavaExecTask"
    ]
}

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.

Debugging Limitations

You'll need to remove any jdwp options that might have been set in your task configuration (eg via jvmArgs).

Snippets

This extensions provides snippets for the groovy and kotlin build files:

  • cgt: Create a new Gradle task

Extension API

This extension exposes a runTask API with the following definition:

function runTask(
  projectFolder: string, // absolute path of root project folder
  taskName: string,
  args?: ReadonlyArray<string>,
  onOutput?: (output: Output) => void
): Promise<void>;

Import the API type definition like so:

import { ExtensionApi as GradleTasksApi } from "vscode-gradle";

You can use this API to run Gradle tasks. It doesn't matter when you call this method as it will wait for tasks to be loaded before running the task.

Refer to vscode-spotless-gradle for example API usage.

Troubleshooting

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.

PATH problems

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": []
    }
  ]
}

Fixing your $PATH

Check your dotfiles (eg ~/.bashrc, ~/.bash_profile, ~/.zshrc) and fix any broken PATH exports, or override the PATH env var by setting terminal.integrated.env in your vscode settings, for example:

"terminal.integrated.env.osx": {
  "PATH": "/put/your:/paths/here",
}

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.

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.

Support

For general support queries, use the #gradle-tasks channel in the slack development community workspace, or

Contributing

Refer to CONTRIBUTING.md for instructions on how to run the project.

Credits

Release Notes

See CHANGELOG.md.

License

See LICENSE.md.

3.10.1

2 years ago

3.10.0

2 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.5.2

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.9

4 years ago

3.4.8

4 years ago

3.4.7

4 years ago

0.0.285934747

4 years ago

0.0.285932723

4 years ago

3.4.6

4 years ago

0.0.256279716

4 years ago

3.4.4

4 years ago

3.4.5

4 years ago

3.4.3

4 years ago

3.4.2

4 years ago

3.4.1

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

0.0.131417341

4 years ago

0.0.131430468

4 years ago

0.0.131364606

4 years ago

0.0.131314464

4 years ago

0.0.131424647

4 years ago

0.0.131439654

4 years ago

0.0.131481354

4 years ago

0.0.131378339

4 years ago

0.0.131475752

4 years ago

0.0.131366681

4 years ago

0.0.131337289

4 years ago

0.0.127676173

4 years ago

0.0.128537602

4 years ago

0.0.128258577

4 years ago

0.0.126792561

4 years ago

0.0.126750456

4 years ago

0.0.125239175

4 years ago

0.0.124810122

4 years ago

0.0.124722701

4 years ago

3.0.8

4 years ago

0.0.123404467

4 years ago

0.0.120741347

4 years ago

0.0.117188420

4 years ago

0.0.116587377

4 years ago

0.0.116579667

4 years ago

0.0.116570817

4 years ago

0.0.116112232

4 years ago

0.0.115881049

4 years ago

0.0.115647467

4 years ago

0.0.115437617

4 years ago

0.0.114924727

4 years ago

0.0.113765621

4 years ago

0.0.113773422

4 years ago

3.0.7

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.7.12

4 years ago

2.7.11

4 years ago

2.7.10

4 years ago

2.7.9

4 years ago

2.7.8

4 years ago

2.7.7

4 years ago

2.7.6

4 years ago

2.7.5

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago