[Gradle, JS] Fix K/JS project build with configuration cache enabled

KT-42494 Fixed
This commit is contained in:
Alexander.Likhachev
2020-10-13 15:55:42 +03:00
parent 82a66bc659
commit d3f98923dc
8 changed files with 18 additions and 4 deletions
@@ -15,9 +15,11 @@ import java.io.File
abstract class DukatTask(
@Internal
@Transient
override val compilation: KotlinJsCompilation
) : DefaultTask(), RequiresNpmDependencies {
@get:Internal
@Transient
protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
@get:Internal
@@ -35,6 +37,7 @@ abstract class DukatTask(
var externalsOutputFormat: ExternalsOutputFormat = ExternalsOutputFormat.SOURCE
@get:Internal
@delegate:Transient
val dts by lazy {
val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled()[project][compilation]
val dtsResolver = DtsResolver(resolvedCompilation.npmProject)
@@ -24,6 +24,7 @@ constructor(
override val destinationDir: File
get() = compilation.npmProject.externalsDir
@delegate:Transient
private val executor by lazy {
DukatExecutor(
nodeJs,
@@ -11,7 +11,6 @@ import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
import org.jetbrains.kotlin.gradle.targets.js.ir.GENERATE_D_TS
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject.Companion.PACKAGE_JSON
import org.jetbrains.kotlin.gradle.utils.property
@@ -21,6 +20,7 @@ import javax.inject.Inject
open class PublicPackageJsonTask
@Inject
constructor(
@Transient
private val compilation: KotlinJsCompilation
) : DefaultTask() {
@@ -24,7 +24,8 @@ open class KotlinNpmInstallTask : DefaultTask() {
}
}
private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject)
@Transient
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
private val resolutionManager get() = nodeJs.npmResolutionManager
@Input
@@ -21,7 +21,10 @@ import org.jetbrains.kotlin.gradle.tasks.registerTask
import java.io.File
open class KotlinPackageJsonTask : DefaultTask() {
@Transient
private lateinit var nodeJs: NodeJsRootExtension
@Transient
private lateinit var compilation: KotlinJsCompilation
private val compilationResolver
@@ -21,7 +21,8 @@ open class RootPackageJsonTask : DefaultTask() {
}
}
private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject)
@Transient
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
private val resolutionManager get() = nodeJs.npmResolutionManager
@get:OutputFile
@@ -35,8 +35,10 @@ open class KotlinWebpack
@Inject
constructor(
@Internal
@Transient
override val compilation: KotlinJsCompilation
) : DefaultTask(), RequiresNpmDependencies {
@Transient
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
private val versions = nodeJs.versions
@@ -40,6 +40,9 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
cacheOnlyIfEnabledForKotlin()
}
@get:Internal
internal val objects = project.objects
override fun localStateDirectories(): FileCollection = project.files()
override fun createCompilerArgs(): K2JSDceArguments = K2JSDceArguments()
@@ -72,7 +75,7 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
fun performDce() {
val inputFiles = (listOf(source) + classpath
.filter { !kotlinFilesOnly || isDceCandidate(it) }
.map { project.fileTree(it) })
.map { objects.fileCollection().from(it).asFileTree })
.reduce(FileTree::plus)
.files.map { it.path }