diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt index 880c079e46d..0f98c065aaf 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt @@ -16,7 +16,6 @@ import org.gradle.workers.WorkQueue import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.BuildTime import org.jetbrains.kotlin.build.report.metrics.measure -import org.jetbrains.kotlin.cli.common.CompilerSystemProperties import org.jetbrains.kotlin.cli.common.arguments.* import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.daemon.client.CompileServiceSession @@ -32,8 +31,7 @@ import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService import org.jetbrains.kotlin.gradle.tasks.* -import org.jetbrains.kotlin.gradle.tasks.InspectClassesForMultiModuleIC -import org.jetbrains.kotlin.gradle.tasks.TaskOutputsBackup +import org.jetbrains.kotlin.gradle.utils.IsolatedKotlinClasspathClassCastException import org.jetbrains.kotlin.gradle.utils.archivePathCompatible import org.jetbrains.kotlin.gradle.utils.newTmpFile import org.jetbrains.kotlin.gradle.utils.relativeOrCanonical @@ -273,8 +271,19 @@ internal open class GradleCompilerRunner( gradle.taskGraph.allTasks.forEach { task -> val project = task.project - // TODO REVIEW: Should this fail or be lenient on isolated classpaths (and therefore failing cast)? - if (project.multiplatformExtensionOrNull != null) { + + /* + Ignoring isolated classpath: + An inaccessible project is not a fatal issue here. Missing information will "only" lead to non-incremental + compilation. We expect the user to be warned about this misconfiguration during configuration phase. + */ + val multiplatformExtension = try { + project.multiplatformExtensionOrNull + } catch (e: IsolatedKotlinClasspathClassCastException) { + null + } + + if (multiplatformExtension != null) { // Just record this, we'll process them later val tasksInProject = multiplatformProjectTasks[project] ?: mutableSetOf() tasksInProject.add(task.name)