-
Notifications
You must be signed in to change notification settings - Fork 0
/
front.gradle
200 lines (171 loc) · 5.89 KB
/
front.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Copyright (c) 2018 Gonzalo Müller Bravo.
// Licensed under the MIT License (MIT), see LICENSE.txt
plugins {
id 'all.shared.gradle.code-common-tasks' version '1.0.1'
id 'com.moowork.node' version '1.2.0'
}
description = 'Frontend code.'
group = 'Code'
// CONSTANTS
////////////
final SOURCE_DIR = "$projectDir/src"
final MAIN_DIR = "$SOURCE_DIR/main"
final TEST_DIR = "$projectDir/test"
final REPORTS_DIR = "$buildDir/reports"
final TESTS_REPORT_DIR = "$REPORTS_DIR/tests"
final COVERAGE_REPORT_DIR = "$REPORTS_DIR/coverage"
final INCREMENTAL_MAIN_CONFIGURATION = {
inputs.dir MAIN_DIR
}
final INCREMENTAL_LINT_CONFIGURATION = {
inputs.files fileLister.obtainFullFileTree("$projectDir", [includes: [FRONT$ESLINT_CFG_FILE]])
}
final NO_OUTPUTS_CONFIGURATION = {
outputs.upToDateWhen { true }
}
final INCREMENTAL_COMMON_TEST_CONFIGURATION = {
inputs.file 'config/test/common-test.cfg.js'
} << NO_OUTPUTS_CONFIGURATION
final INCREMENTAL_UNIT_TEST_CONFIGURATION = {
inputs.dir "$TEST_DIR/unit"
inputs.file 'config/test/unit-test.cfg.js'
} << INCREMENTAL_COMMON_TEST_CONFIGURATION
final INCREMENTAL_INTEGRATION_TEST_CONFIGURATION = {
inputs.file 'config/test/integration/integration-test.cfg.js'
inputs.file 'config/test/integration/jasmine.cfg.js'
inputs.dir "$TEST_DIR/integration"
} << INCREMENTAL_COMMON_TEST_CONFIGURATION
final INCREMENTAL_TEST_LINT_CONFIGURATION = {
inputs.files fileLister.obtainFullFileTree("$projectDir/$TEST_DIR", [includes: [FRONT$ESLINT_CFG_FILE]])
} << INCREMENTAL_LINT_CONFIGURATION
ext {
webDir = "$buildDir/web"
npmTaskConfiguration = {
// NpmTask task settings
args = ['run'] + args + (logger.debugEnabled
? ['--loglevel', 'silly']
: ['--silent'])
// gradle task settings
dependsOn npmInstall
inputs.file file('package.json')
doFirst {
logger.debug "$it.name command: ${args.join ' '}"
}
}
eslintTaskConfiguration = {
// NpmTask task settings
args += [baseStyleConfig.front.eslintNpmConfigArg]
} << npmTaskConfiguration
mainNpmTaskConfiguration = npmTaskConfiguration << INCREMENTAL_MAIN_CONFIGURATION
eslintMainNpmTaskConfiguration = eslintTaskConfiguration << INCREMENTAL_MAIN_CONFIGURATION
}
// Plugin settings
//////////////////
node {
version = FRONT$NODE_VERSION
download = true
}
// TASKS
////////
// Assessment
/////////////
task assessMain(type: NpmTask) {
// NpmTask task settings
args = ['eslintMain']
// gradle task settings
inputs.files fileLister.obtainFullFileTree("$projectDir/$MAIN_DIR", [includes: [FRONT$ESLINT_CFG_FILE]])
}
assessMain eslintMainNpmTaskConfiguration << INCREMENTAL_TEST_LINT_CONFIGURATION << NO_OUTPUTS_CONFIGURATION
task assessUnitTest(type: NpmTask) {
args = ['eslintUT']
}
assessUnitTest eslintTaskConfiguration << INCREMENTAL_TEST_LINT_CONFIGURATION << INCREMENTAL_UNIT_TEST_CONFIGURATION
task assessIntegrationTest(type: NpmTask) {
args = ['eslintIT']
}
assessIntegrationTest eslintTaskConfiguration << INCREMENTAL_TEST_LINT_CONFIGURATION << INCREMENTAL_INTEGRATION_TEST_CONFIGURATION
task assessCss(type: NpmTask) {
// NpmTask task settings
args = ['stylelint', baseStyleConfig.front.stylelintNpmConfigArg]
// gradle task settings
description = 'Analyze and assess CSS files.'
group = codeCommonTasks.groupForAssessTasks
shouldRunAfter assessMain
inputs.file '.stylelintrc.json'
inputs.files fileLister.obtainFullFileTree("$projectDir/$SOURCE_DIR", [includes: ['*.css']])
}
assessCss mainNpmTaskConfiguration << NO_OUTPUTS_CONFIGURATION
task assessLocal(type: NpmTask) {
// NpmTask task settings
args = ['eslintLocal']
// gradle task settings
description = 'Analyze and assess Local code'
group = codeCommonTasks.groupForAssessTasks
inputs.file FRONT$ESLINT_CFG_FILE
inputs.files fileLister.obtainFullFileTree("$projectDir/local_js", [includes: [FRONT$CODE_FILES, FRONT$ESLINT_CFG_FILE]])
inputs.files fileLister.obtainFullFileTree("$projectDir/local_modules", [includes: [FRONT$CODE_FILES, FRONT$ESLINT_CFG_FILE]])
}
assessLocal eslintTaskConfiguration << NO_OUTPUTS_CONFIGURATION
// Tests
////////
task unitTest(type: NpmTask) {
// Code task settings
ext.reportAt = "$TESTS_REPORT_DIR/unitTest"
ext.coverageReportAt = COVERAGE_REPORT_DIR
// NpmTask task settings
args = ['unitTest'
, "--front_src_dir=$SOURCE_DIR"
, "--front_test_report_dir=$reportAt"
, "--front_coverage_report_dir=$coverageReportAt"]
// gradle task settings
outputs.dir reportAt
outputs.dir coverageReportAt
}
unitTest mainNpmTaskConfiguration << INCREMENTAL_UNIT_TEST_CONFIGURATION
task integrationTest(type: NpmTask) {
// Code task settings
ext.reportAt = "$TESTS_REPORT_DIR/integrationTest"
// NpmTask task settings
args = ['integrationTest'
, "--front_src_dir=$SOURCE_DIR"
, "--front_test_report_dir=$reportAt"]
// gradle task settings
outputs.dir reportAt
}
integrationTest mainNpmTaskConfiguration << INCREMENTAL_INTEGRATION_TEST_CONFIGURATION
// Build
////////
task assembleJs(type: NpmTask) {
// NpmTask task settings
args = ['jsbuild',
"--front_src=$MAIN_DIR",
"--front_dest=$webDir/META-INF/resources",
"--front_env=$runningEnvironment"]
// gradle task settings
description = 'Assembles web static resources.'
group = codeCommonTasks.groupForBuildTasks
inputs.file 'local_js/build.js'
outputs.dir webDir
}
assembleJs mainNpmTaskConfiguration
task assemble(type: Jar) {
// jar task settings
baseName = FRONT$ARCHIVE_NAME
version = FRONT$VERSION
from webDir
destinationDir = file("$buildDir/libs")
// gradle task settings
description = 'Assembles a JAR archive containing the web static resources.'
dependsOn 'assembleJs'
}
// Documentation
////////////////
task doc(type: NpmTask) {
// NpmTask task settings
args = ['jsdoc']
// gradle task settings
ext.documentationType = 'jsDoc'
ext.documentationAt = "$buildDir/docs"
inputs.file 'config/jsdoc.cfg.json'
outputs.dir documentationAt
}