Kotlin 2.1.20升级后kotlin-compiler-embeddable依赖冲突警告的排查与解决求助
Kotlin 2.1.20升级后kotlin-compiler-embeddable依赖冲突警告的排查与解决求助
我最近把项目升级到Kotlin 2.1.20,解决了一堆构建错误后,卡在了一个每个模块都会弹出的警告上:
The artifact org.jetbrains.kotlin:kotlin-compiler-embeddable is present in the build classpath along Kotlin Gradle plugin. This may lead to unpredictable and inconsistent behavior. Please remove the org.jetbrains.kotlin:kotlin-compiler-embeddable artifact from the build classpath. See https://kotl.in/gradle/internal-compiler-symbols for more details.
我自己的项目里完全没声明过kotlin-compiler-embeddable这个依赖,肯定是某个第三方库带进来的,但我根本找不到是哪个库的问题。
官方给的链接里说是有排查方案,但写得太模糊了,我完全摸不着头脑:
- 首先文档说要在
build.gradle的dependencies块里加这段代码,但没说加在app级还是模块级的构建脚本里?我两个都试了,结果后面步骤里要用到的依赖完全无法解析:// build.gradle.kts dependencies { compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:2.2.0") } - 接着文档要求创建几个抽象类,但这些类里的几乎所有导入语句都无法找到对应的依赖,同步Gradle也没用,代码全飘红:
比如org.gradle.workers.WorkAction、org.jetbrains.kotlin.config.KotlinCompilerVersion这些包,根本resolve不了。 - 我甚至不知道这些抽象类该放在项目的哪个位置?是放在弹出警告的模块里吗?但依赖都没解析,连类都建不起来。
- 文档里的这些类都是抽象类,按道理需要实现具体的子类吧?但文档里完全没提这茬,也没说要怎么实例化或者调用这些类,光创建一个抽象类有什么用?
现在我完全卡在这里了,有没有人能把官方的排查方案用直白的方式讲清楚?或者有没有更简单的方法能找出到底是哪个第三方依赖引入了kotlin-compiler-embeddable?
内容来源于stack exchange




