[Gradle, JS] Npm resolution plugins work in resolve phase too
#KT-34832 fixed
This commit is contained in:
+5
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -20,6 +20,10 @@ internal class DukatRootResolverPlugin(val resolver: KotlinRootNpmResolver) : Ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun close(resolution: KotlinRootNpmResolution) {
|
override fun close(resolution: KotlinRootNpmResolution) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resolve(resolution: KotlinRootNpmResolution) {
|
||||||
if (resolver.forceFullResolve) {
|
if (resolver.forceFullResolve) {
|
||||||
// inside idea import
|
// inside idea import
|
||||||
compilations.forEach {
|
compilations.forEach {
|
||||||
|
|||||||
+20
-1
@@ -100,13 +100,30 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Incubating
|
@Incubating
|
||||||
fun requireInstalled() = installIfNeeded(requireUpToDateReason = "")
|
internal fun requireInstalled() = installIfNeeded(requireUpToDateReason = "")
|
||||||
|
|
||||||
internal fun requireConfiguringState(): KotlinRootNpmResolver =
|
internal fun requireConfiguringState(): KotlinRootNpmResolver =
|
||||||
(this.state as? ResolutionState.Configuring ?: error("NPM Dependencies already resolved and installed")).resolver
|
(this.state as? ResolutionState.Configuring ?: error("NPM Dependencies already resolved and installed")).resolver
|
||||||
|
|
||||||
internal fun install() = installIfNeeded(requireNotInstalled = true)
|
internal fun install() = installIfNeeded(requireNotInstalled = true)
|
||||||
|
|
||||||
|
internal fun resolve(args: List<String> = emptyList()) {
|
||||||
|
val npmResolution = requireInstalled()
|
||||||
|
val npmResolutions = npmResolution
|
||||||
|
.projects
|
||||||
|
.values
|
||||||
|
|
||||||
|
nodeJsSettings.packageManager.resolveRootProject(
|
||||||
|
nodeJsSettings.rootProject,
|
||||||
|
npmResolutions.flatMap { it.npmProjects },
|
||||||
|
false,
|
||||||
|
args
|
||||||
|
)
|
||||||
|
|
||||||
|
npmResolution.plugins
|
||||||
|
.forEach { it.resolve(npmResolution) }
|
||||||
|
}
|
||||||
|
|
||||||
internal fun requireAlreadyInstalled(project: Project, reason: String = ""): KotlinProjectNpmResolution =
|
internal fun requireAlreadyInstalled(project: Project, reason: String = ""): KotlinProjectNpmResolution =
|
||||||
installIfNeeded(requireUpToDateReason = reason)[project]
|
installIfNeeded(requireUpToDateReason = reason)[project]
|
||||||
|
|
||||||
@@ -173,6 +190,8 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve()
|
||||||
|
|
||||||
return resolvedProject.npmProjectsByNpmDependency[npmDependency] ?: error("NPM project resolved without $this")
|
return resolvedProject.npmProjectsByNpmDependency[npmDependency] ?: error("NPM project resolved without $this")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,5 +10,6 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.resolver.KotlinCompilationNpmR
|
|||||||
|
|
||||||
internal interface RootResolverPlugin {
|
internal interface RootResolverPlugin {
|
||||||
fun createCompilationResolverPlugins(resolver: KotlinCompilationNpmResolver): List<CompilationResolverPlugin>
|
fun createCompilationResolverPlugins(resolver: KotlinCompilationNpmResolver): List<CompilationResolverPlugin>
|
||||||
|
fun resolve(resolution: KotlinRootNpmResolution)
|
||||||
fun close(resolution: KotlinRootNpmResolution)
|
fun close(resolution: KotlinRootNpmResolution)
|
||||||
}
|
}
|
||||||
+4
-2
@@ -6,10 +6,12 @@
|
|||||||
package org.jetbrains.kotlin.gradle.targets.js.npm.resolved
|
package org.jetbrains.kotlin.gradle.targets.js.npm.resolved
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.plugins.RootResolverPlugin
|
||||||
|
|
||||||
class KotlinRootNpmResolution(
|
internal class KotlinRootNpmResolution(
|
||||||
val rootProject: Project,
|
val rootProject: Project,
|
||||||
val projects: Map<Project, KotlinProjectNpmResolution>
|
val projects: Map<Project, KotlinProjectNpmResolution>,
|
||||||
|
val plugins: List<RootResolverPlugin>
|
||||||
) {
|
) {
|
||||||
operator fun get(project: Project) = projects[project] ?: KotlinProjectNpmResolution.empty(project)
|
operator fun get(project: Project) = projects[project] ?: KotlinProjectNpmResolution.empty(project)
|
||||||
}
|
}
|
||||||
+5
-1
@@ -117,7 +117,11 @@ internal class KotlinRootNpmResolver internal constructor(
|
|||||||
|
|
||||||
upToDateChecks.forEach { it.commit() }
|
upToDateChecks.forEach { it.commit() }
|
||||||
|
|
||||||
return KotlinRootNpmResolution(rootProject, projectResolutions)
|
return KotlinRootNpmResolution(
|
||||||
|
rootProject,
|
||||||
|
projectResolutions,
|
||||||
|
plugins
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun closePlugins(resolution: KotlinRootNpmResolution) {
|
internal fun closePlugins(resolution: KotlinRootNpmResolution) {
|
||||||
|
|||||||
+1
-9
@@ -45,15 +45,7 @@ open class KotlinNpmInstallTask : DefaultTask() {
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun resolve() {
|
fun resolve() {
|
||||||
val npmResolutions = resolutionManager.requireInstalled()
|
resolutionManager.resolve(args)
|
||||||
.projects
|
|
||||||
.values
|
|
||||||
nodeJs.packageManager.resolveRootProject(
|
|
||||||
project,
|
|
||||||
npmResolutions.flatMap { it.npmProjects },
|
|
||||||
false,
|
|
||||||
args
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
Reference in New Issue
Block a user