vscode-gradle icon indicating copy to clipboard operation
vscode-gradle copied to clipboard

Debugging with arguments not working

Open szoszk opened this issue 3 years ago • 1 comments

Extension Name: vscode-gradle Extension Version: 3.6.1 OS Version: Windows 10 21H1 VSCode version: 1.58.2

Describe the bug As already mentioned in #876, debugging with an argument doesn't seem to work. It shows the error Unexpected multiple tasks when debugging. Running (without debugging) the same task with additionally the --debug-jvm argument and then connecting the debugger to port 5005, works without problems.

To Reproduce Debug a task by right-clicking it, clicking on Debug Task With Args and then enter an argument and press enter

Expected behavior Task with arguments is run in debug mode.

Output from "Gradle Tasks" [error] [gradle-server] Unexpected multiple tasks when debugging [error] Error running build: foo:test --tests="foo.bar.tests.test1": Unexpected multiple tasks when debugging [error] Unable to start Java debugging: The task completed without the debugger being attached

Another argument: [error] [gradle-server] Unexpected multiple tasks when debugging [error] Error running build: foo:bootRun -q: Unexpected multiple tasks when debugging [error] Unable to start Java debugging: The task completed without the debugger being attached

Does the bug still exist if you disable all other extensions? Yes. I only enabled the required extensions: Debugger for Java, Gradle Language Support, Gradle Tasks and Language Support for Java(TM) by Red Hat

szoszk avatar Jul 30 '21 17:07 szoszk

As already described #876 and this issue, I too am also experiencing the exact same issue. Is there any advice or recommendations on how to work around (or fix) this issues? Not being able to pass arguments when debugging is kind of a major issue.

MikeTheSnowman avatar Oct 24 '21 11:10 MikeTheSnowman

Caused by this, not sure if @CsCherrYY has any potential solutions in mind? https://github.com/microsoft/vscode-gradle/blob/develop/gradle-server/src/main/java/com/github/badsyntax/gradle/GradleBuildRunner.java#L123

dscalzi avatar Mar 06 '23 16:03 dscalzi

thank you @dscalzi , I guess the problem here is that we put the tasks and arguments together, The args in your post code contains both tasks and arguments here, so adding an argument will always throw an exception.

A way to fix maybe we can distinguish tasks and arguments by starting -, so we can exactly know if multiple tasks are found here.

CsCherrYY avatar Mar 07 '23 02:03 CsCherrYY