Revert "KTIJ-37485 [kotlin]: Migrate from File to Path"

This reverts commit 7e8e4839

GitOrigin-RevId: 55de387738eb6af22539930652b791573065e731
This commit is contained in:
Vladimir Dolzhenko
2026-02-24 13:12:34 +00:00
committed by intellij-monorepo-bot
parent 52f898c170
commit 54ce9d16b7
25 changed files with 146 additions and 370 deletions
@@ -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.kotlinStdlibPath, OrderRootType.CLASSES)
addRoot(KotlinArtifacts.kotlinStdlibSourcesPath, OrderRootType.SOURCES)
addRoot(KotlinArtifacts.kotlinStdlib, OrderRootType.CLASSES)
addRoot(KotlinArtifacts.kotlinStdlibSources, OrderRootType.SOURCES)
}
}
}
@@ -1,11 +1,11 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 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.nio.file.Path
import java.io.File
fun Path.toJpsVersionAgnosticKotlinBundledPath(): String {
val kotlincDirectory = KotlinPluginLayout.kotlincPath
fun File.toJpsVersionAgnosticKotlinBundledPath(): String {
val kotlincDirectory = KotlinPluginLayout.kotlinc
require(this.startsWith(kotlincDirectory)) { "$this should start with ${kotlincDirectory}" }
return "\$KOTLIN_BUNDLED\$/${relativize(kotlincDirectory)}"
return "\$KOTLIN_BUNDLED\$/${relativeTo(kotlincDirectory)}"
}
@@ -5,42 +5,35 @@ 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: String = "org.jetbrains.kotlin"
const val KOTLIN_MAVEN_GROUP_ID = "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: String = "kotlin-dist-for-ide"
const val OLD_KOTLIN_DIST_ARTIFACT_ID = "kotlin-dist-for-ide"
@NlsSafe
const val KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID: String = "kotlin-dist-for-jps-meta"
const val KOTLIN_DIST_FOR_JPS_META_ARTIFACT_ID = "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: String = "kotlin-jps-plugin-classpath"
const val OLD_FAT_JAR_KOTLIN_JPS_PLUGIN_CLASSPATH_ARTIFACT_ID = "kotlin-jps-plugin-classpath"
@NlsSafe
const val KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID: String = "kotlin-jps-plugin"
const val KOTLIN_JPS_PLUGIN_PLUGIN_ARTIFACT_ID = "kotlin-jps-plugin"
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()
val KOTLIN_DIST_LOCATION_PREFIX: File = File(PathManager.getSystemPath(), "kotlin-dist-for-ide")
}
/**
@@ -50,260 +43,91 @@ object KotlinArtifactConstants {
* For tests use [TestKotlinArtifacts]
*/
object KotlinArtifacts {
private val kotlincBinDirectoryPath: Path = KotlinPluginLayout.kotlincPath.resolve("bin")
private val kotlincBinDirectory: File = File(KotlinPluginLayout.kotlinc, "bin")
private val kotlincLibDirectoryPath: Path = KotlinPluginLayout.kotlincPath.resolve("lib")
private val kotlincLibDirectory: File = File(KotlinPluginLayout.kotlinc, "lib")
@JvmStatic
val jetbrainsAnnotationsPath: Path = kotlincLibDirectoryPath.resolve(JETBRAINS_ANNOTATIONS)
@Suppress("IO_FILE_USAGE")
@Deprecated("Use jetbrainsAnnotationsPath instead", ReplaceWith("jetbrainsAnnotationsPath"))
@JvmStatic
val jetbrainsAnnotations: File
get() = jetbrainsAnnotationsPath.toFile()
val jetbrainsAnnotations: File = File(kotlincLibDirectory, KotlinArtifactNames.JETBRAINS_ANNOTATIONS)
@JvmStatic
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()
val kotlinStdlib: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB)
@JvmStatic
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()
val kotlinStdlibSources: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_SOURCES)
@JvmStatic
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()
val kotlinStdlibJdk7: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK7)
@JvmStatic
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()
val kotlinStdlibJdk7Sources: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK7_SOURCES)
@JvmStatic
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()
val kotlinStdlibJdk8: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK8)
@JvmStatic
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()
val kotlinStdlibJdk8Sources: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JDK8_SOURCES)
@JvmStatic
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()
val kotlinReflect: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_REFLECT)
@JvmStatic
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()
val kotlinStdlibJs: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_STDLIB_JS)
@JvmStatic
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()
val kotlinMainKts: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_MAIN_KTS)
@JvmStatic
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()
val kotlinScriptRuntime: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPT_RUNTIME)
@JvmStatic
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()
val kotlinScriptingCommon: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_COMMON)
@JvmStatic
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()
val kotlinScriptingJvm: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_JVM)
@JvmStatic
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()
val kotlinCompiler: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_COMPILER)
@JvmStatic
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()
val lombokCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.LOMBOK_COMPILER_PLUGIN)
@JvmStatic
val trove4jPath: Path = kotlincLibDirectoryPath.resolve(KotlinArtifactNames.TROVE4J)
@Suppress("IO_FILE_USAGE")
@Deprecated("Use trove4jPath instead", ReplaceWith("trove4jPath"))
@JvmStatic
val trove4j: File
get() = trove4jPath.toFile()
val trove4j: File = File(kotlincLibDirectory, KotlinArtifactNames.TROVE4J)
@JvmStatic
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()
val kotlinDaemon: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_DAEMON)
@JvmStatic
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()
val kotlinScriptingCompiler: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_COMPILER)
@JvmStatic
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()
val kotlinScriptingCompilerImpl: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_SCRIPTING_COMPILER_IMPL)
@JvmStatic
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()
val allopenCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.ALLOPEN_COMPILER_PLUGIN)
@JvmStatic
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()
val noargCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.NOARG_COMPILER_PLUGIN)
@JvmStatic
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()
val samWithReceiverCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.SAM_WITH_RECEIVER_COMPILER_PLUGIN)
@JvmStatic
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()
val assignmentCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.ASSIGNMENT_COMPILER_PLUGIN)
@JvmStatic
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()
val kotlinxSerializationCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLINX_SERIALIZATION_COMPILER_PLUGIN)
@JvmStatic
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()
val powerAssertPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.POWER_ASSERT_COMPILER_PLUGIN)
@JvmStatic
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()
val kotlinDataFrameCompilerPlugin: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_DATAFRAME_COMPILER_PLUGIN)
@JvmStatic
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()
val kotlinPreloader: File = File(kotlincLibDirectory, KotlinArtifactNames.KOTLIN_PRELOADER)
@JvmStatic
val kotlincPath: Path = kotlincBinDirectoryPath.resolve(KotlinArtifactNames.KOTLINC)
@Suppress("IO_FILE_USAGE")
@Deprecated("Use kotlincPath instead", ReplaceWith("kotlincPath"))
@JvmStatic
val kotlinc: File
get() = kotlincPath.toFile()
val kotlinc: File = File(kotlincBinDirectory, KotlinArtifactNames.KOTLINC)
}
@@ -5,7 +5,6 @@ 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>(
@@ -25,14 +24,9 @@ internal class LazyZipUnpacker(private val destination: File) : AbstractLazyFile
DigestUtil.updateContentHash(messageDigest, input.toPath(), buffer)
}
fun lazyUnpack(zip: File): File {
return lazyProduceOutput(zip, Unit).singleOrNull()
?: error("${LazyZipUnpacker::produceOutput.name} returns only single element")
}
fun lazyUnpack(zip: File) = 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")
}
@@ -32,7 +32,6 @@ 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
@@ -183,14 +182,14 @@ object KotlinArtifactsDownloader {
.distinct()
}
fun downloadMavenArtifact(groupId: String, artifactId: String, version: String, suffix: String = ".jar"): Path? {
fun downloadMavenArtifact(groupId: String, artifactId: String, version: String, suffix: String = ".jar"): File? {
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
return it.toFile()
}
val fileName = "$artifactId-$version$suffix"
@@ -219,11 +218,11 @@ object KotlinArtifactsDownloader {
check(artifact.exists()) { "$artifact should be downloaded" }
}
return artifact
return artifact.toFile()
}
@JvmOverloads
fun downloadArtifactForIdeFromSources(artifactId: String, version: String, suffix: String = ".jar"): Path? {
fun downloadArtifactForIdeFromSources(artifactId: String, version: String, suffix: String = ".jar"): File? {
return downloadMavenArtifact(KOTLIN_MAVEN_GROUP_ID, artifactId, version, suffix)
}
@@ -68,31 +68,14 @@ object KotlinPluginLayout {
* with a compatible version.
*/
@JvmStatic
val kotlincPath: Path
val kotlinc: File
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 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)
get() = jpsPluginClasspathProvider.value
val jsEngines: File? by lazy {
kotlinc.resolve("lib").resolve("js.engines.jar").takeIf { it.exists() }
@@ -113,17 +96,17 @@ object KotlinPluginLayout {
@JvmStatic
val ideCompilerVersion: IdeKotlinVersion = IdeKotlinVersion.get(KotlinCompilerVersion.VERSION)
private val kotlincProvider: Lazy<Path>
private val jpsPluginClasspathProvider: Lazy<List<Path>>
private val kotlincProvider: Lazy<File>
private val jpsPluginClasspathProvider: Lazy<List<File>>
private val standaloneCompilerVersionProvider: Lazy<IdeKotlinVersion>
init {
val standaloneCompilerVersionDefaultProvider = lazy {
val buildTxtPath = kotlincPath.resolve("build.txt")
if (!buildTxtPath.exists()) {
val buildTxtFile = kotlinc.resolve("build.txt")
if (!buildTxtFile.exists()) {
ideCompilerVersion
} else {
val rawVersion = Files.readString(buildTxtPath).trim()
val rawVersion = buildTxtFile.readText().trim()
IdeKotlinVersion.get(rawVersion)
}
}
@@ -140,9 +123,9 @@ object KotlinPluginLayout {
kotlincProvider = lazy {
// NOTE: FromKotlinDistForIdeByNameFallbackBundledFirCompilerPluginProvider
// requires it should be under KotlinArtifactConstants.KOTLIN_DIST_LOCATION_PREFIX
provider.getKotlincCompilerCli()
provider.getKotlincCompilerCli().toFile()
}
jpsPluginClasspathProvider = lazy { provider.getJpsPluginClasspath() }
jpsPluginClasspathProvider = lazy { provider.getJpsPluginClasspath().map { it.toFile() } }
standaloneCompilerVersionProvider = standaloneCompilerVersionDefaultProvider
}
else {
@@ -157,8 +140,8 @@ object KotlinPluginLayout {
bundledJpsVersion
) ?: error("Can't download dist")
val unpackedDistDir =
KotlinArtifactConstants.KOTLIN_DIST_LOCATION_PREFIX_PATH.resolve("kotlinc-dist-for-ide-from-sources")
LazyZipUnpacker(unpackedDistDir.toFile()).lazyUnpack(distJar)
KotlinArtifactConstants.KOTLIN_DIST_LOCATION_PREFIX.resolve("kotlinc-dist-for-ide-from-sources")
LazyZipUnpacker(unpackedDistDir).lazyUnpack(distJar)
}
jpsPluginClasspathProvider = lazy {
@@ -169,7 +152,7 @@ object KotlinPluginLayout {
bundledJpsVersion
)
listOf(jpsPluginArtifact)
listOf(jpsPluginArtifact.toFile())
}
standaloneCompilerVersionProvider = standaloneCompilerVersionDefaultProvider
}
@@ -179,7 +162,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" } }
fun resolve(path: String) = kotlinPluginRoot.resolve(path).also { check(it.exists()) { "$it doesn't exist" } }.toFile()
kotlincProvider = lazy { resolve("kotlinc") }
jpsPluginClasspathProvider = lazy { listOf(resolve("lib/jps/kotlin-jps-plugin.jar")) }
@@ -2,21 +2,20 @@
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 java.nio.file.Path
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
class AllOpenGradleProjectImportHandler : AbstractAnnotationBasedCompilerPluginGradleImportHandler<AllOpenModel>() {
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 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 fun getAnnotationsForPreset(presetName: String): List<String> {
for ((name, annotations) in SUPPORTED_PRESETS.entries) {
@@ -10,15 +10,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
import org.jetbrains.kotlin.idea.maven.getKotlinPlugin
class AllOpenMavenProjectImportHandler : AbstractMavenImportHandler() {
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 val compilerPluginId = PLUGIN_ID
override val pluginName = "allopen"
override val mavenPluginArtifactName = "kotlin-maven-allopen"
override val pluginJarFileFromIdea = KotlinArtifacts.allopenCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -5,18 +5,17 @@
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 java.nio.file.Path
import org.jetbrains.kotlin.idea.jps.toJpsVersionAgnosticKotlinBundledPath
class AssignmentGradleProjectImportHandler : AbstractAnnotationBasedCompilerPluginGradleImportHandler<AssignmentModel>() {
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
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
}
@@ -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: String = PLUGIN_ID
override val pluginName: String = "assignment"
override val mavenPluginArtifactName: String = "kotlin-maven-assignment"
override val pluginJarFileFromIdea: Path = KotlinArtifacts.assignmentCompilerPluginPath
override val compilerPluginId = PLUGIN_ID
override val pluginName = "assignment"
override val mavenPluginArtifactName = "kotlin-maven-assignment"
override val pluginJarFileFromIdea = KotlinArtifacts.assignmentCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -10,7 +10,6 @@ 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
@@ -18,7 +17,7 @@ fun Module.getSpecialAnnotations(prefix: String): List<String> =
?.map { it.substring(prefix.length) }
?: emptyList()
class CompilerPluginSetup(val options: List<PluginOption>, val classpath: List<Path>) {
class CompilerPluginSetup(val options: List<PluginOption>, val classpath: List<String>) {
class PluginOption(val key: String, val value: String)
}
@@ -27,9 +26,7 @@ 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,
@@ -56,14 +53,14 @@ private fun getNewPluginClasspathsOrNull(
commonArguments: CommonCompilerArguments,
pluginName: String,
setup: CompilerPluginSetup?
): Array<Path>? {
): Array<String>? {
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()
@@ -89,21 +86,21 @@ private fun setupCompilerArguments(
facetSettings: IKotlinFacetSettings,
commonArguments: CommonCompilerArguments,
newOptionsForPlugin: Array<String>?,
newClasspath: Array<Path>?,
newClasspath: Array<String>?,
) {
newOptionsForPlugin?.also { commonArguments.pluginOptions = newOptionsForPlugin }
newClasspath?.also { commonArguments.pluginClasspaths = newClasspath.map(Path::toString).toTypedArray() }
newClasspath?.also { commonArguments.pluginClasspaths = newClasspath }
facetSettings.compilerArguments = commonArguments
}
private fun updateCompilerArgumentsIfNeeded(
facetSettings: IKotlinFacetSettings,
newOptionsForPlugin: Array<String>?,
newClasspath: Array<Path>?,
newClasspath: Array<String>?,
) {
if (newOptionsForPlugin == null && newClasspath == null) return
facetSettings.updateCompilerArguments {
newOptionsForPlugin?.also { pluginOptions = newOptionsForPlugin }
newClasspath?.also { pluginClasspaths = newClasspath.map(Path::toString).toTypedArray() }
newClasspath?.also { pluginClasspaths = newClasspath }
}
}
@@ -14,7 +14,6 @@ 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
@@ -37,13 +36,7 @@ abstract class AbstractAnnotationBasedCompilerPluginGradleImportHandler<T : Anno
abstract class AbstractCompilerPluginGradleImportHandler<T> : GradleProjectImportHandler {
abstract val compilerPluginId: String
abstract val pluginName: String
open val pluginJarFromIdea: Path
get() = Path.of(pluginJarFileFromIdea)
@Deprecated("Use pluginJarFromIdea instead")
open val pluginJarFileFromIdea: String
get() = pluginJarFromIdea.toString()
abstract val pluginJarFileFromIdea: String
abstract val modelKey: Key<T>
override fun importBySourceSet(facet: KotlinFacet, sourceSetNode: DataNode<GradleSourceSetData>) {
@@ -69,7 +62,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(pluginJarFromIdea)
val classpath = listOf(pluginJarFileFromIdea)
return CompilerPluginSetup(options, classpath)
}
@@ -10,14 +10,12 @@ import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup
import org.jetbrains.kotlin.idea.compilerPlugin.CompilerPluginSetup.PluginOption
import org.jetbrains.kotlin.idea.compilerPlugin.modifyCompilerArgumentsForPluginWithFacetSettings
import org.jetbrains.kotlin.idea.maven.MavenProjectImportHandler
import java.nio.file.Path
import org.jetbrains.kotlin.idea.maven.findKotlinPlugin
abstract class AbstractMavenImportHandler : MavenProjectImportHandler {
abstract val compilerPluginId: String
abstract val pluginName: String
abstract val mavenPluginArtifactName: String
abstract val pluginJarFileFromIdea: Path
abstract val pluginJarFileFromIdea: String
override fun invoke(facetSettings: IKotlinFacetSettings, mavenProject: MavenProject) {
modifyCompilerArgumentsForPluginWithFacetSettings(
@@ -7,7 +7,6 @@ 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
@@ -23,7 +22,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(Path.of("newClassPath"))
listOf("newClassPath")
)
modifyCompilerArgumentsForPlugin(facet, compilerPluginSetup, compilerPluginId, pluginName)
@@ -53,7 +52,7 @@ class IdePluginUtilsTest : KotlinFacetTestCase() {
val compilerPluginSetup = CompilerPluginSetup(
listOf(CompilerPluginSetup.PluginOption("optionKey", "optionValue")),
listOf(Path.of("newClassPath"))
listOf("newClassPath")
)
modifyCompilerArgumentsForPlugin(facet, compilerPluginSetup, compilerPluginId, pluginName)
@@ -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: Path
get() = KotlinArtifacts.kotlinDataFrameCompilerPluginPath
override val pluginJarFileFromIdea: String
get() = KotlinArtifacts.kotlinDataFrameCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -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: Path by lazy {
KotlinArtifacts.kotlinxSerializationCompilerPluginPath
val PLUGIN_JPS_JAR: String by lazy {
KotlinArtifacts.kotlinxSerializationCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
}
fun isPluginJarPath(path: String): Boolean {
@@ -26,28 +26,20 @@ object KotlinSerializationImportHandler {
val commonArguments = facetSettings.compilerArguments ?: CommonCompilerArguments.DummyImpl()
var pluginWasEnabled = false
val oldPluginClasspaths = (commonArguments.pluginClasspaths?.map { Path.of(it) }?.toTypedArray() ?: emptyArray()).filterTo(mutableListOf()) { jarPath ->
val str = jarPath.toString()
val lastIndexOfFile = str.lastIndexOfAny(charArrayOf('/', File.separatorChar))
val oldPluginClasspaths = (commonArguments.pluginClasspaths ?: emptyArray()).filterTo(mutableListOf()) { jarPath ->
val lastIndexOfFile = jarPath.lastIndexOfAny(charArrayOf('/', File.separatorChar))
if (lastIndexOfFile < 0) {
return@filterTo true
}
val jarFileName = str.drop(lastIndexOfFile + 1)
val jarFileName = jarPath.drop(lastIndexOfFile + 1)
val match = pluginJarsRegex.any { jarFileName.matches(it) }
if (match) pluginWasEnabled = true
!match
}
val newPluginClasspaths = if (pluginWasEnabled) {
buildList {
addAll(oldPluginClasspaths)
add(PLUGIN_JPS_JAR)
}
} else {
oldPluginClasspaths
}
commonArguments.pluginClasspaths = newPluginClasspaths.map { it.toString() }.toTypedArray()
val newPluginClasspaths = if (pluginWasEnabled) oldPluginClasspaths + PLUGIN_JPS_JAR else oldPluginClasspaths
commonArguments.pluginClasspaths = newPluginClasspaths.toTypedArray()
facetSettings.compilerArguments = commonArguments
}
}
@@ -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: Path
get() = KotlinArtifacts.kotlinxSerializationCompilerPluginPath
override val pluginJarFileFromIdea: String
get() = KotlinArtifacts.kotlinxSerializationCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -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 pluginJarFromIdea: Path = KotlinArtifacts.lombokCompilerPluginPath
override val pluginJarFileFromIdea: String = KotlinArtifacts.lombokCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override val compilerPluginId: String = LombokPluginNames.PLUGIN_ID
override val pluginName: String = "lombok"
@@ -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: Path = KotlinArtifacts.lombokCompilerPluginPath
override val pluginJarFileFromIdea: String = KotlinArtifacts.lombokCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -2,23 +2,22 @@
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: 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 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 fun getOptions(model: NoArgModel): List<PluginOption> {
val additionalOptions = listOf(
@@ -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: String = PLUGIN_ID
override val pluginName: String = "noarg"
override val mavenPluginArtifactName: String = "kotlin-maven-noarg"
override val pluginJarFileFromIdea: Path = KotlinArtifacts.noargCompilerPluginPath
override val compilerPluginId = PLUGIN_ID
override val pluginName = "noarg"
override val mavenPluginArtifactName = "kotlin-maven-noarg"
override val pluginJarFileFromIdea = KotlinArtifacts.noargCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -2,19 +2,18 @@
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: 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 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 fun getAnnotationsForPreset(presetName: String): List<String> {
for ((name, annotations) in SamWithReceiverPluginNames.SUPPORTED_PRESETS.entries) {
@@ -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: 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 val compilerPluginId = SamWithReceiverPluginNames.PLUGIN_ID
override val pluginName = "samWithReceiver"
override val mavenPluginArtifactName = "kotlin-maven-sam-with-receiver"
override val pluginJarFileFromIdea = KotlinArtifacts.samWithReceiverCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
override fun getOptions(
mavenProject: MavenProject,
@@ -56,6 +56,7 @@ 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
@@ -3646,12 +3647,12 @@ abstract class AbstractKotlinMavenImporterTest(private val createStdProjectFolde
assertModules("project")
assertEquals(
listOf(
KotlinArtifacts.allopenCompilerPluginPath,
KotlinArtifacts.kotlinxSerializationCompilerPluginPath,
KotlinArtifacts.lombokCompilerPluginPath,
KotlinArtifacts.noargCompilerPluginPath,
KotlinArtifacts.samWithReceiverCompilerPluginPath,
).map { it.toString() },
KotlinArtifacts.allopenCompilerPlugin,
KotlinArtifacts.kotlinxSerializationCompilerPlugin,
KotlinArtifacts.lombokCompilerPlugin,
KotlinArtifacts.noargCompilerPlugin,
KotlinArtifacts.samWithReceiverCompilerPlugin,
).map { it.toJpsVersionAgnosticKotlinBundledPath() },
facetSettings.compilerArguments?.pluginClasspaths?.sorted()
)
}
@@ -2,6 +2,7 @@
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
@@ -93,7 +94,7 @@ class KotlinLombokMavenImporterTest : AbstractKotlinMavenImporterTest(false) {
)
assertContain(
compilerArguments!!.pluginClasspaths!!.toList(),
KotlinArtifacts.lombokCompilerPluginPath.toString()
KotlinArtifacts.lombokCompilerPlugin.toJpsVersionAgnosticKotlinBundledPath()
)
assertEquals(
compilerArguments!!.pluginOptions!!.toList(),