KT-43818:NPM Dependencies already resolved and installed in Android Studio resolve
This commit is contained in:
committed by
Ilya Goncharov
parent
5382e68180
commit
49f2ac3545
+6
-3
@@ -80,11 +80,11 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
|
||||
private val forceFullResolve: Boolean
|
||||
get() = isInIdeaSync
|
||||
|
||||
internal val resolver = KotlinRootNpmResolver(nodeJsSettings, forceFullResolve)
|
||||
|
||||
@Volatile
|
||||
private var state: ResolutionState =
|
||||
ResolutionState.Configuring(
|
||||
KotlinRootNpmResolver(nodeJsSettings, forceFullResolve)
|
||||
)
|
||||
ResolutionState.Configuring(resolver)
|
||||
|
||||
internal sealed class ResolutionState {
|
||||
abstract val npmProjects: List<NpmProject>
|
||||
@@ -121,6 +121,9 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
|
||||
internal fun requireConfiguringState(): KotlinRootNpmResolver =
|
||||
(this.state as? ResolutionState.Configuring ?: error("NPM Dependencies already resolved and installed")).resolver
|
||||
|
||||
internal fun isConfiguringState(): Boolean =
|
||||
this.state is ResolutionState.Configuring
|
||||
|
||||
internal fun prepare() = prepareIfNeeded(requireNotPrepared = true)
|
||||
|
||||
internal fun installIfNeeded(
|
||||
|
||||
+8
-1
@@ -21,13 +21,20 @@ import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import java.io.File
|
||||
|
||||
open class KotlinPackageJsonTask : DefaultTask() {
|
||||
|
||||
init {
|
||||
onlyIf {
|
||||
nodeJs.npmResolutionManager.isConfiguringState()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var nodeJs: NodeJsRootExtension
|
||||
|
||||
@Transient
|
||||
private lateinit var compilation: KotlinJsCompilation
|
||||
|
||||
private val compilationResolver
|
||||
get() = nodeJs.npmResolutionManager.requireConfiguringState()[project][compilation]
|
||||
get() = nodeJs.npmResolutionManager.resolver[project][compilation]
|
||||
|
||||
private val producer: KotlinCompilationNpmResolver.PackageJsonProducer
|
||||
get() = compilationResolver.packageJsonProducer
|
||||
|
||||
+4
@@ -20,6 +20,10 @@ open class RootPackageJsonTask : DefaultTask() {
|
||||
outputs.upToDateWhen {
|
||||
false
|
||||
}
|
||||
|
||||
onlyIf {
|
||||
resolutionManager.isConfiguringState()
|
||||
}
|
||||
}
|
||||
|
||||
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||
|
||||
Reference in New Issue
Block a user