[Gradle] Validate compiler classpath & invoke compiler in single action

#KT-50037 Fixed
This commit is contained in:
Alexander Likhachev
2021-12-03 10:45:28 +03:00
committed by Space
parent 26994817d1
commit 59b6aefe67
2 changed files with 6 additions and 5 deletions
@@ -92,6 +92,7 @@ abstract class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), Kotl
@TaskAction
fun performDce(inputChanges: InputChanges) {
validateCompilerClasspath()
// in case of explicit `all` strategy do not perform incremental copy
val shouldPerformIncrementalCopy = isDevMode && !isExplicitDevModeAllStrategy
@@ -106,11 +106,10 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments>
internal val defaultCompilerClasspath: ConfigurableFileCollection =
project.objects.fileCollection()
init {
this.doFirst {
require(!defaultCompilerClasspath.isEmpty) {
"Default Kotlin compiler classpath is empty! Task: $path (${this::class.qualifiedName})"
}
protected fun validateCompilerClasspath() {
// Note that the check triggers configuration resolution
require(!defaultCompilerClasspath.isEmpty) {
"Default Kotlin compiler classpath is empty! Task: $path (${this::class.qualifiedName})"
}
}
}
@@ -346,6 +345,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> : AbstractKotl
}
val buildMetrics = metrics.get()
buildMetrics.measure(BuildTime.GRADLE_TASK_ACTION) {
validateCompilerClasspath()
systemPropertiesService.get().startIntercept()
CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value = "true"