intellij-platform-gradle-plugin
intellij-platform-gradle-plugin copied to clipboard
Code using kotlin coroutines fails to compile when org.jetbrains.intellij plugin is included
I created two gradle projects with the intellij wizard, one with Intellij Platform Plugin selected and one without.
Then I add coroutines to the dependencies in the build.gradle:
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
And I add a single kotlin file with the contents:
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.combine
val x = listOf<String>().asFlow().combine(listOf<String>().asFlow()) { yo, flow -> yo to flow }
When compiling the projects, the one without the Intellij Platform Plugin selected compiles successfully while the one with the plugin fails with:
e: C:\code\andrew\untitled2\src\main\kotlin\e.kt: (2, 32): Unresolved reference: combine
e: C:\code\andrew\untitled2\src\main\kotlin\e.kt: (4, 35): Unresolved reference: combine
e: C:\code\andrew\untitled2\src\main\kotlin\e.kt: (4, 72): Cannot infer a type for this parameter. Please specify it explicitly.
e: C:\code\andrew\untitled2\src\main\kotlin\e.kt: (4, 76): Cannot infer a type for this parameter. Please specify it explicitly.
Kotlin coroutines are bundled into IntelliJ SDK. Why do you need to use the coroutines library of another version in your plugin? Even if I fix this, you'll have to bundle coroutines with your plugin.
I guess because I’m using a method that not available in the older version that is bundled? Perhaps the combine flow operator is only available in 1.3.3.
Why does it not work? It doesn’t bundle any dependencies that come with IntelliJ even if you use a different version?
Why does it not work?
IntelliJ's jars are at the start of compilation classpath.
It doesn’t bundle any dependencies that come with IntelliJ even if you use a different version?
I didn't get the question
It doesn’t bundle any dependencies that come with IntelliJ even if you use a different version
@zolotov I think he means: is that true that if intellij uses a library "A" with version 1.0, it's impossible to use this library with version 1.3 in plugin development
@Buckstabue no, it's not true
Is there any way to compile a plugin against a version of coroutines I'd like to use? Here is also an issue on YouTrack https://youtrack.jetbrains.com/issue/IDEA-229657
Is there any way to compile a plugin against a version of coroutines I'd like to use?
you can compile without gradle-intellij-plugin
so what is the reason for using non-bundled coroutines in your plugin and why is this so important so you want to sacrifice plugin's distribution size and IDE startup speed?
Here is also an issue on YouTrack https://youtrack.jetbrains.com/issue/IDEA-229657
thanks, I've closed it in favor of this issue
linked sample project: https://github.com/Buckstabue/TestCoroutinesPlugin
so what is the reason for using non-bundled coroutines in your plugin and why is this so important so you want to sacrifice plugin's distribution size and IDE startup speed?
I'm developing a plugin for Android studio which is updated by Google not so often. So I have to target an old idea version with bundled coroutines with version 1.0.3. That Idea doesn't even come with swing coroutines and I have to use an old swing-coroutines library which can probably contain bugs. Also I'd like to use Flow api to get advantage of using operators like "combineLatest" that don't have analogues in Channel api. So I have at least two main reasons:
- ability to use new api
- ability to use latest kotlin libraries that might depend on a newer kotlin version
Sorry the late reply - I solved it by using compile instead implementation when importing coroutines - then the compile time error goes away
good catch. then it looks like #239
whats the status here? i have the same problem. neither implementation nor compile dep works
please, try to add this to your buildscript:
configurations {
compileClasspath.resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST)
testCompileClasspath.resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST)
}
does it help?
this should not be an issue anymore in recent versions