Kotlin Gradle Plugin - clean caches for in-process compilation
This is to prevent file handle leaks on Windows. This commit disposes KotlinCoreEnvironment used during in-process compilation. ^KT-49772 Fixed
This commit is contained in:
committed by
Yahor Berdnikau
parent
7f3b546288
commit
684273783f
@@ -573,6 +573,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
/**
|
/**
|
||||||
* This method is also used in Gradle after configuration phase finished.
|
* This method is also used in Gradle after configuration phase finished.
|
||||||
*/
|
*/
|
||||||
|
@JvmStatic
|
||||||
fun disposeApplicationEnvironment() {
|
fun disposeApplicationEnvironment() {
|
||||||
synchronized(APPLICATION_LOCK) {
|
synchronized(APPLICATION_LOCK) {
|
||||||
val environment = ourApplicationEnvironment ?: return
|
val environment = ourApplicationEnvironment ?: return
|
||||||
|
|||||||
+9
@@ -366,6 +366,15 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
stream,
|
stream,
|
||||||
exitCode
|
exitCode
|
||||||
)
|
)
|
||||||
|
try {
|
||||||
|
metrics.measure(BuildTime.CLEAR_JAR_CACHE) {
|
||||||
|
val coreEnvironment = Class.forName("org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment", true, classLoader)
|
||||||
|
val dispose = coreEnvironment.getMethod("disposeApplicationEnvironment")
|
||||||
|
dispose.invoke(null)
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
log.warn("Unable to clear jar cache after in-process compilation: $e")
|
||||||
|
}
|
||||||
log.logFinish(KotlinCompilerExecutionStrategy.IN_PROCESS)
|
log.logFinish(KotlinCompilerExecutionStrategy.IN_PROCESS)
|
||||||
return exitCode
|
return exitCode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user