[Gradle, JS] A bit change of npm resolution manager registering
This commit is contained in:
committed by
Space Team
parent
5569c37ee3
commit
1997b4ff43
+26
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.gradle.targets.js.MultiplePluginDeclarationDetector
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.CompositeNodeModulesCache
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.GradleNodeModulesCache
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.UsesKotlinNpmResolutionManager
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.resolver.KotlinRootNpmResolver
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.resolver.PACKAGE_JSON_UMBRELLA_TASK_NAME
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmCachesSetup
|
||||
@@ -21,6 +22,9 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
|
||||
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
|
||||
import org.jetbrains.kotlin.gradle.tasks.CleanDataTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
import org.jetbrains.kotlin.gradle.utils.SingleActionPerProject
|
||||
import org.jetbrains.kotlin.gradle.utils.castIsolatedKotlinPluginClassLoaderAware
|
||||
import org.jetbrains.kotlin.gradle.utils.doNotTrackStateCompat
|
||||
import org.jetbrains.kotlin.gradle.utils.markResolvable
|
||||
@@ -146,6 +150,20 @@ open class NodeJsRootPlugin : Plugin<Project> {
|
||||
val Project.kotlinNodeJsExtension: NodeJsRootExtension
|
||||
get() = extensions.getByName(NodeJsRootExtension.EXTENSION_NAME).castIsolatedKotlinPluginClassLoaderAware()
|
||||
|
||||
private val Project.gradleNodeModules
|
||||
get() = GradleNodeModulesCache.registerIfAbsent(
|
||||
this,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
private val Project.compositeNodeModules
|
||||
get() = CompositeNodeModulesCache.registerIfAbsent(
|
||||
this,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
val Project.kotlinNpmResolutionManager: Provider<KotlinNpmResolutionManager>
|
||||
get() {
|
||||
val npmResolutionManager = project.gradle.sharedServices.registerIfAbsent(
|
||||
@@ -155,6 +173,14 @@ open class NodeJsRootPlugin : Plugin<Project> {
|
||||
error("Must be already registered")
|
||||
}
|
||||
|
||||
SingleActionPerProject.run(project, UsesKotlinNpmResolutionManager::class.java.name) {
|
||||
project.tasks.withType<UsesKotlinNpmResolutionManager>().configureEach { task ->
|
||||
task.usesService(npmResolutionManager)
|
||||
task.usesService(gradleNodeModules)
|
||||
task.usesService(compositeNodeModules)
|
||||
}
|
||||
}
|
||||
|
||||
return npmResolutionManager
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -48,13 +48,15 @@ open class YarnPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
val kotlinNpmResolutionManager = project.kotlinNpmResolutionManager
|
||||
|
||||
val rootPackageJson = tasks.register(RootPackageJsonTask.NAME, RootPackageJsonTask::class.java) { task ->
|
||||
task.dependsOn(nodeJsTaskProviders.npmCachesSetupTaskProvider)
|
||||
task.group = NodeJsRootPlugin.TASKS_GROUP_NAME
|
||||
task.description = "Create root package.json"
|
||||
|
||||
task.npmResolutionManager.apply {
|
||||
set(project.kotlinNpmResolutionManager)
|
||||
set(kotlinNpmResolutionManager)
|
||||
disallowChanges()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user