贡献代码
IntelliJ IDEA 设置指南
登录后可跨设备保存划线和私人笔记登录
版权声明配置
每个文件都需要在头部包含 Apache 许可证声明。可以在 IntelliJ 中通过添加版权配置文件来自动完成:
打开“Settings/Preferences” → “Editor” → “Copyright” → “Copyright Profiles”。
添加一个新的配置文件,并命名为“Apache”。
将以下文本添加为版权声明文本:
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.打开“Editor” → “Copyright”,将“Apache”配置文件选为本项目的默认配置文件。
点击“Apply”。
必需的插件
打开“Settings/Preferences” → “Plugins”,并选择“Marketplace”选项卡。搜索以下插件,进行安装,如有提示请重启 IDE:
你还需要安装 google-java-format 插件。但是,该插件需要特定版本。请下载 google-java-format v1.7.0.6 并按以下步骤安装。请务必不要更新该插件。
- 打开“Settings/Preferences” → “Plugins”。
- 点击齿轮图标,选择“Install Plugin from Disk”。
- 找到已下载的 ZIP 文件并选择它。
Java 代码格式化
Kyuubi 使用 Spotless 配合 google-java-format 来格式化 Java 代码。
建议通过以下设置自动格式化你的代码:
- 打开“Settings/Preferences” → “Other Settings” → “google-java-format Settings”。
- 勾选复选框以启用该插件。
- 将代码风格改为“Default Google Java style”。
- 打开“Settings/Preferences” → “Tools” → “Actions on Save”。
- 选择“Reformat code”。
如果你使用的 IDEA 版本为 2021.1 及以下,请用 Save Actions 插件替代上述第 4 步和第 5 步。
Scala 代码格式化
按以下步骤启用 Scalafmt:
- 打开“Settings/Preferences” → “Editor” → “Code Style” → “Scala”
- 将“Formatter”设置为“Scalafmt”
- 启用“Reformat on file save”
Scala 的 Checkstyle
启用 Scalastyle 的方法如下:
- 进入「Settings/Preferences」→「Editor」→「Inspections」。
- 搜索「Scala style inspection」并启用它。
评论
登录后参与评论
正在加载评论…
KnowForge