/
build.gradle
117 lines (92 loc) · 3.58 KB
/
build.gradle
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
import java.util.stream.Collectors
plugins {
alias(libs.plugins.gradle.node)
alias(libs.plugins.task.tree)
}
node {
download = true
version = libs.versions.projectNode.get()
npmVersion = libs.versions.projectNpm.get()
distBaseUrl = "https://nodejs.org/dist"
npmInstallCommand = "ci"
workDir = file("${project.projectDir}/tools/nodejs")
npmWorkDir = file("${project.projectDir}/tools/npm")
yarnWorkDir = file("${project.projectDir}/tools/yarn")
nodeProjectDir = file("${project.projectDir}/frontend")
}
if (project.hasProperty('omitDevDependencies')) {
npmInstall.args = ['--registry', 'https://zowe.jfrog.io/artifactory/api/npm/npm-org', '--production', '--omit=dev', '--legacy-peer-deps'] // different args for different npm versions
} else {
npmInstall.args = ['--registry', 'https://zowe.jfrog.io/artifactory/api/npm/npm-org', '--legacy-peer-deps']
}
// =================================================
//
// Please manage all task dependencies in here and
// not in package.json. This is to leverage
// Gradle's incremental task feature
//
// =================================================
task zipNpmBuild(type: Zip) {
archiveFileName = "static-files.zip"
into('/') {
from "./frontend/build"
}
}
task javascriptClean(type: Delete) {
group = 'npm'
delete 'bin', 'build', 'frontend/test-results', 'frontend/coverage', 'frontend/build'
if (rootProject.cleanNodeModules == 'true') {
delete 'frontend/node_modules'
}
}
clean.dependsOn javascriptClean
// test always runs for build, this side effect of task hierarchy being defined in package.json rather than here
task npmTest(type: NpmTask) {
group = 'npm'
description = "Javascript unit tests"
inputs.dir('frontend/src').withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file('frontend/package.json').withPathSensitivity(PathSensitivity.RELATIVE)
outputs.file('frontend/test-results/test-report-unit.html')
outputs.dir('frontend/coverage')
outputs.cacheIf { true }
args = ['run', 'test']
}
npmTest.dependsOn npmInstall
test.dependsOn npmTest
task npmE2ECI(type: NpmTask, dependsOn: ':integration-tests:startUpCheck') {
group = 'npm'
description = "Javascript End to End Tests"
environment = ['cypress_catalogHomePage': String.format("%s://%s:%s/apicatalog/ui/v1", System.getProperty("gateway.scheme"),
System.getProperty("gateway.host"), System.getProperty("gateway.port")),
'cypress_username' : System.getProperty("credentials.user"),
'cypress_password' : System.getProperty("credentials.password")]
args = ['run', 'cy:e2e:ci']
}
npmE2ECI.dependsOn npmInstall
task npmLint(type: NpmTask) {
group = 'npm'
description = 'Run eslint'
args = ['run', 'lint']
}
npmLint.dependsOn npmInstall
task npmBuild(type: NpmTask) {
group = 'npm'
description = "Executes npm build"
inputs.dir('frontend/src').withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir('frontend/public').withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(fileTree('frontend').matching {
include '**/.env*'
}).withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file('frontend/.eslintrc.js').withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file('frontend/package.json').withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir('frontend/build')
outputs.cacheIf { true }
args = ['run', 'build']
}
npmBuild.dependsOn npmInstall
npmBuild.dependsOn npmLint
build.dependsOn npmBuild
npmBuild.dependsOn npmTest
jar {
enabled false
}