[Gradle] Ensure pluginClasspath is imported into the IDE
See `[KTIJ-24976] Implement initial KotlinMppCompilerPluginImportingTests` in intellij.git KTIJ-24976
This commit is contained in:
committed by
Space Team
parent
6c2087983c
commit
777955b4e2
+2
-1
@@ -83,5 +83,6 @@ interface CompilerArgumentAware<T : CommonToolArguments> : KotlinCompilerArgumen
|
|||||||
|
|
||||||
private val includedArgumentTypes = setOf(
|
private val includedArgumentTypes = setOf(
|
||||||
ArgumentType.Primitive,
|
ArgumentType.Primitive,
|
||||||
ArgumentType.Classpath,
|
ArgumentType.PluginClasspath,
|
||||||
|
ArgumentType.DependencyClasspath,
|
||||||
)
|
)
|
||||||
+3
-2
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsDefault
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsDefault
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsHelper
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsHelper
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
||||||
import org.jetbrains.kotlin.gradle.report.BuildReportMode
|
import org.jetbrains.kotlin.gradle.report.BuildReportMode
|
||||||
@@ -126,13 +125,15 @@ abstract class KaptGenerateStubsTask @Inject constructor(
|
|||||||
args.destinationAsFile = destinationDirectory.get().asFile
|
args.destinationAsFile = destinationDirectory.get().asFile
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath { args ->
|
pluginClasspath { args ->
|
||||||
args.pluginClasspaths = runSafe {
|
args.pluginClasspaths = runSafe {
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
||||||
).reduce(FileCollection::plus).toPathsArray()
|
).reduce(FileCollection::plus).toPathsArray()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyClasspath { args ->
|
||||||
args.classpathAsList = runSafe { libraries.toList().filter { it.exists() } }.orEmpty()
|
args.classpathAsList = runSafe { libraries.toList().filter { it.exists() } }.orEmpty()
|
||||||
args.friendPaths = friendPaths.toPathsArray()
|
args.friendPaths = friendPaths.toPathsArray()
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-4
@@ -16,7 +16,8 @@ interface KotlinCompilerArgumentsProducer {
|
|||||||
|
|
||||||
enum class ArgumentType {
|
enum class ArgumentType {
|
||||||
Primitive,
|
Primitive,
|
||||||
Classpath,
|
PluginClasspath,
|
||||||
|
DependencyClasspath,
|
||||||
Sources;
|
Sources;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -40,7 +41,8 @@ interface KotlinCompilerArgumentsProducer {
|
|||||||
interface ContributeCompilerArgumentsContext<T : CommonToolArguments> {
|
interface ContributeCompilerArgumentsContext<T : CommonToolArguments> {
|
||||||
fun <T> runSafe(action: () -> T): T?
|
fun <T> runSafe(action: () -> T): T?
|
||||||
fun primitive(contribution: (args: T) -> Unit)
|
fun primitive(contribution: (args: T) -> Unit)
|
||||||
fun classpath(contribution: (args: T) -> Unit)
|
fun pluginClasspath(contribution: (args: T) -> Unit)
|
||||||
|
fun dependencyClasspath(contribution: (args: T) -> Unit)
|
||||||
fun sources(contribution: (args: T) -> Unit)
|
fun sources(contribution: (args: T) -> Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +101,14 @@ private class CreateCompilerArgumentsContextImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun classpath(contribution: (args: T) -> Unit) {
|
override fun pluginClasspath(contribution: (args: T) -> Unit) {
|
||||||
if (KotlinCompilerArgumentsProducer.ArgumentType.Classpath in includedArgumentTypes) {
|
if (KotlinCompilerArgumentsProducer.ArgumentType.PluginClasspath in includedArgumentTypes) {
|
||||||
|
applyContribution(contribution)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dependencyClasspath(contribution: (args: T) -> Unit) {
|
||||||
|
if (KotlinCompilerArgumentsProducer.ArgumentType.DependencyClasspath in includedArgumentTypes) {
|
||||||
applyContribution(contribution)
|
applyContribution(contribution)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -32,7 +32,8 @@ internal class IdeCompilerArgumentsResolverImpl(
|
|||||||
isLenient = true,
|
isLenient = true,
|
||||||
includeArgumentTypes = setOfNotNull(
|
includeArgumentTypes = setOfNotNull(
|
||||||
KotlinCompilerArgumentsProducer.ArgumentType.Primitive,
|
KotlinCompilerArgumentsProducer.ArgumentType.Primitive,
|
||||||
KotlinCompilerArgumentsProducer.ArgumentType.Classpath
|
KotlinCompilerArgumentsProducer.ArgumentType.PluginClasspath,
|
||||||
|
KotlinCompilerArgumentsProducer.ArgumentType.DependencyClasspath
|
||||||
.takeIf { extension !is KotlinMultiplatformExtension }
|
.takeIf { extension !is KotlinMultiplatformExtension }
|
||||||
.takeIf { producer is KotlinCompile }
|
.takeIf { producer is KotlinCompile }
|
||||||
.takeIf { !extension.project.hasAndroidPlugin }
|
.takeIf { !extension.project.hasAndroidPlugin }
|
||||||
|
|||||||
+4
-2
@@ -20,7 +20,6 @@ import org.gradle.process.ExecOperations
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.*
|
import org.jetbrains.kotlin.compilerRunner.*
|
||||||
import org.jetbrains.kotlin.gradle.dsl.*
|
import org.jetbrains.kotlin.gradle.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||||
@@ -226,8 +225,11 @@ constructor(
|
|||||||
KotlinCommonCompilerToolOptionsHelper.fillCompilerArguments(toolOptions, args)
|
KotlinCommonCompilerToolOptionsHelper.fillCompilerArguments(toolOptions, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath { args ->
|
pluginClasspath { args ->
|
||||||
args.pluginClasspaths = compilerPlugins.flatMap { classpath -> runSafe { classpath.files } ?: emptySet() }.toPathsArray()
|
args.pluginClasspaths = compilerPlugins.flatMap { classpath -> runSafe { classpath.files } ?: emptySet() }.toPathsArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyClasspath { args ->
|
||||||
args.libraries = runSafe { libraries.files.filterKlibsPassedToCompiler() }?.toPathsArray()
|
args.libraries = runSafe { libraries.files.filterKlibsPassedToCompiler() }?.toPathsArray()
|
||||||
args.exportedLibraries = runSafe { exportLibraries.files.filterKlibsPassedToCompiler() }?.toPathsArray()
|
args.exportedLibraries = runSafe { exportLibraries.files.filterKlibsPassedToCompiler() }?.toPathsArray()
|
||||||
args.friendModules = runSafe { friendModule.files.toList().takeIf { it.isNotEmpty() } }
|
args.friendModules = runSafe { friendModule.files.toList().takeIf { it.isNotEmpty() } }
|
||||||
|
|||||||
+3
-2
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
|
|||||||
import org.jetbrains.kotlin.gradle.internal.isInIdeaSync
|
import org.jetbrains.kotlin.gradle.internal.isInIdeaSync
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationInfo
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationInfo
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
||||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
||||||
@@ -454,9 +453,11 @@ internal constructor(
|
|||||||
KotlinNativeCompilerOptionsHelper.fillCompilerArguments(compilerOptions, args)
|
KotlinNativeCompilerOptionsHelper.fillCompilerArguments(compilerOptions, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath { args ->
|
pluginClasspath { args ->
|
||||||
args.pluginClasspaths = compilerPlugins.flatMap { classpath -> runSafe { classpath.files } ?: emptySet() }.toPathsArray()
|
args.pluginClasspaths = compilerPlugins.flatMap { classpath -> runSafe { classpath.files } ?: emptySet() }.toPathsArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyClasspath { args ->
|
||||||
args.libraries = runSafe { libraries.files.filterKlibsPassedToCompiler().toPathsArray() }
|
args.libraries = runSafe { libraries.files.filterKlibsPassedToCompiler().toPathsArray() }
|
||||||
args.friendModules = runSafe {
|
args.friendModules = runSafe {
|
||||||
friendModule.files.takeIf { it.isNotEmpty() }?.map { it.absolutePath }?.joinToString(File.pathSeparator)
|
friendModule.files.takeIf { it.isNotEmpty() }?.map { it.absolutePath }?.joinToString(File.pathSeparator)
|
||||||
|
|||||||
+3
-1
@@ -167,13 +167,15 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
args.freeArgs = executionTimeFreeCompilerArgs ?: enhancedFreeCompilerArgs.get()
|
args.freeArgs = executionTimeFreeCompilerArgs ?: enhancedFreeCompilerArgs.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath { args ->
|
pluginClasspath { args ->
|
||||||
args.pluginClasspaths = runSafe {
|
args.pluginClasspaths = runSafe {
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
||||||
).reduce(FileCollection::plus).toPathsArray()
|
).reduce(FileCollection::plus).toPathsArray()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyClasspath { args ->
|
||||||
args.friendModules = friendDependencies.files.joinToString(File.pathSeparator) { it.absolutePath }
|
args.friendModules = friendDependencies.files.joinToString(File.pathSeparator) { it.absolutePath }
|
||||||
|
|
||||||
args.libraries = runSafe {
|
args.libraries = runSafe {
|
||||||
|
|||||||
+3
-1
@@ -245,13 +245,15 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath { args ->
|
pluginClasspath { args ->
|
||||||
args.pluginClasspaths = runSafe {
|
args.pluginClasspaths = runSafe {
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
||||||
).reduce(FileCollection::plus).toPathsArray()
|
).reduce(FileCollection::plus).toPathsArray()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyClasspath { args ->
|
||||||
args.friendPaths = friendPaths.toPathsArray()
|
args.friendPaths = friendPaths.toPathsArray()
|
||||||
args.classpathAsList = runSafe {
|
args.classpathAsList = runSafe {
|
||||||
libraries.toList().filter { it.exists() }
|
libraries.toList().filter { it.exists() }
|
||||||
|
|||||||
+4
-3
@@ -23,7 +23,6 @@ import org.gradle.api.tasks.*
|
|||||||
import org.gradle.work.InputChanges
|
import org.gradle.work.InputChanges
|
||||||
import org.gradle.work.NormalizeLineEndings
|
import org.gradle.work.NormalizeLineEndings
|
||||||
import org.gradle.workers.WorkerExecutor
|
import org.gradle.workers.WorkerExecutor
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
||||||
@@ -31,7 +30,6 @@ import org.jetbrains.kotlin.gradle.dsl.*
|
|||||||
import org.jetbrains.kotlin.gradle.internal.tasks.allOutputFiles
|
import org.jetbrains.kotlin.gradle.internal.tasks.allOutputFiles
|
||||||
import org.jetbrains.kotlin.gradle.logging.GradleErrorMessageCollector
|
import org.jetbrains.kotlin.gradle.logging.GradleErrorMessageCollector
|
||||||
import org.jetbrains.kotlin.gradle.logging.GradlePrintingMessageCollector
|
import org.jetbrains.kotlin.gradle.logging.GradlePrintingMessageCollector
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.create
|
||||||
import org.jetbrains.kotlin.gradle.report.BuildReportMode
|
import org.jetbrains.kotlin.gradle.report.BuildReportMode
|
||||||
@@ -93,12 +91,15 @@ abstract class KotlinCompileCommon @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
classpath { args ->
|
pluginClasspath { args ->
|
||||||
args.pluginClasspaths = runSafe {
|
args.pluginClasspaths = runSafe {
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
pluginClasspath, kotlinPluginData?.orNull?.classpath
|
||||||
).reduce(FileCollection::plus).toPathsArray()
|
).reduce(FileCollection::plus).toPathsArray()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyClasspath { args ->
|
||||||
args.classpath = runSafe { libraries.files.filter { it.exists() }.joinToString(File.pathSeparator) }
|
args.classpath = runSafe { libraries.files.filter { it.exists() }.joinToString(File.pathSeparator) }
|
||||||
args.friendPaths = runSafe { this@KotlinCompileCommon.friendPaths.files.toPathsArray() }
|
args.friendPaths = runSafe { this@KotlinCompileCommon.friendPaths.files.toPathsArray() }
|
||||||
args.refinesPaths = refinesMetadataPaths.toPathsArray()
|
args.refinesPaths = refinesMetadataPaths.toPathsArray()
|
||||||
|
|||||||
Reference in New Issue
Block a user