[Gradle] Don't collect module-info on using new IC/JVM approach

Collecting 'moduleInfo' is required for the old history-file-based
incremental compilation approach. And the way how it is being collected
violates Gradle project-isolation feature as it accesses all Kotlin
compile tasks from other Gradle subprojects.

When the new IC based on classpath snapshot is enabled, the plugin will
not collect 'moduleInfo' making it compatible with project isolation.

^KT-59826 Fixed
This commit is contained in:
Yahor Berdnikau
2023-08-22 11:54:24 +02:00
committed by Space Team
parent 40928d50a2
commit e80988d98c
9 changed files with 52 additions and 27 deletions
@@ -616,20 +616,24 @@ abstract class CompileServiceImplBase(
val rootProjectDir = incrementalCompilationOptions.rootProjectDir
val buildDir = incrementalCompilationOptions.buildDir
val modulesApiHistory = incrementalCompilationOptions.multiModuleICSettings?.run {
reporter.info { "Use module detection: $useModuleDetection" }
val modulesInfo = incrementalCompilationOptions.modulesInfo
?: error("The build is configured to use the history-file based IC approach, but doesn't provide the modulesInfo")
check(rootProjectDir != null) {
"rootProjectDir is expected to be non null when the history-file based IC approach is used"
}
val modulesApiHistory = if (incrementalCompilationOptions.classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled) {
EmptyModulesApiHistory
} else {
incrementalCompilationOptions.multiModuleICSettings?.run {
reporter.info { "Use module detection: $useModuleDetection" }
val modulesInfo = incrementalCompilationOptions.modulesInfo
?: error("The build is configured to use the history-file based IC approach, but doesn't provide the modulesInfo")
check(rootProjectDir != null) {
"rootProjectDir is expected to be non null when the history-file based IC approach is used"
}
if (!useModuleDetection) {
ModulesApiHistoryJvm(rootProjectDir, modulesInfo)
} else {
ModulesApiHistoryAndroid(rootProjectDir, modulesInfo)
}
} ?: EmptyModulesApiHistory
if (!useModuleDetection) {
ModulesApiHistoryJvm(rootProjectDir, modulesInfo)
} else {
ModulesApiHistoryAndroid(rootProjectDir, modulesInfo)
}
} ?: EmptyModulesApiHistory
}
val useK2 = k2jvmArgs.useK2 || LanguageVersion.fromVersionString(k2jvmArgs.languageVersion)?.usesK2 == true
// TODO: This should be reverted after implementing of fir-based java tracker (KT-57147).