Fix compatibility with JPS-standalone (KT-26777)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
|
||||
private const val JPS_STANDALONE_CLASS_NAME = "org.jetbrains.jps.build.Standalone"
|
||||
|
||||
val isJps: Boolean by lazy {
|
||||
val jpsStandaloneClassName = JPS_STANDALONE_CLASS_NAME.replace('.', '/') + ".class"
|
||||
|
||||
(object {}.javaClass.classLoader.getResource(jpsStandaloneClassName) != null)
|
||||
|| ApplicationManager.getApplication() == null
|
||||
}
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.platform
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import org.jetbrains.kotlin.config.isJps
|
||||
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
||||
|
||||
interface DefaultIdeTargetPlatformKindProvider {
|
||||
@@ -15,7 +15,7 @@ interface DefaultIdeTargetPlatformKindProvider {
|
||||
companion object {
|
||||
val defaultPlatform: IdePlatform<*, *>
|
||||
get() {
|
||||
if (ApplicationManager.getApplication() == null) {
|
||||
if (isJps) {
|
||||
// TODO support passing custom platforms in JPS
|
||||
return JvmIdePlatformKind.defaultPlatform
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
@file:JvmName("IdePlatformKindUtil")
|
||||
package org.jetbrains.kotlin.platform
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.extensions.ApplicationExtensionDescriptor
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.config.isJps
|
||||
import org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind
|
||||
import org.jetbrains.kotlin.platform.impl.JsIdePlatformKind
|
||||
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
||||
@@ -35,7 +35,8 @@ abstract class IdePlatformKind<Kind : IdePlatformKind<Kind>> {
|
||||
|
||||
companion object {
|
||||
// We can't use the ApplicationExtensionDescriptor class directly because it's missing in the JPS process
|
||||
private val extension = ApplicationManager.getApplication()?.let {
|
||||
private val extension = run {
|
||||
if (isJps) return@run null
|
||||
ApplicationExtensionDescriptor("org.jetbrains.kotlin.idePlatformKind", IdePlatformKind::class.java)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user