Gradle, JS, compilation resolver: close dependent compilation resolver when it's packageJson task is up-to-date
This commit is contained in:
+12
-6
@@ -55,17 +55,21 @@ internal class KotlinCompilationNpmResolver(
|
|||||||
private var resolution: KotlinCompilationNpmResolution? = null
|
private var resolution: KotlinCompilationNpmResolution? = null
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun resolve() {
|
fun resolve(skipWriting: Boolean = false): KotlinCompilationNpmResolution {
|
||||||
check(!closed) { "$this already closed" }
|
check(!closed) { "$this already closed" }
|
||||||
check(resolution == null) { "$this already resolved" }
|
check(resolution == null) { "$this already resolved" }
|
||||||
|
|
||||||
resolution = packageJsonProducer.createPackageJson()
|
return packageJsonProducer.createPackageJson(skipWriting).also {
|
||||||
|
resolution = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun getResolutionOrResolveIfForced(): KotlinCompilationNpmResolution? {
|
fun getResolutionOrResolveIfForced(): KotlinCompilationNpmResolution? {
|
||||||
if (resolver.forceFullResolve && resolution == null) resolve()
|
if (resolution != null) return resolution
|
||||||
return resolution
|
if (packageJsonTaskHolder.doGetTask().state.upToDate) return resolve(skipWriting = true)
|
||||||
|
if (resolver.forceFullResolve && resolution == null) return resolve()
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -203,7 +207,7 @@ internal class KotlinCompilationNpmResolver(
|
|||||||
externalNpmDependencies.map { "${it.key}:${it.version}" }
|
externalNpmDependencies.map { "${it.key}:${it.version}" }
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createPackageJson(): KotlinCompilationNpmResolution {
|
fun createPackageJson(skipWriting: Boolean): KotlinCompilationNpmResolution {
|
||||||
val resolvedInternalDependencies = internalDependencies.map {
|
val resolvedInternalDependencies = internalDependencies.map {
|
||||||
it.getResolutionOrResolveIfForced()
|
it.getResolutionOrResolveIfForced()
|
||||||
?: error("Unresolved dependent npm package: ${this@KotlinCompilationNpmResolver} -> $it")
|
?: error("Unresolved dependent npm package: ${this@KotlinCompilationNpmResolver} -> $it")
|
||||||
@@ -235,7 +239,9 @@ internal class KotlinCompilationNpmResolver(
|
|||||||
it(packageJson)
|
it(packageJson)
|
||||||
}
|
}
|
||||||
|
|
||||||
packageJson.saveTo(npmProject.packageJsonFile)
|
if (!skipWriting) {
|
||||||
|
packageJson.saveTo(npmProject.packageJsonFile)
|
||||||
|
}
|
||||||
|
|
||||||
return KotlinCompilationNpmResolution(
|
return KotlinCompilationNpmResolution(
|
||||||
project,
|
project,
|
||||||
|
|||||||
Reference in New Issue
Block a user