diff options
Diffstat (limited to 'subprojects/frontend/build.gradle')
-rw-r--r-- | subprojects/frontend/build.gradle | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/subprojects/frontend/build.gradle b/subprojects/frontend/build.gradle new file mode 100644 index 00000000..71444e89 --- /dev/null +++ b/subprojects/frontend/build.gradle | |||
@@ -0,0 +1,101 @@ | |||
1 | plugins { | ||
2 | id 'refinery-frontend-workspace' | ||
3 | id 'refinery-sonarqube' | ||
4 | } | ||
5 | |||
6 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn | ||
7 | |||
8 | def webpackOutputDir = "${buildDir}/webpack" | ||
9 | def productionResources = file("${webpackOutputDir}/production") | ||
10 | |||
11 | frontend { | ||
12 | assembleScript = 'assemble:webpack' | ||
13 | } | ||
14 | |||
15 | configurations { | ||
16 | productionAssets { | ||
17 | canBeConsumed = true | ||
18 | canBeResolved = false | ||
19 | } | ||
20 | } | ||
21 | |||
22 | def installFrontend = tasks.named('installFrontend') | ||
23 | |||
24 | def generateLezerGrammar = tasks.register('generateLezerGrammar', RunYarn) { | ||
25 | dependsOn installFrontend | ||
26 | inputs.file 'src/language/problem.grammar' | ||
27 | inputs.file 'package.json' | ||
28 | inputs.file rootProject.file('yarn.lock') | ||
29 | outputs.file "${buildDir}/generated/sources/lezer/problem.ts" | ||
30 | outputs.file "${buildDir}/generated/sources/lezer/problem.terms.ts" | ||
31 | script = 'run assemble:lezer' | ||
32 | } | ||
33 | |||
34 | def assembleFrontend = tasks.named('assembleFrontend') | ||
35 | assembleFrontend.configure { | ||
36 | dependsOn generateLezerGrammar | ||
37 | inputs.dir 'src' | ||
38 | inputs.file "${buildDir}/generated/sources/lezer/problem.ts" | ||
39 | inputs.file "${buildDir}/generated/sources/lezer/problem.terms.ts" | ||
40 | inputs.files('package.json', 'webpack.config.js') | ||
41 | inputs.file rootProject.file('yarn.lock') | ||
42 | outputs.dir productionResources | ||
43 | } | ||
44 | |||
45 | artifacts { | ||
46 | productionAssets(productionResources) { | ||
47 | builtBy assembleFrontend | ||
48 | } | ||
49 | } | ||
50 | |||
51 | def eslint = tasks.register('eslint', RunYarn) { | ||
52 | dependsOn installFrontend | ||
53 | inputs.dir 'src' | ||
54 | inputs.files('.eslintrc.js', 'tsconfig.json') | ||
55 | inputs.file rootProject.file('yarn.lock') | ||
56 | if (project.hasProperty('ci')) { | ||
57 | outputs.file "${buildDir}/eslint.json" | ||
58 | script = 'run check:eslint:ci' | ||
59 | } else { | ||
60 | script = 'run check:eslint' | ||
61 | } | ||
62 | group = 'verification' | ||
63 | description = 'Check for TypeScript errors.' | ||
64 | } | ||
65 | |||
66 | def stylelint = tasks.register('stylelint', RunYarn) { | ||
67 | dependsOn installFrontend | ||
68 | inputs.dir 'src' | ||
69 | inputs.file '.stylelintrc.js' | ||
70 | inputs.file rootProject.file('yarn.lock') | ||
71 | if (project.hasProperty('ci')) { | ||
72 | outputs.file "${buildDir}/stylelint.json" | ||
73 | script = 'run check:stylelint:ci' | ||
74 | } else { | ||
75 | script = 'run check:stylelint' | ||
76 | } | ||
77 | group = 'verification' | ||
78 | description = 'Check for Sass errors.' | ||
79 | } | ||
80 | |||
81 | tasks.named('check') { | ||
82 | dependsOn(eslint, stylelint) | ||
83 | } | ||
84 | |||
85 | tasks.register('webpackServe', RunYarn) { | ||
86 | dependsOn installFrontend | ||
87 | dependsOn generateLezerGrammar | ||
88 | outputs.dir "${webpackOutputDir}/development" | ||
89 | script = 'run serve' | ||
90 | group = 'run' | ||
91 | description = 'Start a Webpack dev server with hot module replacement.' | ||
92 | } | ||
93 | |||
94 | sonarqube.properties { | ||
95 | properties['sonar.sources'] += ['src'] | ||
96 | property 'sonar.nodejs.executable', "${frontend.nodeInstallDirectory.get()}/bin/node" | ||
97 | property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json" | ||
98 | property 'sonar.css.stylelint.reportPaths', "${buildDir}/stylelint.json" | ||
99 | // SonarJS does not pick up typescript files with `exactOptionalPropertyTypes` | ||
100 | property 'sonar.typescript.tsconfigPath', 'tsconfig.sonar.json' | ||
101 | } | ||