[Gradle, JS] Fix K/JS project build with configuration cache (part 2)

It is still does not support configuration cache but these changes allows build to pass with warnings
#KT-42494 Fixed
This commit is contained in:
Alexander.Likhachev
2020-10-15 18:37:01 +03:00
parent d7db643422
commit d6e0d2a55b
7 changed files with 10 additions and 12 deletions
@@ -19,7 +19,6 @@ abstract class DukatTask(
override val compilation: KotlinJsCompilation override val compilation: KotlinJsCompilation
) : DefaultTask(), RequiresNpmDependencies { ) : DefaultTask(), RequiresNpmDependencies {
@get:Internal @get:Internal
@Transient
protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject) protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
@get:Internal @get:Internal
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.Yarn
import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore
import java.io.File import java.io.File
open class NodeJsRootExtension(val rootProject: Project) : ConfigurationPhaseAware<NodeJsEnv>() { open class NodeJsRootExtension(@Transient val rootProject: Project) : ConfigurationPhaseAware<NodeJsEnv>() {
init { init {
check(rootProject.rootProject == rootProject) check(rootProject.rootProject == rootProject)
} }
@@ -41,6 +41,7 @@ open class NodeJsRootExtension(val rootProject: Project) : ConfigurationPhaseAwa
var packageManager: NpmApi by Property(Yarn()) var packageManager: NpmApi by Property(Yarn())
@Transient
private val projectProperties = PropertiesProvider(rootProject) private val projectProperties = PropertiesProvider(rootProject)
inner class Experimental { inner class Experimental {
@@ -50,6 +51,7 @@ open class NodeJsRootExtension(val rootProject: Project) : ConfigurationPhaseAwa
val experimental = Experimental() val experimental = Experimental()
@Transient
val taskRequirements = TasksRequirements() val taskRequirements = TasksRequirements()
val nodeJsSetupTaskProvider: TaskProvider<out NodeJsSetupTask> val nodeJsSetupTaskProvider: TaskProvider<out NodeJsSetupTask>
@@ -117,6 +119,8 @@ open class NodeJsRootExtension(val rootProject: Project) : ConfigurationPhaseAwa
} }
val versions = NpmVersions() val versions = NpmVersions()
@Transient
internal val npmResolutionManager = KotlinNpmResolutionManager(this) internal val npmResolutionManager = KotlinNpmResolutionManager(this)
companion object { companion object {
@@ -23,9 +23,8 @@ constructor(
@Transient @Transient
private val compilation: KotlinJsCompilation private val compilation: KotlinJsCompilation
) : DefaultTask() { ) : DefaultTask() {
@Transient
private val npmProject = compilation.npmProject private val npmProject = compilation.npmProject
private val nodeJs = npmProject.nodeJs private val nodeJs = npmProject.nodeJs
private val compilationResolution private val compilationResolution
@@ -24,7 +24,6 @@ open class KotlinNpmInstallTask : DefaultTask() {
} }
} }
@Transient
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
private val resolutionManager get() = nodeJs.npmResolutionManager private val resolutionManager get() = nodeJs.npmResolutionManager
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.gradle.tasks.registerTask
import java.io.File import java.io.File
open class KotlinPackageJsonTask : DefaultTask() { open class KotlinPackageJsonTask : DefaultTask() {
@Transient
private lateinit var nodeJs: NodeJsRootExtension private lateinit var nodeJs: NodeJsRootExtension
@Transient @Transient
@@ -21,7 +21,6 @@ open class RootPackageJsonTask : DefaultTask() {
} }
} }
@Transient
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
private val resolutionManager get() = nodeJs.npmResolutionManager private val resolutionManager get() = nodeJs.npmResolutionManager
@@ -38,7 +38,6 @@ constructor(
@Transient @Transient
override val compilation: KotlinJsCompilation override val compilation: KotlinJsCompilation
) : DefaultTask(), RequiresNpmDependencies { ) : DefaultTask(), RequiresNpmDependencies {
@Transient
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
private val versions = nodeJs.versions private val versions = nodeJs.versions
@@ -215,6 +214,8 @@ constructor(
override val requiredNpmDependencies: Set<RequiredKotlinJsDependency> override val requiredNpmDependencies: Set<RequiredKotlinJsDependency>
@Internal get() = createRunner().config.getRequiredDependencies(versions) @Internal get() = createRunner().config.getRequiredDependencies(versions)
private val isContinuous = project.gradle.startParameter.isContinuous
@TaskAction @TaskAction
fun doExecute() { fun doExecute() {
nodeJs.npmResolutionManager.checkRequiredDependencies(this) nodeJs.npmResolutionManager.checkRequiredDependencies(this)
@@ -226,13 +227,11 @@ constructor(
return return
} }
if (project.gradle.startParameter.isContinuous) { if (isContinuous) {
val continuousRunner = runner
val deploymentRegistry = services.get(DeploymentRegistry::class.java) val deploymentRegistry = services.get(DeploymentRegistry::class.java)
val deploymentHandle = deploymentRegistry.get("webpack", Handle::class.java) val deploymentHandle = deploymentRegistry.get("webpack", Handle::class.java)
if (deploymentHandle == null) { if (deploymentHandle == null) {
deploymentRegistry.start("webpack", DeploymentRegistry.ChangeBehavior.BLOCK, Handle::class.java, continuousRunner) deploymentRegistry.start("webpack", DeploymentRegistry.ChangeBehavior.BLOCK, Handle::class.java, runner)
} }
} else { } else {
runner.copy( runner.copy(