-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
build.gradle.kts
151 lines (138 loc) · 4.21 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import com.github.gradle.node.npm.proxy.ProxySettings
import com.github.gradle.node.npm.task.NpmTask
import com.github.gradle.node.npm.task.NpxTask
import com.github.gradle.node.task.NodeTask
import com.github.gradle.node.yarn.task.YarnTask
// This file shows how to use this plugin with the Kotlin DSL.
// All the properties are set, most of the time with the default value.
// /!\ We recommend to set only the values for which the default value is not satisfying.
plugins {
// You have to specify the plugin version, for instance
// id("com.github.node-gradle.node") version "3.0.0"
// This works as is in the integration tests context
id("com.github.node-gradle.node")
}
node {
version.set("18.17.1")
npmVersion.set("")
yarnVersion.set("")
npmInstallCommand.set("install")
distBaseUrl.set("https://nodejs.org/dist")
download.set(false)
workDir.set(file("${project.projectDir}/.cache/nodejs"))
npmWorkDir.set(file("${project.projectDir}/.cache/npm"))
yarnWorkDir.set(file("${project.projectDir}/.cache/yarn"))
nodeProjectDir.set(file("${project.projectDir}"))
nodeProxySettings.set(ProxySettings.SMART)
}
tasks.npmInstall {
nodeModulesOutputFilter {
exclude("notExistingFile")
}
}
tasks.yarn {
nodeModulesOutputFilter {
exclude("notExistingFile")
}
}
val testTaskUsingNpx = tasks.register<NpxTask>("testNpx") {
dependsOn(tasks.npmInstall)
command.set("mocha")
args.set(listOf("test", "--grep", "should say hello"))
ignoreExitValue.set(false)
environment.set(mapOf("MY_CUSTOM_VARIABLE" to "hello"))
workingDir.set(projectDir)
execOverrides {
standardOutput = System.out
}
inputs.file("package.json")
inputs.dir("src")
inputs.dir("test")
outputs.upToDateWhen {
true
}
}
val testTaskUsingNpm = tasks.register<NpmTask>("testNpm") {
dependsOn(tasks.npmInstall)
npmCommand.set(listOf("run", "test"))
args.set(listOf("test"))
ignoreExitValue.set(false)
environment.set(mapOf("MY_CUSTOM_VARIABLE" to "hello"))
workingDir.set(projectDir)
execOverrides {
standardOutput = System.out
}
inputs.file("package.json")
inputs.dir("src")
inputs.dir("test")
outputs.upToDateWhen {
true
}
}
val testTaskUsingYarn = tasks.register<YarnTask>("testYarn") {
dependsOn(tasks.npmInstall)
yarnCommand.set(listOf("run", "test"))
args.set(listOf("test"))
ignoreExitValue.set(false)
environment.set(mapOf("MY_CUSTOM_VARIABLE" to "hello"))
workingDir.set(projectDir)
execOverrides {
standardOutput = System.out
}
inputs.dir("node_modules")
inputs.file("package.json")
inputs.dir("src")
inputs.dir("test")
outputs.upToDateWhen {
true
}
}
tasks.register<NodeTask>("run") {
dependsOn(testTaskUsingNpx, testTaskUsingNpm, testTaskUsingYarn)
script.set(file("src/main.js"))
args.set(listOf("Bobby"))
ignoreExitValue.set(false)
environment.set(mapOf("MY_CUSTOM_VARIABLE" to "hello"))
workingDir.set(projectDir)
execOverrides {
standardOutput = System.out
}
inputs.dir("src")
outputs.upToDateWhen {
false
}
}
val buildTaskUsingNpx = tasks.register<NpxTask>("buildNpx") {
dependsOn(tasks.npmInstall)
command.set("babel")
args.set(listOf("src", "--out-dir", "${buildDir}/npx-output"))
inputs.dir("src")
outputs.dir("${buildDir}/npx-output")
}
val buildTaskUsingNpm = tasks.register<NpmTask>("buildNpm") {
dependsOn(tasks.npmInstall)
npmCommand.set(listOf("run", "build"))
args.set(listOf("--", "--out-dir", "${buildDir}/npm-output"))
inputs.dir("src")
outputs.dir("${buildDir}/npm-output")
}
val buildTaskUsingYarn = tasks.register<YarnTask>("buildYarn") {
dependsOn(tasks.npmInstall)
yarnCommand.set(listOf("run", "build"))
args.set(listOf("--out-dir", "${buildDir}/yarn-output"))
inputs.dir("src")
outputs.dir("${buildDir}/yarn-output")
}
tasks.register<Zip>("package") {
archiveFileName.set("app.zip")
destinationDirectory.set(buildDir)
from(buildTaskUsingNpx) {
into("npx")
}
from(buildTaskUsingNpm) {
into("npm")
}
from (buildTaskUsingYarn) {
into("yarn")
}
}