mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-37485 [kotlin]: Migrate from File to Path
GitOrigin-RevId: 7e8e4839f83ac313d6be34fe779e20d5ff4a435f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8ab271bc5c
commit
ec563e7bae
+2
-2
@@ -23,8 +23,8 @@ abstract class KotlinJUnit3SuperTearDownInspectionTest : JUnit3SuperTearDownInsp
|
||||
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
|
||||
super.configureModule(module, model, contentEntry)
|
||||
ConfigLibraryUtil.addLibrary(model, "KotlinJavaRuntime") {
|
||||
addRoot(KotlinArtifacts.kotlinStdlib, OrderRootType.CLASSES)
|
||||
addRoot(KotlinArtifacts.kotlinStdlibSources, OrderRootType.SOURCES)
|
||||
addRoot(KotlinArtifacts.kotlinStdlibPath, OrderRootType.CLASSES)
|
||||
addRoot(KotlinArtifacts.kotlinStdlibSourcesPath, OrderRootType.SOURCES)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.jps
|
||||
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayout
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
fun File.toJpsVersionAgnosticKotlinBundledPath(): String {
|
||||
val kotlincDirectory = KotlinPluginLayout.kotlinc
|
||||
fun Path.toJpsVersionAgnosticKotlinBundledPath(): String {
|
||||
val kotlincDirectory = KotlinPluginLayout.kotlincPath
|
||||
require(this.startsWith(kotlincDirectory)) { "$this should start with ${kotlincDirectory}" }
|
||||
return "\$KOTLIN_BUNDLED\$/${relativeTo(kotlincDirectory)}"
|
||||
return "\$KOTLIN_BUNDLED\$/${relativize(kotlincDirectory)}"
|
||||
}
|
||||
+212
-36
@@ -5,35 +5,42 @@ package org.jetbrains.kotlin.idea.base.plugin.artifacts
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifactNames.JETBRAINS_ANNOTATIONS
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayout
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
@ApiStatus.Internal
|
||||
object KotlinArtifactConstants {
|
||||
@NlsSafe
|
||||
const val KOTLIN_MAVEN_GROUP_ID = "org.jetbrains.kotlin"
|
||||
const val KOTLIN_MAVEN_GROUP_ID: String = "org.jetbrains.kotlin"
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated because new \"meta pom\" format (KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID) should be used. " +
|
||||
"This constant should be used only for being possible to compile intellij repo"
|
||||
)
|
||||
@NlsSafe
|
||||
const val OLD_KOTLIN_DIST_ARTIFACT_ID = "kotlin-dist-for-ide"
|
||||
const val OLD_KOTLIN_DIST_ARTIFACT_ID: String = "kotlin-dist-for-ide"
|
||||
|
||||
@NlsSafe
|
||||
const val KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID = "kotlin-dist-for-jps-meta"
|
||||
const val KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID: String = "kotlin-dist-for-jps-meta"
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated because new KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID should be used. " +
|
||||
"This constant should be used only for being possible to compile intellij repo"
|
||||
)
|
||||
@NlsSafe
|
||||
const val OLD_FAT_JAR_KOTLIN_JPS_PLUGIN_CLASSPATH_ARTIFACT_ID = "kotlin-jps-plugin-classpath"
|
||||
const val OLD_FAT_JAR_KOTLIN_JPS_PLUGIN_CLASSPATH_ARTIFACT_ID: String = "kotlin-jps-plugin-classpath"
|
||||
|
||||
@NlsSafe
|
||||
const val KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID = "kotlin-jps-plugin"
|
||||
const val KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID: String = "kotlin-jps-plugin"
|
||||
|
||||
val KOTLIN_DIST_LOCATION_PREFIX: File = File(PathManager.getSystemPath(), "kotlin-dist-for-ide")
|
||||
val KOTLIN_DIST_LOCATION_PREFIX_PATH: Path = PathManager.getSystemDir().resolve("kotlin-dist-for-ide")
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use KOTLIN_DIST_LOCATION_PREFIX_PATH instead", ReplaceWith("KOTLIN_DIST_LOCATION_PREFIX_PATH"))
|
||||
val KOTLIN_DIST_LOCATION_PREFIX: File
|
||||
get() = KOTLIN_DIST_LOCATION_PREFIX_PATH.toFile()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,91 +50,260 @@ object KotlinArtifactConstants {
|
||||
* For tests use [TestKotlinArtifacts]
|
||||
*/
|
||||
object KotlinArtifacts {
|
||||
private val kotlincBinDirectory: File = File(KotlinPluginLayout.kotlinc, "bin")
|
||||
private val kotlincBinDirectoryPath: Path = KotlinPluginLayout.kotlincPath.resolve("bin")
|
||||
|
||||
private val kotlincLibDirectory: File = File(KotlinPluginLayout.kotlinc, "lib")
|
||||
private val kotlincLibDirectoryPath: Path = KotlinPluginLayout.kotlincPath.resolve("lib")
|
||||
|
||||
@JvmStatic
|
||||
val jetbrainsAnnotations: File = File(kotlincLibDirectory, KotlinArtifactNames.JETBRAINS_ANNOTATIONS)
|
||||
val jetbrainsAnnotationsPath: Path = kotlincLibDirectoryPath.resolve(JETBRAINS_ANNOTATIONS)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use jetbrainsAnnotationsPath instead", ReplaceWith("jetbrainsAnnotationsPath"))
|
||||
@JvmStatic
|
||||
val jetbrainsAnnotations: File
|
||||
get() = jetbrainsAnnotationsPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlib: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB)
|
||||
val kotlinStdlibPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibPath instead", ReplaceWith("kotlinStdlibPath"))
|
||||
@JvmStatic
|
||||
val kotlinStdlib: File
|
||||
get() = kotlinStdlibPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlibSources: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_SOURCES)
|
||||
val kotlinStdlibSourcesPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB_SOURCES)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibSourcesPath instead", ReplaceWith("kotlinStdlibSourcesPath"))
|
||||
@JvmStatic
|
||||
val kotlinStdlibSources: File
|
||||
get() = kotlinStdlibSourcesPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk7: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK7)
|
||||
val kotlinStdlibJdk7Path: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB_JDK7)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibJdk7Path instead", ReplaceWith("kotlinStdlibJdk7Path"))
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk7: File
|
||||
get() = kotlinStdlibJdk7Path.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk7Sources: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK7_SOURCES)
|
||||
val kotlinStdlibJdk7SourcesPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB_JDK7_SOURCES)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibJdk7SourcesPath instead", ReplaceWith("kotlinStdlibJdk7SourcesPath"))
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk7Sources: File
|
||||
get() = kotlinStdlibJdk7SourcesPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk8: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK8)
|
||||
val kotlinStdlibJdk8Path: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB_JDK8)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibJdk8Path instead", ReplaceWith("kotlinStdlibJdk8Path"))
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk8: File
|
||||
get() = kotlinStdlibJdk8Path.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk8Sources: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK8_SOURCES)
|
||||
val kotlinStdlibJdk8SourcesPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB_JDK8_SOURCES)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibJdk8SourcesPath instead", ReplaceWith("kotlinStdlibJdk8SourcesPath"))
|
||||
@JvmStatic
|
||||
val kotlinStdlibJdk8Sources: File
|
||||
get() = kotlinStdlibJdk8SourcesPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinReflect: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_REFLECT)
|
||||
val kotlinReflectPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_REFLECT)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinReflectPath instead", ReplaceWith("kotlinReflectPath"))
|
||||
@JvmStatic
|
||||
val kotlinReflect: File
|
||||
get() = kotlinReflectPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinStdlibJs: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JS)
|
||||
val kotlinStdlibJsPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_STDLIB_JS)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinStdlibJsPath instead", ReplaceWith("kotlinStdlibJsPath"))
|
||||
@JvmStatic
|
||||
val kotlinStdlibJs: File
|
||||
get() = kotlinStdlibJsPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinMainKts: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_MAIN_KTS)
|
||||
val kotlinMainKtsPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_MAIN_KTS)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinMainKtsPath instead", ReplaceWith("kotlinMainKtsPath"))
|
||||
@JvmStatic
|
||||
val kotlinMainKts: File
|
||||
get() = kotlinMainKtsPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinScriptRuntime: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPT_RUNTIME)
|
||||
val kotlinScriptRuntimePath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_SCRIPT_RUNTIME)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinScriptRuntimePath instead", ReplaceWith("kotlinScriptRuntimePath"))
|
||||
@JvmStatic
|
||||
val kotlinScriptRuntime: File
|
||||
get() = kotlinScriptRuntimePath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinScriptingCommon: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_COMMON)
|
||||
val kotlinScriptingCommonPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_SCRIPTING_COMMON)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinScriptingCommonPath instead", ReplaceWith("kotlinScriptingCommonPath"))
|
||||
@JvmStatic
|
||||
val kotlinScriptingCommon: File
|
||||
get() = kotlinScriptingCommonPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinScriptingJvm: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_JVM)
|
||||
val kotlinScriptingJvmPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_SCRIPTING_JVM)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinScriptingJvmPath instead", ReplaceWith("kotlinScriptingJvmPath"))
|
||||
@JvmStatic
|
||||
val kotlinScriptingJvm: File
|
||||
get() = kotlinScriptingJvmPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinCompiler: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_COMPILER)
|
||||
val kotlinCompilerPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_COMPILER)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinCompilerPath instead", ReplaceWith("kotlinCompilerPath"))
|
||||
@JvmStatic
|
||||
val kotlinCompiler: File
|
||||
get() = kotlinCompilerPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val lombokCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.LOMBOK_COMPILER_PLUGIN)
|
||||
val lombokCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.LOMBOK_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use lombokCompilerPluginPath instead", ReplaceWith("lombokCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val lombokCompilerPlugin: File
|
||||
get() = lombokCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val trove4j: File = File(kotlincLibDirectory, KotlinArtifactNames.TROVE4J)
|
||||
val trove4jPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.TROVE4J)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use trove4jPath instead", ReplaceWith("trove4jPath"))
|
||||
@JvmStatic
|
||||
val trove4j: File
|
||||
get() = trove4jPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinDaemon: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_DAEMON)
|
||||
val kotlinDaemonPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_DAEMON)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinDaemonPath instead", ReplaceWith("kotlinDaemonPath"))
|
||||
@JvmStatic
|
||||
val kotlinDaemon: File
|
||||
get() = kotlinDaemonPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinScriptingCompiler: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_COMPILER)
|
||||
val kotlinScriptingCompilerPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_SCRIPTING_COMPILER)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinScriptingCompilerPath instead", ReplaceWith("kotlinScriptingCompilerPath"))
|
||||
@JvmStatic
|
||||
val kotlinScriptingCompiler: File
|
||||
get() = kotlinScriptingCompilerPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinScriptingCompilerImpl: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_COMPILER_IMPL)
|
||||
val kotlinScriptingCompilerImplPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_SCRIPTING_COMPILER_IMPL)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinScriptingCompilerImplPath instead", ReplaceWith("kotlinScriptingCompilerImplPath"))
|
||||
@JvmStatic
|
||||
val kotlinScriptingCompilerImpl: File
|
||||
get() = kotlinScriptingCompilerImplPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val allopenCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.ALLOPEN_COMPILER_PLUGIN)
|
||||
val allopenCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.ALLOPEN_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use allopenCompilerPluginPath instead", ReplaceWith("allopenCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val allopenCompilerPlugin: File
|
||||
get() = allopenCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val noargCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.NOARG_COMPILER_PLUGIN)
|
||||
val noargCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.NOARG_COMPILER_PLUGIN)
|
||||
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use noargCompilerPluginPath instead", ReplaceWith("noargCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val noargCompilerPlugin: File
|
||||
get() = noargCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val samWithReceiverCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.SAM_WITH_RECEIVER_COMPILER_PLUGIN)
|
||||
val samWithReceiverCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.SAM_WITH_RECEIVER_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use samWithReceiverCompilerPluginPath instead", ReplaceWith("samWithReceiverCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val samWithReceiverCompilerPlugin: File
|
||||
get() = samWithReceiverCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val assignmentCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.ASSIGNMENT_COMPILER_PLUGIN)
|
||||
val assignmentCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.ASSIGNMENT_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use assignmentCompilerPluginPath instead", ReplaceWith("assignmentCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val assignmentCompilerPlugin: File
|
||||
get() = assignmentCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinxSerializationCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLINX_SERIALIZATION_COMPILER_PLUGIN)
|
||||
val kotlinxSerializationCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLINX_SERIALIZATION_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinxSerializationCompilerPluginPath instead", ReplaceWith("kotlinxSerializationCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val kotlinxSerializationCompilerPlugin: File
|
||||
get() = kotlinxSerializationCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val powerAssertPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.POWER_ASSERT_COMPILER_PLUGIN)
|
||||
val powerAssertPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.POWER_ASSERT_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use powerAssertPluginPath instead", ReplaceWith("powerAssertPluginPath"))
|
||||
@JvmStatic
|
||||
val powerAssertPlugin: File
|
||||
get() = powerAssertPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinDataFrameCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_DATAFRAME_COMPILER_PLUGIN)
|
||||
val kotlinDataFrameCompilerPluginPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_DATAFRAME_COMPILER_PLUGIN)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinDataFrameCompilerPluginPath instead", ReplaceWith("kotlinDataFrameCompilerPluginPath"))
|
||||
@JvmStatic
|
||||
val kotlinDataFrameCompilerPlugin: File
|
||||
get() = kotlinDataFrameCompilerPluginPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinPreloader: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_PRELOADER)
|
||||
val kotlinPreloaderPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.KOTLIN_PRELOADER)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlinPreloaderPath instead", ReplaceWith("kotlinPreloaderPath"))
|
||||
@JvmStatic
|
||||
val kotlinPreloader: File
|
||||
get() = kotlinPreloaderPath.toFile()
|
||||
|
||||
@JvmStatic
|
||||
val kotlinc: File = File(kotlincBinDirectory, KotlinArtifactNames.KOTLINC)
|
||||
val kotlincPath: Path = kotlincBinDirectoryPath.resolve(KotlinArtifactNames.KOTLINC)
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
@Deprecated("Use kotlincPath instead", ReplaceWith("kotlincPath"))
|
||||
@JvmStatic
|
||||
val kotlinc: File
|
||||
get() = kotlincPath.toFile()
|
||||
}
|
||||
|
||||
+8
-2
@@ -5,6 +5,7 @@ import com.intellij.util.io.Decompressor
|
||||
import com.intellij.util.io.DigestUtil
|
||||
import com.intellij.util.io.hashToHexString
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.security.MessageDigest
|
||||
|
||||
internal class LazyZipUnpacker(private val destination: File) : AbstractLazyFileOutputProducer<File, Unit>(
|
||||
@@ -24,9 +25,14 @@ internal class LazyZipUnpacker(private val destination: File) : AbstractLazyFile
|
||||
DigestUtil.updateContentHash(messageDigest, input.toPath(), buffer)
|
||||
}
|
||||
|
||||
fun lazyUnpack(zip: File) = lazyProduceOutput(zip, Unit).singleOrNull()
|
||||
?: error("${LazyZipUnpacker::produceOutput.name} returns only single element")
|
||||
fun lazyUnpack(zip: File): File {
|
||||
return lazyProduceOutput(zip, Unit).singleOrNull()
|
||||
?: error("${LazyZipUnpacker::produceOutput.name} returns only single element")
|
||||
}
|
||||
|
||||
fun lazyUnpack(zip: Path): Path {
|
||||
return lazyUnpack(zip.toFile()).toPath()
|
||||
}
|
||||
fun getUnpackedIfUpToDateOrNull(zip: File): File? = getOutputIfUpToDateOrEmpty(zip).ifEmpty { return null }.singleOrNull()
|
||||
?: error("${LazyZipUnpacker::produceOutput.name} returns only single element")
|
||||
}
|
||||
|
||||
+5
-4
@@ -32,6 +32,7 @@ import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.net.URL
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.io.path.exists
|
||||
|
||||
@@ -182,14 +183,14 @@ object KotlinArtifactsDownloader {
|
||||
.distinct()
|
||||
}
|
||||
|
||||
fun downloadMavenArtifact(groupId: String, artifactId: String, version: String, suffix: String = ".jar"): File? {
|
||||
fun downloadMavenArtifact(groupId: String, artifactId: String, version: String, suffix: String = ".jar"): Path? {
|
||||
check(isRunningFromSources) {
|
||||
"${::downloadArtifactForIdeFromSources.name} must be called only for IDE running from sources or tests. " +
|
||||
"Use ${::downloadMavenArtifacts.name} when run in production"
|
||||
}
|
||||
// In cooperative development artifacts are already downloaded and stored in $PROJECT_DIR$/../build/repo
|
||||
KotlinMavenUtils.findArtifact(groupId, artifactId, version, suffix)?.let {
|
||||
return it.toFile()
|
||||
return it
|
||||
}
|
||||
|
||||
val fileName = "$artifactId-$version$suffix"
|
||||
@@ -218,11 +219,11 @@ object KotlinArtifactsDownloader {
|
||||
check(artifact.exists()) { "$artifact should be downloaded" }
|
||||
}
|
||||
|
||||
return artifact.toFile()
|
||||
return artifact
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun downloadArtifactForIdeFromSources(artifactId: String, version: String, suffix: String = ".jar"): File? {
|
||||
fun downloadArtifactForIdeFromSources(artifactId: String, version: String, suffix: String = ".jar"): Path? {
|
||||
return downloadMavenArtifact(KOTLIN_MAVEN_GROUP_ID, artifactId, version, suffix)
|
||||
}
|
||||
|
||||
|
||||
+30
-13
@@ -68,15 +68,32 @@ object KotlinPluginLayout {
|
||||
* with a compatible version.
|
||||
*/
|
||||
@JvmStatic
|
||||
val kotlinc: File
|
||||
val kotlincPath: Path
|
||||
get() = kotlincProvider.value
|
||||
|
||||
@Suppress("IO_FILE_USAGE")
|
||||
/**
|
||||
* Directory with the bundled Kotlin compiler distribution. Includes the compiler itself and a set of compiler plugins
|
||||
* with a compatible version.
|
||||
*/
|
||||
@Deprecated("Use kotlincPath instead", ReplaceWith("kotlincPath"))
|
||||
@JvmStatic
|
||||
val kotlinc: File
|
||||
get() = kotlincPath.toFile()
|
||||
|
||||
/**
|
||||
* Location of the JPS plugin and all its dependency jars
|
||||
*/
|
||||
val jpsPluginClasspath: List<File>
|
||||
val jpsPluginClasspathPath: List<Path>
|
||||
get() = jpsPluginClasspathProvider.value
|
||||
|
||||
/**
|
||||
* Location of the JPS plugin and all its dependency jars
|
||||
*/
|
||||
@Deprecated("Use jpsPluginClasspathPath instead", ReplaceWith("jpsPluginClasspathPath"))
|
||||
val jpsPluginClasspath: List<File>
|
||||
get() = jpsPluginClasspathPath.map(Path::toFile)
|
||||
|
||||
val jsEngines: File? by lazy {
|
||||
kotlinc.resolve("lib").resolve("js.engines.jar").takeIf { it.exists() }
|
||||
}
|
||||
@@ -96,17 +113,17 @@ object KotlinPluginLayout {
|
||||
@JvmStatic
|
||||
val ideCompilerVersion: IdeKotlinVersion = IdeKotlinVersion.get(KotlinCompilerVersion.VERSION)
|
||||
|
||||
private val kotlincProvider: Lazy<File>
|
||||
private val jpsPluginClasspathProvider: Lazy<List<File>>
|
||||
private val kotlincProvider: Lazy<Path>
|
||||
private val jpsPluginClasspathProvider: Lazy<List<Path>>
|
||||
private val standaloneCompilerVersionProvider: Lazy<IdeKotlinVersion>
|
||||
|
||||
init {
|
||||
val standaloneCompilerVersionDefaultProvider = lazy {
|
||||
val buildTxtFile = kotlinc.resolve("build.txt")
|
||||
if (!buildTxtFile.exists()) {
|
||||
val buildTxtPath = kotlincPath.resolve("build.txt")
|
||||
if (!buildTxtPath.exists()) {
|
||||
ideCompilerVersion
|
||||
} else {
|
||||
val rawVersion = buildTxtFile.readText().trim()
|
||||
val rawVersion = Files.readString(buildTxtPath).trim()
|
||||
IdeKotlinVersion.get(rawVersion)
|
||||
}
|
||||
}
|
||||
@@ -123,9 +140,9 @@ object KotlinPluginLayout {
|
||||
kotlincProvider = lazy {
|
||||
// NOTE: FromKotlinDistForIdeByNameFallbackBundledFirCompilerPluginProvider
|
||||
// requires it should be under KotlinArtifactConstants.KOTLIN_DIST_LOCATION_PREFIX
|
||||
provider.getKotlincCompilerCli().toFile()
|
||||
provider.getKotlincCompilerCli()
|
||||
}
|
||||
jpsPluginClasspathProvider = lazy { provider.getJpsPluginClasspath().map { it.toFile() } }
|
||||
jpsPluginClasspathProvider = lazy { provider.getJpsPluginClasspath() }
|
||||
standaloneCompilerVersionProvider = standaloneCompilerVersionDefaultProvider
|
||||
}
|
||||
else {
|
||||
@@ -140,8 +157,8 @@ object KotlinPluginLayout {
|
||||
bundledJpsVersion
|
||||
) ?: error("Can't download dist")
|
||||
val unpackedDistDir =
|
||||
KotlinArtifactConstants.KOTLIN_DIST_LOCATION_PREFIX.resolve("kotlinc-dist-for-ide-from-sources")
|
||||
LazyZipUnpacker(unpackedDistDir).lazyUnpack(distJar)
|
||||
KotlinArtifactConstants.KOTLIN_DIST_LOCATION_PREFIX_PATH.resolve("kotlinc-dist-for-ide-from-sources")
|
||||
LazyZipUnpacker(unpackedDistDir.toFile()).lazyUnpack(distJar)
|
||||
}
|
||||
|
||||
jpsPluginClasspathProvider = lazy {
|
||||
@@ -152,7 +169,7 @@ object KotlinPluginLayout {
|
||||
bundledJpsVersion
|
||||
)
|
||||
|
||||
listOf(jpsPluginArtifact.toFile())
|
||||
listOf(jpsPluginArtifact)
|
||||
}
|
||||
standaloneCompilerVersionProvider = standaloneCompilerVersionDefaultProvider
|
||||
}
|
||||
@@ -162,7 +179,7 @@ object KotlinPluginLayout {
|
||||
val kotlinPluginRoot = getPluginDistDirByClass(KotlinPluginLayout::class.java)
|
||||
?: error("Can't find jar file for ${KotlinPluginLayout::class.simpleName}")
|
||||
|
||||
fun resolve(path: String) = kotlinPluginRoot.resolve(path).also { check(it.exists()) { "$it doesn't exist" } }.toFile()
|
||||
fun resolve(path: String) = kotlinPluginRoot.resolve(path).also { check(it.exists()) { "$it doesn't exist" } }
|
||||
|
||||
kotlincProvider = lazy { resolve("kotlinc") }
|
||||
jpsPluginClasspathProvider = lazy { listOf(resolve("lib/jps/kotlin-jps-plugin.jar")) }
|
||||
|
||||
+7
-6
@@ -2,20 +2,21 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.compilerPlugin.allopen.gradleJava
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import org.jetbrains.kotlin.allopen.AllOpenPluginNames.ANNOTATION_OPTION_NAME
|
||||
import org.jetbrains.kotlin.allopen.AllOpenPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.allopen.AllOpenPluginNames.SUPPORTED_PRESETS
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.gradleJava.compilerPlugin.AbstractAnnotationBasedCompilerPluginGradleImportHandler
|
||||
import org.jetbrains.kotlin.idea.gradleTooling.model.allopen.AllOpenModel
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import java.nio.file.Path
|
||||
|
||||
class AllOpenGradleProjectImportHandler : AbstractAnnotationBasedCompilerPluginGradleImportHandler<AllOpenModel>() {
|
||||
override val compilerPluginId = PLUGIN_ID
|
||||
override val pluginName = "allopen"
|
||||
override val annotationOptionName = ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFileFromIdea: String = KotlinArtifacts.allopenCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val modelKey = AllOpenProjectResolverExtension.KEY
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = "allopen"
|
||||
override val annotationOptionName: String = ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFromIdea: Path = KotlinArtifacts.allopenCompilerPluginPath
|
||||
override val modelKey: Key<AllOpenModel> = AllOpenProjectResolverExtension.KEY
|
||||
|
||||
override fun getAnnotationsForPreset(presetName: String): List<String> {
|
||||
for ((name, annotations) in SUPPORTED_PRESETS.entries) {
|
||||
|
||||
+5
-5
@@ -8,14 +8,14 @@ import org.jetbrains.kotlin.allopen.AllOpenPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.allopen.AllOpenPluginNames.SUPPORTED_PRESETS
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import java.nio.file.Path
|
||||
|
||||
class AllOpenMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
override val compilerPluginId = PLUGIN_ID
|
||||
override val pluginName = "allopen"
|
||||
override val mavenPluginArtifactName = "kotlin-maven-allopen"
|
||||
override val pluginJarFileFromIdea = KotlinArtifacts.allopenCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = "allopen"
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-allopen"
|
||||
override val pluginJarFileFromIdea: Path = KotlinArtifacts.allopenCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+7
-6
@@ -5,17 +5,18 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.compilerPlugin.assignment.gradleJava
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import org.jetbrains.kotlin.assignment.plugin.AssignmentPluginNames.ANNOTATION_OPTION_NAME
|
||||
import org.jetbrains.kotlin.assignment.plugin.AssignmentPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.gradleJava.compilerPlugin.AbstractAnnotationBasedCompilerPluginGradleImportHandler
|
||||
import org.jetbrains.kotlin.idea.gradleTooling.model.assignment.AssignmentModel
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import java.nio.file.Path
|
||||
|
||||
class AssignmentGradleProjectImportHandler : AbstractAnnotationBasedCompilerPluginGradleImportHandler<AssignmentModel>() {
|
||||
override val compilerPluginId = PLUGIN_ID
|
||||
override val pluginName = "assignment"
|
||||
override val annotationOptionName = ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFileFromIdea: String = KotlinArtifacts.assignmentCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val modelKey = AssignmentProjectResolverExtension.KEY
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = "assignment"
|
||||
override val annotationOptionName: String = ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFromIdea: Path = KotlinArtifacts.assignmentCompilerPluginPath
|
||||
override val modelKey: Key<AssignmentModel> = AssignmentProjectResolverExtension.KEY
|
||||
}
|
||||
|
||||
+5
-5
@@ -10,18 +10,18 @@ import org.jetbrains.kotlin.assignment.plugin.AssignmentPluginNames.ANNOTATION_O
|
||||
import org.jetbrains.kotlin.assignment.plugin.AssignmentPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import java.nio.file.Path
|
||||
|
||||
class AssignmentMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
private companion object {
|
||||
const val ANNOTATION_PARAMETER_PREFIX = "assignment:$ANNOTATION_OPTION_NAME="
|
||||
}
|
||||
|
||||
override val compilerPluginId = PLUGIN_ID
|
||||
override val pluginName = "assignment"
|
||||
override val mavenPluginArtifactName = "kotlin-maven-assignment"
|
||||
override val pluginJarFileFromIdea = KotlinArtifacts.assignmentCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = "assignment"
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-assignment"
|
||||
override val pluginJarFileFromIdea: Path = KotlinArtifacts.assignmentCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+11
-8
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.facet.getInstance
|
||||
import org.jetbrains.kotlin.idea.serialization.updateCompilerArguments
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
fun Module.getSpecialAnnotations(prefix: String): List<String> =
|
||||
KotlinCommonCompilerArgumentsHolder.getInstance(this).pluginOptions
|
||||
@@ -17,7 +18,7 @@ fun Module.getSpecialAnnotations(prefix: String): List<String> =
|
||||
?.map { it.substring(prefix.length) }
|
||||
?: emptyList()
|
||||
|
||||
class CompilerPluginSetup(val options: List<PluginOption>, val classpath: List<String>) {
|
||||
class CompilerPluginSetup(val options: List<PluginOption>, val classpath: List<Path>) {
|
||||
class PluginOption(val key: String, val value: String)
|
||||
}
|
||||
|
||||
@@ -26,7 +27,9 @@ fun modifyCompilerArgumentsForPlugin(
|
||||
setup: CompilerPluginSetup?,
|
||||
compilerPluginId: String,
|
||||
pluginName: String
|
||||
) = modifyCompilerArgumentsForPluginWithFacetSettings(facet.configuration.settings, setup, compilerPluginId, pluginName)
|
||||
) {
|
||||
modifyCompilerArgumentsForPluginWithFacetSettings(facet.configuration.settings, setup, compilerPluginId, pluginName)
|
||||
}
|
||||
|
||||
fun modifyCompilerArgumentsForPluginWithFacetSettings(
|
||||
facetSettings: IKotlinFacetSettings,
|
||||
@@ -53,14 +56,14 @@ private fun getNewPluginClasspathsOrNull(
|
||||
commonArguments: CommonCompilerArguments,
|
||||
pluginName: String,
|
||||
setup: CompilerPluginSetup?
|
||||
): Array<String>? {
|
||||
): Array<Path>? {
|
||||
val oldPluginClasspaths = (commonArguments.pluginClasspaths ?: emptyArray()).filterTo(mutableListOf()) {
|
||||
val lastIndexOfFile = it.lastIndexOfAny(charArrayOf('/', File.separatorChar))
|
||||
if (lastIndexOfFile < 0) {
|
||||
return@filterTo true
|
||||
}
|
||||
!it.drop(lastIndexOfFile + 1).matches("(kotlin-)?(maven-)?$pluginName-.*\\.jar".toRegex())
|
||||
}
|
||||
}.map(Path::of)
|
||||
|
||||
val newClasspath = setup?.classpath ?: emptyList()
|
||||
val newPluginClasspaths = (oldPluginClasspaths + newClasspath).toTypedArray()
|
||||
@@ -86,21 +89,21 @@ private fun setupCompilerArguments(
|
||||
facetSettings: IKotlinFacetSettings,
|
||||
commonArguments: CommonCompilerArguments,
|
||||
newOptionsForPlugin: Array<String>?,
|
||||
newClasspath: Array<String>?,
|
||||
newClasspath: Array<Path>?,
|
||||
) {
|
||||
newOptionsForPlugin?.also { commonArguments.pluginOptions = newOptionsForPlugin }
|
||||
newClasspath?.also { commonArguments.pluginClasspaths = newClasspath }
|
||||
newClasspath?.also { commonArguments.pluginClasspaths = newClasspath.map(Path::toString).toTypedArray() }
|
||||
facetSettings.compilerArguments = commonArguments
|
||||
}
|
||||
|
||||
private fun updateCompilerArgumentsIfNeeded(
|
||||
facetSettings: IKotlinFacetSettings,
|
||||
newOptionsForPlugin: Array<String>?,
|
||||
newClasspath: Array<String>?,
|
||||
newClasspath: Array<Path>?,
|
||||
) {
|
||||
if (newOptionsForPlugin == null && newClasspath == null) return
|
||||
facetSettings.updateCompilerArguments {
|
||||
newOptionsForPlugin?.also { pluginOptions = newOptionsForPlugin }
|
||||
newClasspath?.also { pluginClasspaths = newClasspath }
|
||||
newClasspath?.also { pluginClasspaths = newClasspath.map(Path::toString).toTypedArray() }
|
||||
}
|
||||
}
|
||||
+9
-2
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.gradleJava.configuration.GradleProjectImportHandler
|
||||
import org.jetbrains.kotlin.idea.gradleTooling.model.annotation.AnnotationBasedPluginModel
|
||||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
|
||||
import java.nio.file.Path
|
||||
|
||||
abstract class AbstractAnnotationBasedCompilerPluginGradleImportHandler<T : AnnotationBasedPluginModel> : AbstractCompilerPluginGradleImportHandler<T>() {
|
||||
abstract val annotationOptionName: String
|
||||
@@ -36,7 +37,13 @@ abstract class AbstractAnnotationBasedCompilerPluginGradleImportHandler<T : Anno
|
||||
abstract class AbstractCompilerPluginGradleImportHandler<T> : GradleProjectImportHandler {
|
||||
abstract val compilerPluginId: String
|
||||
abstract val pluginName: String
|
||||
abstract val pluginJarFileFromIdea: String
|
||||
|
||||
open val pluginJarFromIdea: Path
|
||||
get() = Path.of(pluginJarFileFromIdea)
|
||||
|
||||
@Deprecated("Use pluginJarFromIdea instead")
|
||||
open val pluginJarFileFromIdea: String
|
||||
get() = pluginJarFromIdea.toString()
|
||||
abstract val modelKey: Key<T>
|
||||
|
||||
override fun importBySourceSet(facet: KotlinFacet, sourceSetNode: DataNode<GradleSourceSetData>) {
|
||||
@@ -62,7 +69,7 @@ abstract class AbstractCompilerPluginGradleImportHandler<T> : GradleProjectImpor
|
||||
|
||||
// For now we can't use plugins from Gradle cause they're shaded and may have an incompatible version.
|
||||
// So we use ones from the IDEA plugin.
|
||||
val classpath = listOf(pluginJarFileFromIdea)
|
||||
val classpath = listOf(pluginJarFromIdea)
|
||||
|
||||
return CompilerPluginSetup(options, classpath)
|
||||
}
|
||||
|
||||
+2
-1
@@ -12,12 +12,13 @@ import org.jetbrains.kotlin.idea.compilerPlugin.modifyCompilerArgumentsForPlugin
|
||||
import org.jetbrains.kotlin.idea.maven.KotlinMavenImporter.Companion.KOTLIN_PLUGIN_ARTIFACT_ID
|
||||
import org.jetbrains.kotlin.idea.maven.KotlinMavenImporter.Companion.KOTLIN_PLUGIN_GROUP_ID
|
||||
import org.jetbrains.kotlin.idea.maven.MavenProjectImportHandler
|
||||
import java.nio.file.Path
|
||||
|
||||
abstract class AbstractMavenImportHandler : MavenProjectImportHandler {
|
||||
abstract val compilerPluginId: String
|
||||
abstract val pluginName: String
|
||||
abstract val mavenPluginArtifactName: String
|
||||
abstract val pluginJarFileFromIdea: String
|
||||
abstract val pluginJarFileFromIdea: Path
|
||||
|
||||
override fun invoke(facetSettings: IKotlinFacetSettings, mavenProject: MavenProject) {
|
||||
modifyCompilerArgumentsForPluginWithFacetSettings(
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.modifyCompilerArgumentsForPlugin
|
||||
import org.jetbrains.kotlin.idea.serialization.updateCompilerArguments
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import java.nio.file.Path
|
||||
|
||||
class IdePluginUtilsTest : KotlinFacetTestCase() {
|
||||
val facet
|
||||
@@ -22,7 +23,7 @@ class IdePluginUtilsTest : KotlinFacetTestCase() {
|
||||
fun `test modify empty compiler arguments for plugin with new classpath and new options`() {
|
||||
val compilerPluginSetup = CompilerPluginSetup(
|
||||
listOf(CompilerPluginSetup.PluginOption("optionKey", "optionValue")),
|
||||
listOf("newClassPath")
|
||||
listOf(Path.of("newClassPath"))
|
||||
)
|
||||
|
||||
modifyCompilerArgumentsForPlugin(facet, compilerPluginSetup, compilerPluginId, pluginName)
|
||||
@@ -52,7 +53,7 @@ class IdePluginUtilsTest : KotlinFacetTestCase() {
|
||||
|
||||
val compilerPluginSetup = CompilerPluginSetup(
|
||||
listOf(CompilerPluginSetup.PluginOption("optionKey", "optionValue")),
|
||||
listOf("newClassPath")
|
||||
listOf(Path.of("newClassPath"))
|
||||
)
|
||||
|
||||
modifyCompilerArgumentsForPlugin(facet, compilerPluginSetup, compilerPluginId, pluginName)
|
||||
|
||||
+3
-3
@@ -5,15 +5,15 @@ package org.jetbrains.kotlin.idea.compilerPlugin.kotlinDataFrame.maven
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import java.nio.file.Path
|
||||
|
||||
class KotlinDataFrameMavenImportHandler : AbstractMavenImportHandler() {
|
||||
override val compilerPluginId: String = "org.jetbrains.kotlin.dataframe"
|
||||
override val pluginName: String = "dataframe"
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-dataframe"
|
||||
override val pluginJarFileFromIdea: String
|
||||
get() = KotlinArtifacts.kotlinDataFrameCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val pluginJarFileFromIdea: Path
|
||||
get() = KotlinArtifacts.kotlinDataFrameCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+16
-8
@@ -6,12 +6,12 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifactNames
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
object KotlinSerializationImportHandler {
|
||||
val PLUGIN_JPS_JAR: String by lazy {
|
||||
KotlinArtifacts.kotlinxSerializationCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
val PLUGIN_JPS_JAR: Path by lazy {
|
||||
KotlinArtifacts.kotlinxSerializationCompilerPluginPath
|
||||
}
|
||||
|
||||
fun isPluginJarPath(path: String): Boolean {
|
||||
@@ -26,20 +26,28 @@ object KotlinSerializationImportHandler {
|
||||
val commonArguments = facetSettings.compilerArguments ?: CommonCompilerArguments.DummyImpl()
|
||||
|
||||
var pluginWasEnabled = false
|
||||
val oldPluginClasspaths = (commonArguments.pluginClasspaths ?: emptyArray()).filterTo(mutableListOf()) { jarPath ->
|
||||
val lastIndexOfFile = jarPath.lastIndexOfAny(charArrayOf('/', File.separatorChar))
|
||||
val oldPluginClasspaths = (commonArguments.pluginClasspaths?.map { Path.of(it) }?.toTypedArray() ?: emptyArray()).filterTo(mutableListOf()) { jarPath ->
|
||||
val str = jarPath.toString()
|
||||
val lastIndexOfFile = str.lastIndexOfAny(charArrayOf('/', File.separatorChar))
|
||||
if (lastIndexOfFile < 0) {
|
||||
return@filterTo true
|
||||
}
|
||||
|
||||
val jarFileName = jarPath.drop(lastIndexOfFile + 1)
|
||||
val jarFileName = str.drop(lastIndexOfFile + 1)
|
||||
val match = pluginJarsRegex.any { jarFileName.matches(it) }
|
||||
if (match) pluginWasEnabled = true
|
||||
!match
|
||||
}
|
||||
|
||||
val newPluginClasspaths = if (pluginWasEnabled) oldPluginClasspaths + PLUGIN_JPS_JAR else oldPluginClasspaths
|
||||
commonArguments.pluginClasspaths = newPluginClasspaths.toTypedArray()
|
||||
val newPluginClasspaths = if (pluginWasEnabled) {
|
||||
buildList {
|
||||
addAll(oldPluginClasspaths)
|
||||
add(PLUGIN_JPS_JAR)
|
||||
}
|
||||
} else {
|
||||
oldPluginClasspaths
|
||||
}
|
||||
commonArguments.pluginClasspaths = newPluginClasspaths.map { it.toString() }.toTypedArray()
|
||||
facetSettings.compilerArguments = commonArguments
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -5,15 +5,15 @@ package org.jetbrains.kotlin.idea.compilerPlugin.kotlinxSerialization.maven
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import java.nio.file.Path
|
||||
|
||||
class KotlinSerializationMavenImportHandler : AbstractMavenImportHandler() {
|
||||
override val compilerPluginId: String = "org.jetbrains.kotlinx.serialization"
|
||||
override val pluginName: String = "serialization"
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-serialization"
|
||||
override val pluginJarFileFromIdea: String
|
||||
get() = KotlinArtifacts.kotlinxSerializationCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val pluginJarFileFromIdea: Path
|
||||
get() = KotlinArtifacts.kotlinxSerializationCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+2
-2
@@ -6,13 +6,13 @@ import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup
|
||||
import org.jetbrains.kotlin.idea.gradleJava.compilerPlugin.AbstractCompilerPluginGradleImportHandler
|
||||
import org.jetbrains.kotlin.idea.gradleTooling.model.lombok.LombokModel
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.lombok.LombokPluginNames
|
||||
import java.nio.file.Path
|
||||
|
||||
class LombokGradleProjectImportHandler : AbstractCompilerPluginGradleImportHandler<LombokModel>() {
|
||||
|
||||
override val modelKey: Key<LombokModel> = LombokGradleProjectResolverExtension.KEY
|
||||
override val pluginJarFileFromIdea: String = KotlinArtifacts.lombokCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val pluginJarFromIdea: Path = KotlinArtifacts.lombokCompilerPluginPath
|
||||
override val compilerPluginId: String = LombokPluginNames.PLUGIN_ID
|
||||
override val pluginName: String = "lombok"
|
||||
|
||||
|
||||
+2
-2
@@ -5,17 +5,17 @@ package org.jetbrains.kotlin.idea.compilerPlugin.lombok.maven
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import org.jetbrains.kotlin.lombok.LombokPluginNames.CONFIG_OPTION_NAME
|
||||
import org.jetbrains.kotlin.lombok.LombokPluginNames.PLUGIN_ID
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
class LombokMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = MAVEN_SUBPLUGIN_NAME
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-lombok"
|
||||
override val pluginJarFileFromIdea: String = KotlinArtifacts.lombokCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val pluginJarFileFromIdea: Path = KotlinArtifacts.lombokCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+7
-6
@@ -2,22 +2,23 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.compilerPlugin.noarg.gradleJava
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.idea.gradleJava.compilerPlugin.AbstractAnnotationBasedCompilerPluginGradleImportHandler
|
||||
import org.jetbrains.kotlin.idea.gradleTooling.model.noarg.NoArgModel
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.ANNOTATION_OPTION_NAME
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.INVOKE_INITIALIZERS_OPTION_NAME
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.SUPPORTED_PRESETS
|
||||
import java.nio.file.Path
|
||||
|
||||
class NoArgGradleProjectImportHandler : AbstractAnnotationBasedCompilerPluginGradleImportHandler<NoArgModel>() {
|
||||
override val compilerPluginId = PLUGIN_ID
|
||||
override val pluginName = "noarg"
|
||||
override val annotationOptionName = ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFileFromIdea: String = KotlinArtifacts.noargCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val modelKey = NoArgProjectResolverExtension.KEY
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = "noarg"
|
||||
override val annotationOptionName: String = ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFromIdea: Path = KotlinArtifacts.noargCompilerPluginPath
|
||||
override val modelKey: Key<NoArgModel> = NoArgProjectResolverExtension.KEY
|
||||
|
||||
override fun getOptions(model: NoArgModel): List<PluginOption> {
|
||||
val additionalOptions = listOf(
|
||||
|
||||
+5
-5
@@ -5,18 +5,18 @@ package org.jetbrains.kotlin.idea.compilerPlugin.noarg.maven
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.ANNOTATION_OPTION_NAME
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.INVOKE_INITIALIZERS_OPTION_NAME
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.noarg.NoArgPluginNames.SUPPORTED_PRESETS
|
||||
import java.nio.file.Path
|
||||
|
||||
class NoArgMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
override val compilerPluginId = PLUGIN_ID
|
||||
override val pluginName = "noarg"
|
||||
override val mavenPluginArtifactName = "kotlin-maven-noarg"
|
||||
override val pluginJarFileFromIdea = KotlinArtifacts.noargCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val compilerPluginId: String = PLUGIN_ID
|
||||
override val pluginName: String = "noarg"
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-noarg"
|
||||
override val pluginJarFileFromIdea: Path = KotlinArtifacts.noargCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+7
-6
@@ -2,18 +2,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.compilerPlugin.samWithReceiver.gradleJava
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.gradleJava.compilerPlugin.AbstractAnnotationBasedCompilerPluginGradleImportHandler
|
||||
import org.jetbrains.kotlin.idea.gradleTooling.model.samWithReceiver.SamWithReceiverModel
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.samWithReceiver.SamWithReceiverPluginNames
|
||||
import java.nio.file.Path
|
||||
|
||||
class SamWithReceiverGradleProjectImportHandler : AbstractAnnotationBasedCompilerPluginGradleImportHandler<SamWithReceiverModel>() {
|
||||
override val compilerPluginId = SamWithReceiverPluginNames.PLUGIN_ID
|
||||
override val pluginName = "sam-with-receiver"
|
||||
override val annotationOptionName = SamWithReceiverPluginNames.ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFileFromIdea: String = KotlinArtifacts.samWithReceiverCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val modelKey = SamWithReceiverProjectResolverExtension.KEY
|
||||
override val compilerPluginId: String = SamWithReceiverPluginNames.PLUGIN_ID
|
||||
override val pluginName: String = "sam-with-receiver"
|
||||
override val annotationOptionName: String = SamWithReceiverPluginNames.ANNOTATION_OPTION_NAME
|
||||
override val pluginJarFromIdea: Path = KotlinArtifacts.samWithReceiverCompilerPluginPath
|
||||
override val modelKey: Key<SamWithReceiverModel> = SamWithReceiverProjectResolverExtension.KEY
|
||||
|
||||
override fun getAnnotationsForPreset(presetName: String): List<String> {
|
||||
for ((name, annotations) in SamWithReceiverPluginNames.SUPPORTED_PRESETS.entries) {
|
||||
|
||||
+5
-5
@@ -5,15 +5,15 @@ package org.jetbrains.kotlin.idea.compilerPlugin.samWithReceiver.maven
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.compilerPlugin.AbstractMavenImportHandler
|
||||
import org.jetbrains.kotlin.samWithReceiver.SamWithReceiverPluginNames
|
||||
import java.nio.file.Path
|
||||
|
||||
class SamWithReceiverMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
override val compilerPluginId = SamWithReceiverPluginNames.PLUGIN_ID
|
||||
override val pluginName = "samWithReceiver"
|
||||
override val mavenPluginArtifactName = "kotlin-maven-sam-with-receiver"
|
||||
override val pluginJarFileFromIdea = KotlinArtifacts.samWithReceiverCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
override val compilerPluginId: String = SamWithReceiverPluginNames.PLUGIN_ID
|
||||
override val pluginName: String = "samWithReceiver"
|
||||
override val mavenPluginArtifactName: String = "kotlin-maven-sam-with-receiver"
|
||||
override val pluginJarFileFromIdea: Path = KotlinArtifacts.samWithReceiverCompilerPluginPath
|
||||
|
||||
override fun getOptions(
|
||||
mavenProject: MavenProject,
|
||||
|
||||
+6
-7
@@ -56,7 +56,6 @@ import org.jetbrains.kotlin.idea.formatter.KotlinObsoleteStyleGuide
|
||||
import org.jetbrains.kotlin.idea.formatter.KotlinOfficialStyleGuide
|
||||
import org.jetbrains.kotlin.idea.formatter.kotlinCodeStyleDefaults
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.notification.asText
|
||||
import org.jetbrains.kotlin.idea.notification.catchNotificationTextAsync
|
||||
import org.jetbrains.kotlin.idea.notification.catchNotificationsAsync
|
||||
@@ -3647,12 +3646,12 @@ abstract class AbstractKotlinMavenImporterTest(private val createStdProjectFolde
|
||||
assertModules("project")
|
||||
assertEquals(
|
||||
listOf(
|
||||
KotlinArtifacts.allopenCompilerPlugin,
|
||||
KotlinArtifacts.kotlinxSerializationCompilerPlugin,
|
||||
KotlinArtifacts.lombokCompilerPlugin,
|
||||
KotlinArtifacts.noargCompilerPlugin,
|
||||
KotlinArtifacts.samWithReceiverCompilerPlugin,
|
||||
).map { it.toJpsVersionAgnosticKotlinBundledPath() },
|
||||
KotlinArtifacts.allopenCompilerPluginPath,
|
||||
KotlinArtifacts.kotlinxSerializationCompilerPluginPath,
|
||||
KotlinArtifacts.lombokCompilerPluginPath,
|
||||
KotlinArtifacts.noargCompilerPluginPath,
|
||||
KotlinArtifacts.samWithReceiverCompilerPluginPath,
|
||||
).map { it.toString() },
|
||||
facetSettings.compilerArguments?.pluginClasspaths?.sorted()
|
||||
)
|
||||
}
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
package org.jetbrains.kotlin.idea.maven.importer
|
||||
|
||||
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
|
||||
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
|
||||
import org.jetbrains.kotlin.idea.maven.AbstractKotlinMavenImporterTest
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
@@ -94,7 +93,7 @@ class KotlinLombokMavenImporterTest : AbstractKotlinMavenImporterTest(false) {
|
||||
)
|
||||
assertContain(
|
||||
compilerArguments!!.pluginClasspaths!!.toList(),
|
||||
KotlinArtifacts.lombokCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
|
||||
KotlinArtifacts.lombokCompilerPluginPath.toString()
|
||||
)
|
||||
assertEquals(
|
||||
compilerArguments!!.pluginOptions!!.toList(),
|
||||
|
||||
Reference in New Issue
Block a user