'Compile Groovy in VSCode

I've found the vscode-groovy extension that does the formatting and highlighting, but I'm really having trouble getting the compiler/debugger configured.

I figure I could just point JAVA_HOME to my Groovy compiler, but is there a better way to do this?



Solution 1:[1]

I had the same problem, so I did the following steps:

  1. Installation of Groovy. Firstly, I've installed the latest stable pack from the Groovy website. This is basically downloading the pack and unzipping it to a certain local folder.
  2. Add Groovy bin to PATH variable. Just add the bin folder of the unzipped Groovy pack to the environment variable PATH.
  3. Install the Code Runner extension for Visual Studio Code. This extension can be downloaded from the VS marketplace. If this is done, then you can at least run the groovy script already. Just open the context menu of the file in the VS Code explorer and click Run code.

If you want to debug the script, then you should put it in a java class and debug it as described here.

Solution 2:[2]

My way as of today:

  1. Install Java, Gradle, Visual Studio Code with extensions vscjava.vscode-java-pack and richardwillis.vscode-gradle-extension-pack.
  2. In an empty folder, run gradle init, Type of project application, Implementation language Groovy, use defaults for the rest.
  3. Open folder in Visual Studio Code.
  4. In left toolbar, select the Gradle icon, expand app, tasks, application, select run and click the icon Run task.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 budul
Solution 2 GeorgesZ