[Gradle, JS] Fix K/JS project build with configuration cache enabled
KT-42494 Fixed
This commit is contained in:
+3
@@ -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)
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ constructor(
|
||||
override val destinationDir: File
|
||||
get() = compilation.npmProject.externalsDir
|
||||
|
||||
@delegate:Transient
|
||||
private val executor by lazy {
|
||||
DukatExecutor(
|
||||
nodeJs,
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+3
@@ -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
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+2
@@ -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
|
||||
|
||||
|
||||
+4
-1
@@ -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 }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user