@@ -15,6 +15,7 @@ import com.github.gradle.node.yarn.task.YarnSetupTask
15
15
import com.github.gradle.node.yarn.task.YarnTask
16
16
import org.gradle.api.Plugin
17
17
import org.gradle.api.Project
18
+ import org.gradle.api.provider.Property
18
19
import org.gradle.kotlin.dsl.create
19
20
import org.gradle.kotlin.dsl.named
20
21
import org.gradle.kotlin.dsl.register
@@ -30,9 +31,9 @@ class NodePlugin : Plugin<Project> {
30
31
project.extensions.create<PackageJsonExtension >(PackageJsonExtension .NAME , project)
31
32
addGlobalTypes()
32
33
addTasks()
33
- addNpmRule()
34
- addPnpmRule()
35
- addYarnRule()
34
+ addNpmRule(nodeExtension.enableTaskRules )
35
+ addPnpmRule(nodeExtension.enableTaskRules )
36
+ addYarnRule(nodeExtension.enableTaskRules )
36
37
project.afterEvaluate {
37
38
if (nodeExtension.download.get()) {
38
39
nodeExtension.distBaseUrl.orNull?.let { addRepository(it, nodeExtension.allowInsecureProtocol.orNull) }
@@ -64,10 +65,10 @@ class NodePlugin : Plugin<Project> {
64
65
project.tasks.register<YarnSetupTask >(YarnSetupTask .NAME )
65
66
}
66
67
67
- private fun addNpmRule () { // note this rule also makes it possible to specify e.g. "dependsOn npm_install"
68
+ private fun addNpmRule (enableTaskRules : Property < Boolean > ) { // note this rule also makes it possible to specify e.g. "dependsOn npm_install"
68
69
project.tasks.addRule(" Pattern: \" npm_<command>\" : Executes an NPM command." ) {
69
70
val taskName = this
70
- if (taskName.startsWith(" npm_" )) {
71
+ if (taskName.startsWith(" npm_" ) && enableTaskRules.get() ) {
71
72
project.tasks.create<NpmTask >(taskName) {
72
73
val tokens = taskName.split(" _" ).drop(1 ) // all except first
73
74
npmCommand.set(tokens)
@@ -79,10 +80,10 @@ class NodePlugin : Plugin<Project> {
79
80
}
80
81
}
81
82
82
- private fun addPnpmRule () { // note this rule also makes it possible to specify e.g. "dependsOn npm_install"
83
+ private fun addPnpmRule (enableTaskRules : Property < Boolean > ) { // note this rule also makes it possible to specify e.g. "dependsOn npm_install"
83
84
project.tasks.addRule(" Pattern: \" pnpm_<command>\" : Executes an PNPM command." ) {
84
85
val taskName = this
85
- if (taskName.startsWith(" pnpm_" )) {
86
+ if (taskName.startsWith(" pnpm_" ) && enableTaskRules.get() ) {
86
87
project.tasks.register<PnpmTask >(taskName) {
87
88
val tokens = taskName.split(" _" ).drop(1 ) // all except first
88
89
pnpmCommand.set(tokens)
@@ -94,10 +95,10 @@ class NodePlugin : Plugin<Project> {
94
95
}
95
96
}
96
97
97
- private fun addYarnRule () { // note this rule also makes it possible to specify e.g. "dependsOn yarn_install"
98
+ private fun addYarnRule (enableTaskRules : Property < Boolean > ) { // note this rule also makes it possible to specify e.g. "dependsOn yarn_install"
98
99
project.tasks.addRule(" Pattern: \" yarn_<command>\" : Executes an Yarn command." ) {
99
100
val taskName = this
100
- if (taskName.startsWith(" yarn_" )) {
101
+ if (taskName.startsWith(" yarn_" ) && enableTaskRules.get() ) {
101
102
project.tasks.create<YarnTask >(taskName) {
102
103
val tokens = taskName.split(" _" ).drop(1 ) // all except first
103
104
yarnCommand.set(tokens)
0 commit comments