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:
@@ -11,6 +11,7 @@ val Project.intellijVersion
|
||||
get() = rootProject.extra["versions.intellijSdk"]
|
||||
|
||||
fun Project.intellijCore() = dependencies.project(":dependencies:intellij-core")
|
||||
fun Project.intellijUtilRt() = "com.jetbrains.intellij.platform:util-rt:$intellijVersion"
|
||||
|
||||
fun Project.jpsModel() = "com.jetbrains.intellij.platform:jps-model:$intellijVersion"
|
||||
fun Project.jpsModelSerialization() = "com.jetbrains.intellij.platform:jps-model-serialization:$intellijVersion"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ dependencies {
|
||||
api(project(":kotlin-preloader"))
|
||||
api(project(":jps:jps-common"))
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(jpsModel())
|
||||
compileOnly(jpsModelImpl())
|
||||
compileOnly(jpsBuild())
|
||||
@@ -68,8 +67,6 @@ dependencies {
|
||||
testCompileOnly(jpsBuild())
|
||||
testApi(devKitJps())
|
||||
|
||||
testApi(intellijCore())
|
||||
|
||||
testApi(jpsBuildTest())
|
||||
compilerModules.forEach {
|
||||
testRuntimeOnly(project(it))
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.jps.build
|
||||
|
||||
import com.intellij.util.PathUtil
|
||||
import com.intellij.util.PathUtilRt
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||
@@ -46,7 +46,7 @@ class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
K bar();
|
||||
}
|
||||
""")
|
||||
val a = addModule("m1", PathUtil.getParentPath(aFile))
|
||||
val a = addModule("m1", PathUtilRt.getParentPath(aFile))
|
||||
|
||||
val bFile = createFile("m2/m2.kt",
|
||||
"""
|
||||
@@ -57,7 +57,7 @@ class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
override fun bar(): K
|
||||
}
|
||||
""")
|
||||
val b = addModule("b", PathUtil.getParentPath(bFile))
|
||||
val b = addModule("b", PathUtilRt.getParentPath(bFile))
|
||||
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(
|
||||
b.dependenciesList.addModuleDependency(a)
|
||||
).isExported = false
|
||||
|
||||
@@ -6,7 +6,6 @@ package org.jetbrains.kotlin.jps.targets
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import com.intellij.util.containers.FileCollectionFactory
|
||||
import com.intellij.util.io.URLUtil
|
||||
import org.jetbrains.jps.ModuleChunk
|
||||
@@ -321,9 +320,9 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
|
||||
.satisfying { dependency -> dependency is JpsSdkDependency }
|
||||
.classes().urls
|
||||
|
||||
val url = urls.firstOrNull { it.startsWith(StandardFileSystems.JRT_PROTOCOL_PREFIX) } ?: return null
|
||||
val url = urls.firstOrNull { it.startsWith(URLUtil.JRT_PROTOCOL + URLUtil.SCHEME_SEPARATOR) } ?: return null
|
||||
|
||||
return File(url.substringAfter(StandardFileSystems.JRT_PROTOCOL_PREFIX).substringBeforeLast(URLUtil.JAR_SEPARATOR))
|
||||
return File(url.substringAfter(URLUtil.JRT_PROTOCOL + URLUtil.SCHEME_SEPARATOR).substringBeforeLast(URLUtil.JAR_SEPARATOR))
|
||||
}
|
||||
|
||||
private fun findSourceRoots(context: CompileContext): List<JvmSourceRoot> {
|
||||
|
||||
Reference in New Issue
Block a user