[Gradle, JS] Rename Installed on prepared

#KT-34832 fixed
This commit is contained in:
Ilya Goncharov
2020-04-16 17:03:52 +03:00
parent 578a33767b
commit 9174e184d3
@@ -47,7 +47,9 @@ import java.io.File
* by compilation that depends on this compilation. Note that package.json will be executed only for * by compilation that depends on this compilation. Note that package.json will be executed only for
* required compilations, while other may be missed. * required compilations, while other may be missed.
* *
* **installed**. Global final state. Initiated by executing global `kotlinNpmInstall` task. * **installed**. Global final state. Initiated by executing global `rootPackageJson` task.
*
* **resolved**.
* All created package.json files will be gathered and package manager will be executed. * All created package.json files will be gathered and package manager will be executed.
* Package manager will create lock file, that will be parsed for transitive npm dependencies * Package manager will create lock file, that will be parsed for transitive npm dependencies
* that will be added to the root [NpmDependency] objects. `kotlinNpmInstall` task may be up-to-date. * that will be added to the root [NpmDependency] objects. `kotlinNpmInstall` task may be up-to-date.
@@ -92,7 +94,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
} }
class Installed(val resolved: KotlinRootNpmResolution) : ResolutionState() { class Prepared(val resolved: KotlinRootNpmResolution) : ResolutionState() {
override val npmProjects: List<NpmProject> override val npmProjects: List<NpmProject>
get() = resolved.projects.values.flatMap { it.npmProjects.map { it.npmProject } } get() = resolved.projects.values.flatMap { it.npmProjects.map { it.npmProject } }
@@ -146,12 +148,12 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
val state0 = this.state val state0 = this.state
return when (state0) { return when (state0) {
is ResolutionState.Installed -> alreadyResolved(state0.resolved) is ResolutionState.Prepared -> alreadyResolved(state0.resolved)
is ResolutionState.Configuring -> { is ResolutionState.Configuring -> {
synchronized(this) { synchronized(this) {
val state1 = this.state val state1 = this.state
when (state1) { when (state1) {
is ResolutionState.Installed -> alreadyResolved(state1.resolved) is ResolutionState.Prepared -> alreadyResolved(state1.resolved)
is ResolutionState.Configuring -> { is ResolutionState.Configuring -> {
val upToDate = nodeJsSettings.npmInstallTask.state.upToDate val upToDate = nodeJsSettings.npmInstallTask.state.upToDate
if (requireUpToDateReason != null && !upToDate) { if (requireUpToDateReason != null && !upToDate) {
@@ -160,7 +162,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
val forceUpToDate = upToDate && !forceFullResolve val forceUpToDate = upToDate && !forceFullResolve
state1.resolver.close(forceUpToDate).also { state1.resolver.close(forceUpToDate).also {
this.state = ResolutionState.Installed(it) this.state = ResolutionState.Prepared(it)
state1.resolver.closePlugins(it) state1.resolver.closePlugins(it)
} }
} }
@@ -182,7 +184,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
// requires resolve to build package.json, in this case we should just skip this call) // requires resolve to build package.json, in this case we should just skip this call)
val state0 = state val state0 = state
when (state0) { when (state0) {
is ResolutionState.Installed -> state0.resolved[project] is ResolutionState.Prepared -> state0.resolved[project]
is ResolutionState.Configuring -> { is ResolutionState.Configuring -> {
return null return null
//error("Cannot use NpmDependency before :kotlinNpmInstall task execution") //error("Cannot use NpmDependency before :kotlinNpmInstall task execution")