简体   繁体   中英

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?

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 .

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM