intellij-platform-gradle-plugin icon indicating copy to clipboard operation
intellij-platform-gradle-plugin copied to clipboard

does not work together with kotlin-multiplatform

Open Zane-XY opened this issue 1 year ago • 8 comments

What happened?

The plugin project may include shared subproject modules that target Kotlin Multiplatform. However, when the plugin subproject uses the Kotlin JVM plugin, it is unable to resolve the project(":shared-subproject") dependency correctly. On the other hand, if the plugin subproject uses the Kotlin Multiplatform plugin, it can resolve the shared project dependency. But, it may not recognize the SDK dependency brought by the IntelliJ plugin and fails to compile. Need to confirm if it is possible to achieve a shared subject compiles to multiplatform targets in an IntelliJ plugin project?

Relevant log output or stack trace

No response

Steps to reproduce

as above description.

Gradle IntelliJ Plugin version

1.16.1

Gradle version

8.5

Operating System

None

Link to build, i.e. failing GitHub Action job

No response

Zane-XY avatar Dec 13 '23 15:12 Zane-XY

Please provide a minimal reproducible example so I could review your issue locally.

hsz avatar Jan 12 '24 13:01 hsz

@hsz here is a reproducer: https://github.com/slackhq/slack-gradle-plugin/tree/main/skate-plugin

The plugin appears to be missing compiled kotlin deps, seemingly because it does not find the correct KotlinCompile task in multiplatform

I see the following task dependency tree in multiplatform

:skate-plugin:initializeIntelliJPlugin SKIPPED
:skate-plugin:generateBuildConfig SKIPPED
:skate-plugin:patchPluginXml SKIPPED
:skate-plugin:verifyPluginConfiguration SKIPPED
:skate-plugin:compileJava SKIPPED
:skate-plugin:processResources SKIPPED
:skate-plugin:classes SKIPPED
:skate-plugin:instrumentCode SKIPPED
:skate-plugin:classpathIndexCleanup SKIPPED
:skate-plugin:instrumentedJar SKIPPED
:skate-plugin:jar SKIPPED
:skate-plugin:prepareSandbox SKIPPED
:skate-plugin:buildSearchableOptions SKIPPED
:skate-plugin:jarSearchableOptions SKIPPED
:skate-plugin:buildPlugin SKIPPED

missing the compileKotlinJvm task that the kotlin multiplatform uses for the jvmMain source set instead. This seems to be due to it exclusively looking for compileKotlin here: https://github.com/JetBrains/intellij-platform-gradle-plugin/blob/bb484a6824455fe5df5cec2fb756bbb3a03b7cb4/src/main/kotlin/org/jetbrains/intellij/platform/gradle/Constants.kt#L140

ZacSweers avatar Mar 27 '24 20:03 ZacSweers

It also appears to only look for the kotlin jvm plugin: https://github.com/JetBrains/intellij-platform-gradle-plugin/blob/bb484a6824455fe5df5cec2fb756bbb3a03b7cb4/src/main/kotlin/org/jetbrains/intellij/platform/gradle/Constants.kt#L41

ZacSweers avatar Mar 27 '24 20:03 ZacSweers

Thanks, Zac! I'll check it soon, but most likely any possible fix will be provided with the 2.0 release.

hsz avatar Mar 28 '24 21:03 hsz

I think the issue is actually from depending on the wrong Jar task, as there is a separate jarJvm task from the standard jar task that the plugin looks for. I'm looking into it and seeing if I can put together a PR 👍. In the meantime, the property using a convention means it should be possible to workaround this without a new release. I'll update here when I have more details

ZacSweers avatar Mar 28 '24 21:03 ZacSweers

I just managed to change the default jar task to jarJvm but there's more work required here, as kotlin.jvm in KMP doesn't work on default set but custom subset of dependencies, configurations, sourceSets, and tasks. In 2.x the support for KMP could be possible, but this needs to be investigated at first.

hsz avatar Jul 15 '24 08:07 hsz