<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/module-dependencies/SKILL.md -->
Module Dependencies Management
Documentation
- Modularization Overview - Module organization principles:
- Granularity of Modules
- Modules in Project Sources
- Modules at Runtime
- Modules in Build Scripts
- Project Structure - Naming conventions, Kotlin usage, dependencies
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 incommunity/.idea/modules.xml - inserts entries in the canonical order:
.imlbasename without the.imlsuffix, matchingorg.jetbrains.intellij.build.ModulesXml - removes trailing line breaks from the listed
.imlfiles when--fix-iml-eofis passed
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:
- 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`
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:
- Edit the
.iml. - Run
bun build/jps-module.mjs register <path-to-iml> --fix-iml-eoffor every changed module file. - Run
./build/jpsModelToBazel.cmdso generatedBUILD.bazelfiles match the.imlsource of truth. - Verify compilation or tests for the affected module.