「VS-CODE」- 配置 Apache Groovy 开发环境

vscode-groovy-lint | by Nicolas Vuillamy

The Apache Groovy programming language – IDE integration

插件:https://marketplace.visualstudio.com/items?itemName=NicolasVuillamy.vscode-groovy-lint
仓库:https://github.com/nvuillam/vscode-groovy-lint

vscode-groovy-lint,其集成 npm-groovy-lint 工具,而 npm-groovy-lint 又集成 CodeNarc 工具

npm-groovy-lint | Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files using command line

CodeNarc | CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues and more. A flexible framework for rules, rulesets and custom rules means it’s easy to configure CodeNarc to fit into your project. Build tool, framework support, and report generation are all enterprise ready.

CodeNarc requires:
  • Java 1.8 or later
  • Groovy version 3.0 or later; Groovy version 4.0 or later for the 3.x.x-groovy-4.x versions of CodeNarc
  • SLF4J API and binding jar(s)
  • GMetrics or GMetrics-Groovy4 2.1.0 or later, if using the Size/Complexity rules

简而言之,我们安装并使用 vscode-groovy-lint 即可。除非必要,否则无需关注 npm-groovy-lint 与 CodeNarc 工具。

代码缩进

其使用 “groovyLint.format.useDocumentIndentSize”: true 配置,所以我们在编辑器右下角,Space 中直接修改,然后 Alt Shift I 直接进行格式化即可。

JAVA SDK | Flatpak

https://superuser.com/questions/1698922/how-to-give-vscode-flatpak-package-access-to-system-sdk-for-java

加入 VS Code 通过 Flatpak 安装,如果需要安装 Java SDK 环境,需要通过 Flatpak 安装:

flatpak search Sdk | grep -i jdk
flatpak install org.freedesktop.Sdk.Extension.openjdk17

flatpak ps
flatpak enter <Instance> sh
cd /usr/lib/sdk/openjdk…

在 settings.json 中,添加相关配置:

    "java.jdt.ls.java.home": "/usr/lib/sdk/openjdk17/jvm/openjdk-17.0.1/"`,
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-17",
            "path": "/usr/lib/sdk/openjdk17/jvm/openjdk-17.0.1/",
            "default": true
        }
    ],