[kotlin] K2: in scripts use projectSdk if there is any

GitOrigin-RevId: 4e332fa878ed5a85abd0f679ab6bf625b11e1848
This commit is contained in:
Vlad Koshkin
2024-07-12 13:43:40 +02:00
committed by intellij-monorepo-bot
parent 4ee04a3e95
commit 73d0177c8b

View File

@@ -137,7 +137,13 @@ class K2ScriptDependenciesProvider(project: Project) : ScriptDependenciesProvide
classes.addAll(toVfsRoots(configurationWrapper.dependenciesClassPath))
sources.addAll(toVfsRoots(configurationWrapper.dependenciesSources))
configurationWrapper.javaHome?.toPath()?.let {
sdks[it] = ExternalSystemJdkUtil.lookupJdkByPath(it.pathString)
val projectSdk = ProjectRootManager.getInstance(project).projectSdk
if (projectSdk != null && projectSdk.homePath == javaHome) {
sdks[it] = projectSdk
} else {
sdks[it] = ExternalSystemJdkUtil.lookupJdkByPath(it.pathString)
}
}
counter++