diff --git a/plugins/pill/pill-importer/src/ModelParser.kt b/plugins/pill/pill-importer/src/ModelParser.kt index 33d6ced42e0..110895cb0f0 100644 --- a/plugins/pill/pill-importer/src/ModelParser.kt +++ b/plugins/pill/pill-importer/src/ModelParser.kt @@ -228,7 +228,7 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String forTests = sourceSet.isTestSourceSet, sourceDirectories = sourceDirectories, resourceDirectories = resourceDirectories, - kotlinOptions = kotlinCompileTask?.let { getKotlinOptions(it) }, + kotlinOptions = kotlinCompileTask?.let { getKotlinOptions(it, project) }, compileClasspathConfigurationName = sourceSet.compileClasspathConfigurationName, runtimeClasspathConfigurationName = sourceSet.runtimeClasspathConfigurationName ) @@ -257,7 +257,7 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String return roots } - private fun getKotlinOptions(kotlinCompileTask: Any): PSourceRootKotlinOptions? { + private fun getKotlinOptions(kotlinCompileTask: Any, project: Project): PSourceRootKotlinOptions { val compileArguments = run { val method = kotlinCompileTask::class.java.getMethod("getSerializedCompilerArguments") method.isAccessible = true @@ -270,6 +270,12 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String val extraArguments = compileArguments.filter { it.startsWith("-X") && !it.startsWith("-Xplugin=") } + val pluginClasspath = mutableListOf() + + if (project.plugins.hasPlugin("org.jetbrains.kotlin.plugin.serialization")) { + pluginClasspath += "\$KOTLIN_BUNDLED\$/lib/kotlinx-serialization-compiler-plugin.jar" + } + return PSourceRootKotlinOptions( parseBoolean("no-stdlib"), parseBoolean("no-reflect"), @@ -277,7 +283,8 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String parseString("api-version"), parseString("language-version"), parseString("jvm-target"), - extraArguments + extraArguments, + pluginClasspath ) } diff --git a/plugins/pill/pill-importer/src/model/PModule.kt b/plugins/pill/pill-importer/src/model/PModule.kt index 0b55f675439..678bb9a3f11 100644 --- a/plugins/pill/pill-importer/src/model/PModule.kt +++ b/plugins/pill/pill-importer/src/model/PModule.kt @@ -38,5 +38,6 @@ data class PSourceRootKotlinOptions( val apiVersion: String?, val languageVersion: String?, val jvmTarget: String?, - val extraArguments: List + val extraArguments: List, + val pluginClasspath: List ) \ No newline at end of file diff --git a/plugins/pill/pill-importer/src/render.kt b/plugins/pill/pill-importer/src/render.kt index 4544b4e258a..4c64668eb8b 100644 --- a/plugins/pill/pill-importer/src/render.kt +++ b/plugins/pill/pill-importer/src/render.kt @@ -88,7 +88,13 @@ private fun renderModule(project: PProject, module: PModule) = PFile( kotlinCompileOptions.apiVersion.option("apiVersion") xml("option", "name" to "pluginOptions") { xml("array") } - xml("option", "name" to "pluginClasspaths") { xml("array") } + xml("option", "name" to "pluginClasspaths") { + xml("array") { + for (path in kotlinCompileOptions.pluginClasspath) { + xml("option", "value" to path) + } + } + } } } }