Module dependencies

From JetBrains/intellij-community · View interactive version

Module dependencies is an AI agent skill from the GitHub repository JetBrains/intellij-community. Add or modify IntelliJ module dependencies in `.iml` files.

How to use this skill

Skill file

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

Module Dependencies Management

Documentation

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:

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

Library Version Changes

To change the version or the library block of a repository library, follow Library Version Changes.

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:

Skip Generation Marker

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

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

For a custom jps_test target with this marker, see community/platform/eel/BUILD.bazel.

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. The generator rejects a module that has both production and test source roots.

Put the tests in a separate test module.

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/platform/configuration-store-impl/intellij.platform.configurationStore.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. 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.
  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.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.