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
|
plugins {
id 'refinery-frontend-workspace'
id 'refinery-java-application'
id 'refinery-xtext-conventions'
}
import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn
dependencies {
implementation project(':refinery-language')
implementation project(':refinery-language-ide')
implementation libs.xtend.lib
implementation libs.xtext.web
implementation libs.jetty.server
implementation libs.jetty.servlet
implementation libs.jetty.websocket.server
implementation libs.slf4j.simple
implementation libs.slf4j.log4j
testImplementation testFixtures(project(':refinery-language'))
testImplementation libs.jetty.websocket.client
}
def generateXtextLanguage = project(':refinery-language').tasks.named('generateXtextLanguage')
for (taskName in ['compileJava', 'processResources']) {
tasks.named(taskName) {
dependsOn generateXtextLanguage
}
}
def webpackOutputDir = "${buildDir}/webpack"
def productionResources = "${webpackOutputDir}/production"
def serverMainClass = 'tools.refinery.language.web.ServerLauncher'
frontend {
assembleScript = 'assemble:webpack'
}
def installFrontend = tasks.named('installFrontend')
def generateLezerGrammar = tasks.register('generateLezerGrammar', RunYarn) {
dependsOn installFrontend
inputs.file('src/main/js/language/problem.grammar')
inputs.files('package.json', 'yarn.lock')
outputs.file "${buildDir}/generated/sources/lezer/problem.ts"
outputs.file "${buildDir}/generated/sources/lezer/problem.terms.ts"
script = 'run assemble:lezer'
}
def assembleFrontend = tasks.named('assembleFrontend')
assembleFrontend.configure {
dependsOn generateLezerGrammar
inputs.dir 'src/main/css'
inputs.dir 'src/main/html'
inputs.dir 'src/main/js'
inputs.file "${buildDir}/generated/sources/lezer/problem.ts"
inputs.file "${buildDir}/generated/sources/lezer/problem.terms.ts"
inputs.files('package.json', 'yarn.lock', 'webpack.config.js')
outputs.dir productionResources
}
def eslint = tasks.register('eslint', RunYarn) {
dependsOn installFrontend
inputs.dir 'src/main/js'
inputs.files('.eslintrc.js', 'tsconfig.json')
if (project.hasProperty('ci')) {
outputs.file "${buildDir}/eslint.json"
script = 'run check:eslint:ci'
} else {
script = 'run check:eslint'
}
group = 'verification'
description = 'Check for TypeScript errors.'
}
def stylelint = tasks.register('stylelint', RunYarn) {
dependsOn installFrontend
inputs.dir 'src/main/css'
inputs.file '.stylelintrc.js'
if (project.hasProperty('ci')) {
outputs.file "${buildDir}/stylelint.json"
script = 'run check:stylelint:ci'
} else {
script = 'run check:stylelint'
}
group = 'verification'
description = 'Check for Sass errors.'
}
tasks.named('check') {
dependsOn(eslint, stylelint)
}
mainClassName = serverMainClass
tasks.named('jar') {
dependsOn assembleFrontend
from(productionResources) {
into 'webapp'
}
}
tasks.named('shadowJar') {
dependsOn assembleFrontend
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
configurations = [project.configurations.runtimeClasspath]
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*',
'.options', '.api_description', '*.profile', 'about.*', 'about_*.html', 'about_files/*',
'plugin.xml', 'systembundle.properties', 'profile.list', 'META-INF/resources/xtext/**')
append('plugin.properties')
from(productionResources) {
into 'webapp'
}
}
def jettyRun = tasks.register('jettyRun', JavaExec) {
dependsOn assembleFrontend
dependsOn sourceSets.main.runtimeClasspath
classpath = sourceSets.main.runtimeClasspath.filter{it.exists()}
mainClass = serverMainClass
standardInput = System.in
environment BASE_RESOURCE: productionResources
group = 'run'
description = 'Start a Jetty web server serving the Xtex API and assets.'
}
tasks.register('webpackServe', RunYarn) {
dependsOn installFrontend
dependsOn generateLezerGrammar
outputs.dir "${webpackOutputDir}/development"
script = 'run serve'
group = 'run'
description = 'Start a Webpack dev server with hot module replacement.'
}
sonarqube.properties {
properties['sonar.sources'] += [
'src/main/css',
'src/main/html',
'src/main/js',
]
property 'sonar.nodejs.executable', "${frontend.nodeInstallDirectory.get()}/bin/node"
property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json"
property 'sonar.css.stylelint.reportPaths', "${buildDir}/stylelint.json"
// SonarJS does not pick up typescript files with `exactOptionalPropertyTypes`
property 'sonar.typescript.tsconfigPath', 'tsconfig.sonar.json'
}
|