From 9309a864ce8208e367b6ae14ff06cb4b472319cd Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Mon, 17 Apr 2023 16:24:10 +0200 Subject: [PATCH] [Gradle] IdeCompilerArgumentsResolver: Do not resolve compile tasks DependencyClasspath as it is not needed for JPS builds. JPS will build the classpath by reading the IJ project model. Classpath entries added as freeCompilerArgs will still be forwarded KTIJ-25227 --- .../ide/IdeCompilerArgumentsResolver.kt | 2 +- .../ide/IdeCompilerArgumentsResolverImpl.kt | 22 ++----------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolver.kt index 164e0efb0ff..d170da37748 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolver.kt @@ -21,7 +21,7 @@ interface IdeCompilerArgumentsResolver { @JvmStatic fun instance(project: Project): IdeCompilerArgumentsResolver { return project.extraProperties.getOrPut(IdeCompilerArgumentsResolver::class.java.name) { - IdeCompilerArgumentsResolverImpl(project.kotlinExtension) + IdeCompilerArgumentsResolverImpl() } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolverImpl.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolverImpl.kt index 4e22c4714e1..9a7e8b78682 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolverImpl.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide/IdeCompilerArgumentsResolverImpl.kt @@ -6,17 +6,11 @@ package org.jetbrains.kotlin.gradle.plugin.ide import org.jetbrains.kotlin.compilerRunner.toArgumentStrings -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.CreateCompilerArgumentsContext import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jetbrains.kotlin.gradle.utils.hasAndroidPlugin -internal class IdeCompilerArgumentsResolverImpl( - private val extension: KotlinProjectExtension -) : IdeCompilerArgumentsResolver { +internal class IdeCompilerArgumentsResolverImpl : IdeCompilerArgumentsResolver { override fun resolveCompilerArguments(any: Any): List? { return when (any) { @@ -30,25 +24,13 @@ internal class IdeCompilerArgumentsResolverImpl( val compilerArguments = producer.createCompilerArguments( CreateCompilerArgumentsContext( isLenient = true, - includeArgumentTypes = setOfNotNull( + includeArgumentTypes = setOf( KotlinCompilerArgumentsProducer.ArgumentType.Primitive, - /* Always resolve the plugin classpath: This is still consumed by the associated IDE plugins. e.g: the kotlinx.serialisation IDE plugin relies on this classpath. */ KotlinCompilerArgumentsProducer.ArgumentType.PluginClasspath, - - /* - Dependency Classpath is required for IDE import to provide the ability to compile - the given Gradle project using 'jps'. This is only supported by the jvm Kotlin plugin - and does not work for Multiplatform or Android projects: - Therefore, we omit the classpath for multiplatform and Android projects - */ - KotlinCompilerArgumentsProducer.ArgumentType.DependencyClasspath - .takeIf { extension !is KotlinMultiplatformExtension } - .takeIf { producer is KotlinCompile } - .takeIf { !extension.project.hasAndroidPlugin } ), ) )