[Gradle] Release daemon compile session at a compilation task's finish

Before this change, some long-running tasks like `run` might cause the Kotlin daemon to go into the LastSession state and stay in that state until the long-running tasks and therefore the Gradle build are finished.
The reason for that behaviour is that if we don't release sessions explicitly, the created "session is alive" marker files are cleaned up by `KotlinGradleFinishBuildHandler.buildFinished` at the end of the build.
^KT-55322 In Progress
This commit is contained in:
Alexander.Likhachev
2023-11-21 10:02:41 +01:00
committed by Space Team
parent 8ceee3e8b9
commit 3ccca58bb0
@@ -250,10 +250,11 @@ internal class GradleKotlinCompilerWork @Inject constructor(
// TODO: implement a proper logic to avoid remote calls in such cases
try {
metrics.measure(GradleBuildTime.CLEAR_JAR_CACHE) {
daemon.clearJarCache()
// releasing compile session implies clearing the jar cache
daemon.releaseCompileSession(sessionId)
}
} catch (e: RemoteException) {
log.warn("Unable to clear jar cache after compilation, maybe daemon is already down: $e")
log.warn("Unable to release compile session, maybe daemon is already down: $e")
}
}
log.logFinish(KotlinCompilerExecutionStrategy.DAEMON)