跳到正文
cccskills
免费在 GitHub 公开中文介绍

module-dependencies

本技能指导您在 IntelliJ 的 `.iml` 文件中添加或修改模块依赖,并同步相关生成文件和构建信息,涵盖模块注册、Bazel 文件、库版本更新及测试访问 Kotlin 内部声明。

原文查看原文说明

Add or modify IntelliJ module dependencies in `.iml` files.

JetBrains/intellij-community星标 20,685(GitHub 20,685 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 在 `.iml` 中添加模块依赖
  • 修改后同步生成的 Bazel 文件
  • 检查库版本更新
  • 让测试使用 Kotlin 内部声明

中文介绍

功能

本技能指导您在 IntelliJ JPS 模块的 .iml 文件中添加或修改依赖,并使相关注册信息与生成文件保持一致。创建或编辑模块后,可用 jps-module.mjs 检查注册状态,再用 jpsModelToBazel.cmd 根据 .iml 重新生成 Bazel BUILD 文件。更新库版本时,流程还包括使用专用 dashboard 命令检查与 POM 的构件一致性,并更新 Fleet 中复制的版本和 Bazel 锁文件。它也说明如何设置测试模块访问 Kotlin internal 声明,以及如何处理自动生成区域。

适用场景

需要补充缺失的依赖,或想确认修改 .iml 后构建定义是否仍然过时时,可以使用本技能。它也适用于库版本升级,以及让另一个模块中的测试使用内部声明的配置。

使用示例

  • “为这个模块添加所需依赖,并同步生成文件。”
  • “更新库版本,并检查相关副本和锁文件。”
  • “让测试模块能够访问目标 internal 声明。”

注意事项

这些步骤适用于遵循 IntelliJ 项目结构的代码库。运行 downloadLibraries.cmd 来复现库解析需要 Space 认证信息。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足资料列出会生成或更新文件的命令,但未明确说明运行前确认步骤。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足需要 IntelliJ 仓库结构和 Space 认证信息,但未说明配置步骤。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md9.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/module-dependencies/SKILL.md -->

Module Dependencies Management

This document describes how to manage module dependencies when working with IntelliJ IDEA codebase.

Documentation

Build System Overview

The repository uses a hybrid build system:

  • JPS (*.iml files): Source of truth for module dependencies
  • Bazel (BUILD files): Auto-generated from *.iml files
  • Generator: run build/jpsModelToBazel.cmd after changing .iml files

JPS Module Registration Helper

When creating or editing a JPS module .iml, use the helper instead of hand-editing project module lists:

bun build/jps-module.mjs register <path-to-iml> --fix-iml-eof

The helper:

  • registers the module in .idea/modules.xml
  • also registers community/... modules in community/.idea/modules.xml
  • inserts entries in the canonical order: .iml basename without the .iml suffix, matching org.jetbrains.intellij.build.ModulesXml
  • removes trailing line breaks from the listed .iml files when --fix-iml-eof is passed

Use bun build/jps-module.mjs check <path-to-iml> --fix-iml-eof to verify without writing.

Running the IML-to-Bazel Generator

To manually run the converter that generates Bazel BUILD files from .iml files:

./build/jpsModelToBazel.cmd

This is useful when:

  • The automatic converter didn't run (e.g., .iml files were modified outside the IDE)
  • You need to regenerate BUILD files after git operations
  • Troubleshooting build system synchronization issues

Library Version Changes

Bump a library with the dashboard tool, not by hand: bun community/build/libraries-dashboard/libraries-dashboard.mjs bump <groupId:artifactId>=<version> --kind=wrapper. It rewrites the maven-id, the jar URLs and every <sha256sum>, and prints the follow-up commands.

The artifact list must match the POM

JPS resolves a repository library from its POM and requires the <verification> artifact set to equal the resolved jar set. Bazel downloads the listed URLs instead, so a mismatch passes every local Bazel build and fails the first JPS step on TeamCity ("Library 'x': not found expected artifacts"). Two rules follow:

  • A transitive artifact in a library block stays at the version the POM of the main artifact declares. Do not align it with another wrapper by editing the version.
  • To share one version across wrappers, exclude the dependency and add a module dependency on its wrapper. community/libraries/mockk/jvm/intellij.libraries.mockk.jvm.iml excludes byte-buddy-agent and depends on intellij.libraries.byte.buddy.agent.

The bump command checks a multi-artifact library against the direct dependencies of the new POM and fails on a mismatch. After a manual edit of a library block, run the same check:

bun community/build/libraries-dashboard/libraries-dashboard.mjs check <groupId:artifactId>

The check reads one POM without its parents and compares direct dependencies only. To reproduce the JPS resolution that TeamCity runs before every build, run ./build/downloadLibraries.cmd. It needs Space credentials.

Version copies outside the JPS model

After you change the version of a repository library in an *.iml or in .idea/libraries/*.xml, run the Fleet generator in the monorepo checkout:

./fleet/build/generateProjectModel.cmd dump

The Fleet generator copies the JPS library versions into fleet/build/jps-library-mappings.tsv and both fleet/kmp.MODULE.bazel files. Its check mode fails on drift.

When the dump changes a kmp.MODULE.bazel, update both Bazel lockfiles:

./bazel.cmd mod deps --lockfile_mode=update
(cd community && ./bazel.cmd mod deps --lockfile_mode=update)

The kmp module extension records its artifact list in the MODULE.bazel.lock of each module, and CI runs Bazel with --lockfile_mode=error, so a stale lockfile fails the build. bun community/build/libraries-dashboard/libraries-dashboard.mjs bump prints these commands after a bump.

Some files outside the JPS model copy a library version, and the project structure tests check each copy:

  • community/platform/jps-bootstrap/pom.xml copies every library that jps-bootstrap uses (JpsBoostrapStructureTest).
  • JetBrainsAnnotationsExternalLibraryResolver.VERSION copies org.jetbrains:annotations (IdeaUltimateProjectStructureTest).

The bump command rewrites these copies and reports a copy that still differs. After a manual version change, edit them by hand. Then run the tests that gate the Smoke Tests build:

./tests.cmd --module intellij.projectStructureTests --test 'com.intellij.ideaProjectStructure.fast.*'

These tests also check the Kotlin, Compose and LanguageTool version alignment and the unused project libraries.

BUILD.bazel Auto-Generated Sections

BUILD.bazel files have auto-generated sections marked with comments:

### auto-generated section `build module.name` start
... generated content ...
### auto-generated section `build module.name` end

### auto-generated section `test module.name` start
... generated content ...
### auto-generated section `test module.name` end

Key rules:

  • Content inside auto-generated sections is overwritten by the generator
  • Content outside auto-generated sections is preserved during regeneration

Skip Generation Marker

To prevent auto-generation of a section (so you can provide custom content):

### skip generation section `test module.name`

Example - Custom test target with preserved content:

load("@community//build:tests-options.bzl", "jps_test")

# Custom test target (before auto-generated sections)
jps_test(
  name = "my-tests_test",
  runtime_deps = [
    ":my-tests_test_lib",
    "//:main_test_lib",
  ],
)

### skip generation section `test my.module.name`

### auto-generated section `build my.module.name` start
... (let generator handle the build section)

Content Modules and Wrapper Plugins

Product layouts can include content modules directly. If production runtime already gets a dependency from a content module in the product layout, that content-module dependency can be enough and does not automatically require adding a wrapper plugin dependency to a production .iml or plugin descriptor.

Test plugin resolution is different because tests often do not run with the full production product layout or flat classpath. If a test module loads a plugin whose dependencies include content modules owned by a wrapper plugin, add the wrapper plugin as a test/runtime dependency in the test module .iml instead of broadening the production module dependency. For example, a test that needs Problems View content modules may need intellij.platform.problemView.plugin as a runtime dependency even when the production module only depends on Problems View content modules.

Test Access to internal Declarations

A Kotlin internal declaration is visible to a test only when the test module is a friend of the production module.

The same module. A test source root of a module sees the internal declarations of the production sources. Nothing to configure. The generator adds the production target to the associates attribute of the _test_lib target.

A separate test module. Add the TestModuleProperties component to the test module .iml:

  <component name="TestModuleProperties" production-module="intellij.platform.configurationStore.impl" />

Then run ./build/jpsModelToBazel.cmd. The generator moves the production module from deps to associates, and the Kotlin compiler gets it as a friend path. For a complete example, see community/notebooks/visualization/intellij.notebooks.visualization.tests.iml.

The component holds one module. A test module cannot be a friend of two production modules, and the friendship is not transitive.

Java. Java has no internal modifier. Put the test class in the same package as a package-private declaration. For a member that carries @ApiStatus.Internal, add @VisibleForTesting or @TestOnly, because the compiler makes no check here.

Important Notes

When you need to fix missing dependencies:

  1. Edit the .iml with the repo-approved edit tool.
  2. Run bun build/jps-module.mjs register <path-to-iml> --fix-iml-eof for every changed module file.
  3. Run ./build/jpsModelToBazel.cmd so generated BUILD.bazel files match the .iml source of truth.
  4. Verify compilation or tests for the affected module.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

actions

免费有简介

实现或修改 IntelliJ `AnAction`,并在 `plugin.xml` 中注册。将显示名称和说明写入消息资源文件,按需设置图标,并通过事件协程作用域启动挂起任务,避免同步处理阻塞 IDE。

  • 为 IDE 菜单添加操作
  • 修改操作注册或图标
  • 整理操作名称和说明
JetBrains/intellij-community2.1万2026年10月29日 更新

bazel-test-migration

免费有简介

将 IntelliJ JPS 测试模块迁移到 Bazel,并排查仅在 Bazel 中出现的失败。根据症状检查依赖、插件、测试数据和 runfiles,重新生成并验证目标。

  • 将 JPS 测试模块迁移到 Bazel
  • 排查仅在 Bazel 中失败的测试
  • 检查测试依赖和数据配置
JetBrains/intellij-community2.1万2026年10月29日 更新

code-style

免费有简介

按 IntelliJ 项目规范编写或审查 Kotlin 和 Java 代码,涵盖语言选择、格式、密封类型、线程注解及控制流异常处理。

  • 按 IntelliJ 规范编写 Kotlin
  • 审查 Java 代码
  • 检查异常处理和密封类型分支
JetBrains/intellij-community2.1万2026年10月29日 更新

commits

免费有简介

本指南帮助您按 IntelliJ 项目规则拆分更改并撰写提交信息:有工单时使用编号和变更说明,无工单时使用标签与子系统名,并在需要时说明原因和决定。

  • 按项目格式编写带工单号的提交信息
  • 整理测试或文档提交并选择合适标签
  • 按规则修改已有提交信息
JetBrains/intellij-community2.1万2026年10月29日 更新

使用多个 Python 类型检查器比较代码片段或文件的类型推断和报错判断,并汇总各工具的结论、耗时与诊断信息,可保存为 Markdown 报告。

  • 比较不同检查器的类型推断
  • 确认代码是否会被判为类型错误
  • 查看多个工具的诊断差异
JetBrains/intellij-community2.1万2026年10月29日 更新

整理 Compose Desktop 界面中的状态和副作用,让可组合函数负责绘制,由展示器或协调器处理应用决策。了解状态归属、Effect、可复用组件接口、延迟列表键、动画和性能,适用于单项界面修改。

  • 分离界面绘制与展示器决策
  • 整理界面状态的归属
  • 检查 Effect 键和协程用法
JetBrains/intellij-community2.1万2026年10月29日 更新

查看 JetBrains 的全部技能

报告此技能的问题