本文へ移動
cccskills
無料GitHub で公開日本語紹介

pseudo-kmp

IntelliJのJPS環境でKotlinの疑似マルチプラットフォームモジュールを作成・移行し、共通宣言とJVMなど各環境の実装を対応づけるスキルです。

原文原文の説明を見る

Create or modify IntelliJ pseudo-KMP expect/actual modules.

JetBrains/intellij-communityスター 20,664(GitHub 20,664 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 疑似KMPモジュールを新設したいとき
  • 既存モジュールを疑似KMPへ移行したいとき
  • 共通宣言と環境別関数を対応づけたいとき

日本語での紹介

できること

IntelliJのJPSビルド環境で、Kotlin Multiplatformの仕組みを疑似的に使うモジュールの作成や移行を支援します。共通コードとJVM、WasmJs、JS、Native向けコードのソースフォルダー構成、.imlへの支援モジュール依存やexpects-compiler-pluginの登録、構造テストへの追加方法を確認できます。共通側の関数をlinkToActual()で宣言し、各環境側の関数を@Actualとプラットフォーム接尾辞で対応づける書き方も扱います。許可されるライブラリ依存や、共通ソースセットを示すマーカーファイルについても案内します。

こんなときに便利

IntelliJのモノレポでマルチプラットフォーム向けのモジュールを新設するときや、既存モジュールを疑似KMP構成へ移すときに役立ちます。共通コードと環境ごとの実装を同じモジュール内で整理したい場合や、.imlの設定、依存関係、ソースルートの配置を確認したい場合にも使えます。

使い方の例

  • 「このKotlinモジュールを疑似KMP構成に移す手順を教えて」
  • 「JVM用のactual関数と共通側の宣言を追加して」

注意点

この方式ではトップレベル関数のみが対象で、共通宣言と各環境の実装は同じモジュールに置きます。WasmJsのソースフォルダーは.imlのソースルートに追加しません。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md6.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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

Pseudo-KMP Modules

The monorepo is compiled by JPS, which does not support Kotlin Multiplatform. To emulate KMP expect/actual declarations, the Fleet team created the expects-compiler-plugin. This skill covers how to set up and work with modules that use this mechanism.

Documentation

Module Configuration Checklist

When creating or migrating a pseudo-KMP module:

  1. Register in the structure test. Add your module name to the multiplatformModules list in com.intellij.ideaProjectStructure.fast.MultiplatformModuleStructureTest (tests/ideaProjectStructure/testSrc/com/intellij/ideaProjectStructure/fast/MultiplatformModuleStructureTest.kt).

  2. Use only allowed library dependencies. The test enforces a closed set:

    • kotlin-stdlib
    • kotlinx-coroutines-core
    • kotlinx-coroutines-debug
    • jetbrains-annotations
    • kotlinx-serialization-core
    • kotlinx-serialization-json
    • kotlin-reflect
    • kotlinx-collections-immutable

    If you need a new library, add it to allowedMultiplatformLibraryDependencies in the test. Dependencies on other multiplatform modules (those in multiplatformModules) are also allowed.

  3. Set up source folders:

    • src/ — common code
    • srcJvm/ or srcJvmMain/ — JVM-specific code (Java code can live here too)
    • srcWasmJs/ or srcWasmJsMain/ — WasmJs-specific code
    • srcJsMain/ — JS-specific code
    • srcNativeMain/ — Native-specific code

    Important: Do NOT add srcWasmJs/srcWasmJsMain as a source root in the .iml file. The IDE would try to compile it in JVM mode.

  4. Add the .pseudoCommonKotlinSourceSet marker file to the common source root (e.g., src/.pseudoCommonKotlinSourceSet). This empty file tells the Kotlin plugin that the source set is common code, preventing Optimize Imports from removing imports that are unnecessary on JVM but mandatory in common code (e.g., @JvmStatic, @JvmField).

IML File Setup

Your .iml file needs two things: the multiplatformSupport dependency and the compiler plugin registration.

Use community/platform/util/multiplatform/intellij.platform.util.multiplatform.iml as a reference. To find the current plugin version, check that file rather than hardcoding.

1. Add the support module dependency (PROVIDED scope)

<orderEntry type="module" module-name="intellij.platform.multiplatformSupport" scope="PROVIDED" />

2. Add the Kotlin facet with expects-compiler-plugin

<facet type="kotlin-language" name="Kotlin">
  <configuration version="5" platform="JVM 1.8" allPlatforms="JVM [1.8]" useProjectSettings="false">
    <compilerSettings>
      <option name="additionalArguments" value="-Xjvm-default=all ..." />
    </compilerSettings>
    <compilerArguments>
      <stringArguments>
        <stringArg name="jvmTarget" arg="1.8" />
        <stringArg name="apiVersion" arg="2.3" />
        <stringArg name="languageVersion" arg="2.3" />
      </stringArguments>
      <arrayArguments>
        <arrayArg name="pluginClasspaths">
          <args>$MAVEN_REPOSITORY$/jetbrains/fleet/expects-compiler-plugin/{VERSION}/expects-compiler-plugin-{VERSION}.jar</args>
        </arrayArg>
      </arrayArguments>
    </compilerArguments>
  </configuration>
</facet>

Replace {VERSION} with the version from the reference IML.

Expect/Actual Pattern

Only top-level functions are supported. Both the expect and actual declarations must be in the same module.

Common side (in src/)

Use linkToActual() as the function body:

import fleet.util.multiplatform.linkToActual

internal fun myFunction(param1: String, param2: Int): Boolean = linkToActual()

Platform side (in srcJvm/, srcWasmJs/, etc.)

Annotate with @Actual. The function name must be the expect function name + platform suffix:

import fleet.util.multiplatform.Actual

@Actual
internal fun myFunctionJvm(param1: String, param2: Int): Boolean {
  // JVM implementation
}

Platform suffixes

PlatformSuffixSource folder
JVMJvmsrcJvm/ or srcJvmMain/
WasmJsWasmJssrcWasmJs/ or srcWasmJsMain/
JSJssrcJsMain/
NativeNativesrcNativeMain/
Multi-platform buildImpl(rare)

Real example

Common (community/platform/util/base/multiplatform/src/com/intellij/util/text/CharArrayUtilKmp.kt):

internal fun getCharsPlatformSpecific(
  sequence: CharSequence, srcOffset: Int, dst: CharArray, dstOffset: Int, len: Int
): Boolean = linkToActual()

JVM actual (community/platform/util/base/multiplatform/srcJvmMain/com/intellij/util/text/jvm.kt):

@Actual
internal fun getCharsPlatformSpecificJvm(
  string: CharSequence, srcOffset: Int, dst: CharArray, dstOffset: Int, len: Int
): Boolean {
  if (string is CharBuffer) { /* ... */ }
  return false
}

Code Conversion Notes

  • The monorepo uses the JVM version of the Kotlin standard library, which differs from the common version. Check which declarations are available in common code.
  • @JvmStatic, @JvmField, and similar annotations are not auto-imported in common code. Import them manually. The .pseudoCommonKotlinSourceSet marker prevents the IDE from removing these imports.
  • Java code can remain in platform-specific source sets (srcJvm/).

After Editing

  1. Run ./build/jpsModelToBazel.cmd after modifying any .iml files.
  2. Run MultiplatformModuleStructureTest to validate module structure:
    ./tests.cmd --module tests.ideaProjectStructure --test com.intellij.ideaProjectStructure.fast.MultiplatformModuleStructureTest
    
  3. Lint changed files with mcp__ijproxy__lint_files.

Artifact Publication

The monorepo does not publish multiplatform artifacts to Maven Central directly. Separate repositories with Gradle infrastructure extract module sources, compile with true KMP, and publish. See fleet-multiplatform-deps and fleet-parser-collection in JetBrains Space.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

actions

無料概要あり

IntelliJプラグインのAnActionと登録設定を実装・変更し、表示文言やアイコンの定義、非同期処理の起動方法を整えます。

  • IDEに新しいアクションを追加したいとき
  • アクションの登録やアイコンを変更したいとき
  • 表示名と説明文の定義を整理したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

bazel-test-migration

無料概要あり

IntelliJのJPSテストモジュールをBazelへ移行し、Bazelだけで起きる失敗を依存関係や実行環境から切り分ける手順を案内します。

  • JPSテストをBazelへ移行したいとき
  • Bazelだけで起きるテスト失敗を調べたいとき
  • テストの依存関係やデータ設定を確認したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

code-style

無料概要あり

IntelliJのKotlin・Javaコードを新規作成やレビューする際に、言語の選び方、書式、型の扱い、例外処理などのプロジェクト規約に沿って整えるスキルです。

  • IntelliJ規約に沿ってKotlinを書きたいとき
  • Javaコードをレビューしたいとき
  • 例外処理やsealed型の分岐を確認したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

commits

無料概要あり

IntelliJ向けの変更を適切な単位に分け、チケットの有無に応じた形式で、理由や判断も伝わるコミットメッセージを作成・修正するスキルです。

  • チケット付き変更のメッセージを作りたいとき
  • テストやドキュメントのコミットを整理したいとき
  • 既存のコミットメッセージを修正したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

compare-python-typecheckers

無料概要あり

Pythonコードの型推論や型エラーを複数の型チェッカーで比較し、各ツールの判定と診断内容をまとめたレポートを作成します。

  • 型推論の違いを比較したいとき
  • 型エラーになるか確かめたいとき
  • 複数チェッカーの診断を見比べたいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

compose-ui-architecture

無料概要あり

Compose Desktopの画面で状態や副作用をどこに持たせるか整理し、表示と判断の境界、再利用部品やリストの設計を整えます。

  • 画面とプレゼンターの責務を分けたいとき
  • UI状態の置き場所を整理したいとき
  • Effectやコルーチンの使い方を見直したいとき
JetBrains/intellij-community2.1万2026年10月26日 更新

JetBrains のスキルをすべて見る

このスキルの問題を報告する