vscode-gradle
vscode-gradle copied to clipboard
Can't set gradle task as default
Extension Name: vscode-gradle Extension Version: v3.12.2 OS Version: Windows 10 VSCode version:
Version: 1.68.1 (user setup) Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630 Date: 2022-06-14T12:48:58.283Z Electron: 17.4.7 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Windows_NT x64 10.0.19044
Describe the bug When I configure the VS Code default build task, the automatically-populated gradle task in tasks.json fails to parse and I cannot run the task.
To Reproduce Starting from a new workspace. Running "gradle: build" from the gradle tab does successfully build my project. However, I would like to be able to build it with a single key combo rather than clicking through menus.
Run "Configure default build task" Select the gradle task I want ("gradle: build").
The tasks.json file is populated like this:
{
"tasks": [
{
"type": "gradle",
"id": "c:\\code\\becky\\EyeMineModsbuildarchitectury-eyemine",
"script": "build",
"description": "Assembles and tests this project.",
"group": {
"kind": "build",
"isDefault": true
},
"project": "architectury-eyemine",
"buildFile": "C:\\code\\becky\\EyeMineMods\\build.gradle",
"rootProject": "architectury-eyemine",
"projectFolder": "c:\\code\\becky\\EyeMineMods",
"workspaceFolder": "c:\\code\\becky\\EyeMineMods",
"args": "",
"javaDebug": false,
"problemMatcher": [
"$gradle"
],
"label": "gradle: build"
}
]
}
This error occurs:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':common'.
> java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 8 column 14 path $.tasks[0].group
I can fix this error by replacing the group object with "group": "build" which still lets me build with a single shortcut so long as there is only one build task specified in tasks.json. The JSON is now:
{
"tasks": [
{
"type": "gradle",
"id": "c:\\code\\becky\\EyeMineModsbuildarchitectury-eyemine",
"script": "build",
"description": "Assembles and tests this project.",
"group": "build",
"project": "architectury-eyemine",
"buildFile": "C:\\code\\becky\\EyeMineMods\\build.gradle",
"rootProject": "architectury-eyemine",
"projectFolder": "c:\\code\\becky\\EyeMineMods",
"workspaceFolder": "c:\\code\\becky\\EyeMineMods",
"args": "",
"javaDebug": false,
"problemMatcher": [
"$gradle"
],
"label": "gradle: build"
}
]
}
Now I get a different error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':common'.
> java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 14 column 13 path $.tasks[0].args
I have tried replacing the "args": "" with "args": [""] but this is not correct - it does expect a string, and completely fails to parse if you have an array.
I have also tried removing the "args" line altogether. When I then run a build, it works once but strips down the tasks.json to this, which fails next time.
{
"version": "2.0.0",
"tasks": [
{
"label": "gradle: build",
"type": "gradle",
"group": "build"
}
]
}
Expected behavior Building a gradle task via automatically setting up a default build task should work the same as if I run the gradle task from the gradle tab
Screenshots If applicable, add screenshots to help explain your problem.
Output from "Gradle for Java"
[error] [gradle-server] Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.0.2-bin.zip'.
[error] Error running build: build: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.0.2-bin.zip'.
Does the bug still exist if you disable all other extensions? Yes