-
Notifications
You must be signed in to change notification settings - Fork 56
/
build.gradle
403 lines (341 loc) · 13.6 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
import java.nio.file.Files
ext.moduleName = 'stroom.dashboard.gwt'
def getSysPropertyOrDefault = { propName, defaultValue ->
def val
if (System.hasProperty(propName)
&& System.getProperty(propName) != "unspecified"
&& System.getProperty(propName) != "") {
val = System.getProperty(propName)
logger.info("Using property [${propName}] with value [${val}]")
} else {
val = defaultValue
logger.info("Property [${propName}] has no value, using default value [${val}]")
}
return val
}
def resourcesDir = project(':stroom-app').file('src/main/resources')
def warDir = "${resourcesDir}/ui"
def outputDir = "${warDir}/dashboard"
def javaIoTmpDir = getSysPropertyOrDefault("java.io.tmpdir", "/tmp")
logger.info('javaIoTmpDir: ' + javaIoTmpDir)
// Append the rootDir so gwt builds from different dirs don't conflict
def gwtBuildDir = "${javaIoTmpDir}/gwt/${rootProjectAbsPathStr}/dashboard-gwt_build"
gwtBuildDir = gwtBuildDir.replaceAll('//', '/')
logger.info('gwtBuildDir: ' + gwtBuildDir)
def gwtTmpDir = "${gwtBuildDir}/tmp"
logger.info('gwtTmpDir: ' + gwtTmpDir)
def workDir = "${gwtBuildDir}/work"
def deployDir = "${gwtBuildDir}/deploy"
def extraDir = "${gwtBuildDir}/extra"
def allSourceDir = "${gwtBuildDir}/all-source"
def transformedSourceDir = "${gwtBuildDir}/transformed-source"
def transformedBuildDir = "${gwtBuildDir}/transformed-build"
def rsyncOutputDir = "${gwtBuildDir}/rsync-output"
def gwtSourceDirs = []
configurations.configureEach {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'javax.xml.bind') {
details.useVersion "2.3.1"
}
if (details.requested.group == 'com.fasterxml.jackson.core') {
details.useVersion "2.9.6"
}
}
}
}
// Declare a source set just for our GWT compile that is separate from the Java compilation source set.
sourceSets {
gwtSource
jakartaTransformer
}
dependencies {
implementation project(':stroom-core-client')
implementation project(':stroom-core-client-widget')
implementation project(':stroom-core-shared')
implementation project(':stroom-dashboard:stroom-dashboard-client')
implementation project(':stroom-docref')
implementation project(':stroom-gwt')
implementation project(':stroom-query:stroom-query-language-api')
implementation project(':stroom-query:stroom-query-api')
// These source deps are all needed for the GWT transpiling to javascript
implementation libs.gin
implementation libs.guice__gwt
implementation libs.gwt_dev
implementation libs.gwt_user
implementation libs.gwtp_mvp_client
implementation libs.jackson_annotations
implementation libs.jaxb_api__gwt
implementation libs.swagger_annotations // needed so gwt can compile the stroom-query code that contains swagger annotations
implementation libs.ws_rs_api__gwt
gwtSourceImplementation libs.gin
gwtSourceImplementation libs.gwt_dev
gwtSourceImplementation libs.gwt_user
gwtSourceImplementation libs.gwtp_mvp_client
gwtSourceImplementation libs.jaxb_api__gwt
gwtSourceImplementation libs.swagger_annotations // needed so gwt can compile the stroom-query code that contains swagger annotations
gwtSourceImplementation libs.restygwt
gwtSourceImplementation libs.ws_rs_api__gwt
jakartaTransformerImplementation libs.eclipse_transformer_cli
}
// Define a list of projects that contain the source code we want to compile with GWT.
def clientProjects = [
project(':stroom-core-client'),
project(':stroom-core-client-widget'),
project(':stroom-dashboard-gwt'),
project(':stroom-dashboard:stroom-dashboard-client'),
project(':stroom-core-shared'),
project(':stroom-docref'),
project(':stroom-query:stroom-query-api'),
project(':stroom-query:stroom-query-language-api'),
project(':stroom-util-shared'),
]
// Task to make a copy of each project in projectsToRename then change all imports
// from jakarta => javax (in source/classses/resources) so that GWT can use them.
// It adds the modified projects to GWTs compile classpath.
// This is a temporary hack until there is a jakarta friendly version of GWT.
// See https://github.com/gwtproject/gwt/issues/9727 for details on jakarta progress but
// be aware that restgwt is not jakarta friendly and is a dormant project so that will need
// sorting somehow.
tasks.register('copySources') {
doLast {
// This file has all the rename mappings for TransformerCLI to use
def propFilePath = rootDir.toPath().resolve('jakarta-renames-reverse.properties')
def inputProjectPath = "${gwtBuildDir}/raw-source"
// Delete current source output.
delete inputProjectPath
// Copy all code into source output.
clientProjects.each { prj ->
println('copy: ' + prj.projectDir)
copy {
from prj.projectDir.toPath().resolve('src').resolve('main').resolve('java')
into inputProjectPath
}
copy {
from prj.projectDir.toPath().resolve('src').resolve('main').resolve('resources')
into inputProjectPath
}
}
// Transform code.
println 'Running eclipse TransformerCLI'
println(' input: ' + inputProjectPath)
println(' outpu: ' + transformedSourceDir)
delete transformedSourceDir
javaexec {
classpath = files(sourceSets.jakartaTransformer.compileClasspath)
mainClass = "org.eclipse.transformer.cli.TransformerCLI"
args = [
inputProjectPath,
transformedSourceDir,
'-tr', propFilePath,
]
}
}
}
tasks.register('compileSources', JavaCompile) {
dependsOn copySources
def sources = transformedSourceDir
new File(sources).mkdirs()
def build = transformedBuildDir
new File(build).mkdirs()
source = file(sources)
destinationDirectory.set(file(build))
classpath = files(sources, sourceSets.gwtSource.compileClasspath)
options.sourcepath = files(sources)
outputs.dir(destinationDirectory.get())
}
tasks.register('makeGwtSourceDirs') {
dependsOn compileSources
doLast {
gwtSourceDirs = []
// Add all of the library sources from the gwtSource source set defined above.
gwtSourceDirs.addAll(sourceSets.gwtSource.compileClasspath)
gwtSourceDirs.addAll(project(':stroom-gwt').sourceSets.main.output.classesDirs)
gwtSourceDirs.add(transformedSourceDir)
gwtSourceDirs.add(transformedBuildDir)
println "Dumping ${gwtSourceDirs.size()} gwtSourceDirs"
gwtSourceDirs.each {
println "${it.toString()}"
}
}
}
tasks.register('gwtCompile', JavaExec) {
dependsOn classes
group "gwt"
dependsOn 'gwtClean'
dependsOn 'makeGwtSourceDirs'
def module = 'stroom.dashboard.DashboardApp'
doFirst {
println 'Deleting GWT build dirs in ' + gwtBuildDir.toString()
delete gwtTmpDir
delete workDir
delete deployDir
delete extraDir
logger.info("Ensuring directory gwtBuildDir ${gwtBuildDir}")
new File(gwtBuildDir).mkdirs()
logger.info("Ensuring directory gwtTmpDir ${gwtTmpDir}")
new File(gwtTmpDir).mkdirs()
logger.info("Ensuring directory workDir ${workDir}")
new File(workDir).mkdirs()
logger.info("Ensuring directory deployDir ${deployDir}")
new File(deployDir).mkdirs()
logger.info("Ensuring directory extraDir ${extraDir}")
new File(extraDir).mkdirs()
logger.info("gwtSourceDirs count: ${gwtSourceDirs.size()}")
//println "Dumping $gwtSourceDirs.size gwtSourceDirs"
//gwtSourceDirs.each {
//println "${it.toString()}"
//}
gwtSourceDirs.each {
if (it instanceof java.nio.file.Path && Files.exists(it)) {
println "Can't find gwtSourceDir" + it
//throw new GradleException("Can't find gwtSourceDir ${it}")
} else if (it instanceof File && !Files.exists(it.toPath())) {
println "Can't find gwtSourceDir" + it
}
}
}
mainClass.set(gwtCompilerProps.mainClass.toString())
classpath {
gwtSourceDirs
}
args = [
'-logLevel', 'INFO',
'-workDir', workDir,
'-XfragmentCount', '5',
'-optimize', '9',
'-failOnError',
'-localWorkers', gwtCompilerProps.workers,
'-war', warDir,
'-deploy', deployDir,
'-extra', extraDir,
'-strict',
module // Your GWT module
]
jvmArgs = [
"-Djava.io.tmpdir=${gwtTmpDir}",
//'-Dgwt.persistentunitcache=false',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED', // needed for GWT
]
minHeapSize = gwtCompilerProps.minHeap
maxHeapSize = gwtCompilerProps.maxHeap
}
tasks.register('gwtDraftCompile', JavaExec) {
dependsOn classes
group "gwt"
dependsOn 'makeGwtSourceDirs'
def module = 'stroom.dashboard.DashboardAppSuperDevModeChrome'
doFirst {
println 'Deleting GWT compiled output: ' + outputDir.toString()
delete outputDir
logger.info("Ensuring directory gwtBuildDir ${gwtBuildDir}")
new File(gwtBuildDir).mkdirs()
logger.info("Ensuring directory gwtTmpDir ${gwtTmpDir}")
new File(gwtTmpDir).mkdirs()
logger.info("Ensuring directory workDir ${workDir}")
new File(workDir).mkdirs()
logger.info("Ensuring directory deployDir ${deployDir}")
new File(deployDir).mkdirs()
logger.info("Ensuring directory extraDir ${extraDir}")
new File(extraDir).mkdirs()
gwtSourceDirs.each {
if (it instanceof java.nio.file.Path && Files.exists(it)) {
println "Can't find gwtSourceDir" + it
//throw new GradleException("Can't find gwtSourceDir ${it}")
} else if (it instanceof File && !Files.exists(it.toPath())) {
println "Can't find gwtSourceDir" + it
}
}
}
mainClass = 'com.google.gwt.dev.Compiler'
classpath {
gwtSourceDirs
}
args = [
'-logLevel', 'INFO',
'-workDir', workDir,
'-draftCompile', // Speeds up compile with 25%
'-XfragmentCount', '0',
'-optimize', '0',
'-failOnError',
'-localWorkers', '5',
'-incremental',
'-war', warDir,
'-deploy', deployDir,
'-extra', extraDir,
'-strict',
module // Your GWT module
]
jvmArgs = [
"-Djava.io.tmpdir=${gwtTmpDir}",
'--add-opens', 'java.base/java.lang=ALL-UNNAMED', // needed for GWT
]
minHeapSize = '1G'
maxHeapSize = '4G'
}
tasks.register('gwtSuperDevMode', JavaExec) {
dependsOn classes
group "gwt"
dependsOn 'makeGwtSourceDirs'
def module = 'stroom.dashboard.DashboardAppSuperDevModeChrome'
// def dirs = []
// parent.file(".").eachDir {it.eachDirMatch("src") {it.eachDirMatch("main") { it.eachDirMatch("java") {dirs << it}}}}
// parent.file(".").eachDir {it.eachDirMatch("src") {it.eachDirMatch("main") { it.eachDirMatch("resources") {dirs << it}}}}
// println dirs
doFirst {
logger.info("Ensuring directory gwtBuildDir ${gwtBuildDir}")
new File(gwtBuildDir).mkdirs()
logger.info("Ensuring directory gwtTmpDir ${gwtTmpDir}")
new File(gwtTmpDir).mkdirs()
logger.info("Ensuring directory workDir ${workDir}")
new File(workDir).mkdirs()
logger.info("Ensuring directory deployDir ${deployDir}")
new File(deployDir).mkdirs()
logger.info("Ensuring directory extraDir ${extraDir}")
new File(extraDir).mkdirs()
def GREEN = '\033[1;32m'
def NC = '\033[0m'
println """
${NC}To run stroom in SuperDevMode:${GREEN}
* Visit the 'code server' (link further down) and copy the dev mode buttons to your browser bookmarks
* Visit stroom at http://localhost:8080 (NOTE: http, not https), or https://localhost if running Nginx
* Click 'Dev Mode On'${NC}
If you change any code shared between client and server, you will need to run :stroom-app-gwt:jakarta to
update GWT's view of the code.
""".stripIndent().trim()
}
mainClass = 'com.google.gwt.dev.DevMode'
classpath {
gwtSourceDirs
}
args = [
'-logLevel', 'INFO',
'-workDir', workDir,
'-failOnError',
'-war', warDir,
'-deploy', deployDir,
'-extra', extraDir,
'-strict',
'-noserver',
module // Your GWT module
]
jvmArgs = [
"-Djava.io.tmpdir=${gwtTmpDir}",
'--add-opens', 'java.base/java.lang=ALL-UNNAMED', // needed for GWT
]
minHeapSize = gwtCompilerProps.minHeap
maxHeapSize = gwtCompilerProps.maxHeap
}
tasks.register('gwtClean') {
group "gwt"
doLast {
// println 'Deleting GWT unit cache: ' + unitCacheDir.toString()
// delete unitCacheDir
logger.info('Deleting gwtBuildDir: ' + gwtBuildDir.toString())
delete gwtBuildDir
logger.info("Ensuring directory gwtBuildDir ${gwtBuildDir}")
new File(gwtBuildDir).mkdirs()
logger.info("Ensuring directory gwtTmpDir ${gwtTmpDir}")
new File(gwtTmpDir).mkdirs()
}
}