Kotlin JPS plugin: drop intellij-core dependency
Drop dependency because https://youtrack.jetbrains.com/issue/IDEA-292483/UnsupportedClassVersionError-when-trying-to-run-JUnit5-unit-test#focus=Comments-27-6034750.0-0 IDEA plans to drop `PathUtil` from JPS classpath, we should prepare to that `KotlinFacetSettingsProvider` isn't used in jps so it was moved into intellij repo. It was moved to `community/plugins/kotlin/idea/src/org/jetbrains/kotlin/config/KotlinFacetSettingsProvider.kt` path (so you can find it git history) Review: KT-MR-6195
This commit is contained in:
@@ -13,7 +13,8 @@ dependencies {
|
||||
api(project(":compiler:frontend.java"))
|
||||
api(project(":js:js.frontend"))
|
||||
api(project(":native:frontend.native"))
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(intellijUtilRt())
|
||||
compileOnly(intellijPlatformUtil())
|
||||
compileOnly(jpsModel())
|
||||
compileOnly(jpsModelImpl())
|
||||
compileOnly(jpsModelSerialization())
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
|
||||
private const val APPLICATION_MANAGER_CLASS_NAME = "com.intellij.openapi.application.ApplicationManager"
|
||||
const val APPLICATION_MANAGER_CLASS_NAME = "com.intellij.openapi.application.ApplicationManager"
|
||||
|
||||
val isJps: Boolean by lazy {
|
||||
/*
|
||||
@@ -16,7 +14,7 @@ val isJps: Boolean by lazy {
|
||||
Though Application is not properly initialized inside JPS so we can use it as a check.
|
||||
*/
|
||||
return@lazy if (doesClassExist(APPLICATION_MANAGER_CLASS_NAME)) {
|
||||
ApplicationManager.getApplication() == null
|
||||
Class.forName(APPLICATION_MANAGER_CLASS_NAME).getMethod("getApplication").invoke(null) == null
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||
import org.jetbrains.kotlin.platform.IdePlatformKind
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
@@ -276,13 +274,3 @@ class KotlinFacetSettings {
|
||||
|
||||
var pureKotlinSourceFolders: List<String> = emptyList()
|
||||
}
|
||||
|
||||
interface KotlinFacetSettingsProvider {
|
||||
fun getSettings(module: Module): KotlinFacetSettings?
|
||||
fun getInitializedSettings(module: Module): KotlinFacetSettings
|
||||
|
||||
companion object {
|
||||
fun getInstance(project: Project): KotlinFacetSettingsProvider? = project.takeUnless(Project::isDisposed)
|
||||
?.getService(KotlinFacetSettingsProvider::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
import com.intellij.util.PathUtil
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.util.xmlb.SerializationFilter
|
||||
import com.intellij.util.xmlb.SkipDefaultsSerializationFilter
|
||||
import com.intellij.util.xmlb.XmlSerializer
|
||||
@@ -179,10 +179,10 @@ private fun readV2AndLaterConfig(
|
||||
compilerArguments!!.detectVersionAutoAdvance()
|
||||
}
|
||||
productionOutputPath = element.getChild("productionOutputPath")?.let {
|
||||
PathUtil.toSystemDependentName((it.content.firstOrNull() as? Text)?.textTrim)
|
||||
(it.content.firstOrNull() as? Text)?.textTrim?.let(FileUtilRt::toSystemDependentName)
|
||||
} ?: (compilerArguments as? K2JSCompilerArguments)?.outputFile
|
||||
testOutputPath = element.getChild("testOutputPath")?.let {
|
||||
PathUtil.toSystemDependentName((it.content.firstOrNull() as? Text)?.textTrim)
|
||||
(it.content.firstOrNull() as? Text)?.textTrim?.let(FileUtilRt::toSystemDependentName)
|
||||
} ?: (compilerArguments as? K2JSCompilerArguments)?.outputFile
|
||||
}
|
||||
}
|
||||
@@ -222,33 +222,33 @@ fun deserializeFacetSettings(element: Element): KotlinFacetSettings {
|
||||
}
|
||||
|
||||
fun CommonCompilerArguments.convertPathsToSystemIndependent() {
|
||||
pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths!![index] = PathUtil.toSystemIndependentName(s) }
|
||||
pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths!![index] = FileUtilRt.toSystemIndependentName(s) }
|
||||
|
||||
when (this) {
|
||||
is K2JVMCompilerArguments -> {
|
||||
destination = PathUtil.toSystemIndependentName(destination)
|
||||
classpath = PathUtil.toSystemIndependentName(classpath)
|
||||
jdkHome = PathUtil.toSystemIndependentName(jdkHome)
|
||||
kotlinHome = PathUtil.toSystemIndependentName(kotlinHome)
|
||||
friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = PathUtil.toSystemIndependentName(s) }
|
||||
declarationsOutputPath = PathUtil.toSystemIndependentName(declarationsOutputPath)
|
||||
destination = destination?.let(FileUtilRt::toSystemIndependentName)
|
||||
classpath = classpath?.let(FileUtilRt::toSystemIndependentName)
|
||||
jdkHome = jdkHome?.let(FileUtilRt::toSystemIndependentName)
|
||||
kotlinHome = kotlinHome?.let(FileUtilRt::toSystemIndependentName)
|
||||
friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = FileUtilRt.toSystemIndependentName(s) }
|
||||
declarationsOutputPath = declarationsOutputPath?.let(FileUtilRt::toSystemIndependentName)
|
||||
}
|
||||
|
||||
is K2JSCompilerArguments -> {
|
||||
outputFile = PathUtil.toSystemIndependentName(outputFile)
|
||||
libraries = PathUtil.toSystemIndependentName(libraries)
|
||||
outputFile = outputFile?.let(FileUtilRt::toSystemIndependentName)
|
||||
libraries = libraries?.let(FileUtilRt::toSystemIndependentName)
|
||||
}
|
||||
|
||||
is K2MetadataCompilerArguments -> {
|
||||
destination = PathUtil.toSystemIndependentName(destination)
|
||||
classpath = PathUtil.toSystemIndependentName(classpath)
|
||||
destination = destination?.let(FileUtilRt::toSystemIndependentName)
|
||||
classpath = classpath?.let(FileUtilRt::toSystemIndependentName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun CompilerSettings.convertPathsToSystemIndependent() {
|
||||
scriptTemplatesClasspath = PathUtil.toSystemIndependentName(scriptTemplatesClasspath)
|
||||
outputDirectoryForJsLibraryFiles = PathUtil.toSystemIndependentName(outputDirectoryForJsLibraryFiles)
|
||||
scriptTemplatesClasspath = FileUtilRt.toSystemIndependentName(scriptTemplatesClasspath)
|
||||
outputDirectoryForJsLibraryFiles = FileUtilRt.toSystemIndependentName(outputDirectoryForJsLibraryFiles)
|
||||
}
|
||||
|
||||
private fun KClass<*>.superClass() = superclasses.firstOrNull { !it.java.isInterface }
|
||||
@@ -351,12 +351,12 @@ private fun KotlinFacetSettings.writeConfig(element: Element) {
|
||||
}
|
||||
productionOutputPath?.let {
|
||||
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
|
||||
element.addContent(Element("productionOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) })
|
||||
element.addContent(Element("productionOutputPath").apply { addContent(FileUtilRt.toSystemIndependentName(it)) })
|
||||
}
|
||||
}
|
||||
testOutputPath?.let {
|
||||
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
|
||||
element.addContent(Element("testOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) })
|
||||
element.addContent(Element("testOutputPath").apply { addContent(FileUtilRt.toSystemIndependentName(it)) })
|
||||
}
|
||||
}
|
||||
compilerSettings?.let { copyBean(it) }?.let {
|
||||
|
||||
+5
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.platform
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.kotlin.config.APPLICATION_MANAGER_CLASS_NAME
|
||||
import org.jetbrains.kotlin.config.isJps
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
|
||||
@@ -20,7 +20,10 @@ interface DefaultIdeTargetPlatformKindProvider {
|
||||
return JvmPlatforms.defaultJvmPlatform
|
||||
}
|
||||
|
||||
return ApplicationManager.getApplication().getService(DefaultIdeTargetPlatformKindProvider::class.java).defaultPlatform
|
||||
val application = Class.forName(APPLICATION_MANAGER_CLASS_NAME).getMethod("getApplication").invoke(null)
|
||||
val service = application::class.java.getMethod("getService", Class::class.java)
|
||||
.invoke(application, DefaultIdeTargetPlatformKindProvider::class.java) as DefaultIdeTargetPlatformKindProvider
|
||||
return service.defaultPlatform
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user