1
1
import java.nio.file.Files
2
+ import java.time.Duration
3
+ import java.time.Instant
2
4
3
5
ext. moduleName = ' stroom.app.gwt'
4
6
@@ -23,7 +25,7 @@ def outputDir = "${warDir}/stroom"
23
25
def javaIoTmpDir = getSysPropertyOrDefault(" java.io.tmpdir" , " /tmp" )
24
26
logger. info(' javaIoTmpDir: ' + javaIoTmpDir)
25
27
// Append the rootDir so gwt builds from different dirs don't conflict
26
- def gwtBuildDir = javaIoTmpDir + " / app-gwt_build/ " + rootDir
28
+ def gwtBuildDir = " ${ javaIoTmpDir } /gwt/ ${ rootProjectAbsPathStr } / app-gwt_build"
27
29
gwtBuildDir = gwtBuildDir. replaceAll(' //' , ' /' )
28
30
logger. info(' gwtBuildDir: ' + gwtBuildDir)
29
31
@@ -32,10 +34,12 @@ logger.info('gwtTmpDir: ' + gwtTmpDir)
32
34
def workDir = " ${ gwtBuildDir} /work"
33
35
def deployDir = " ${ gwtBuildDir} /deploy"
34
36
def extraDir = " ${ gwtBuildDir} /extra"
35
- // This is where eclipse transformer outputs to
36
- def modifiedProjectsBasePath = " ${ gwtBuildDir} /modified_projects"
37
- // This will contain a copy of modifiedProjectsBasePath that GWT uses on its classpath
38
- def modifiedProjectsBasePathGwt = " ${ gwtBuildDir} /modified_projects_gwt"
37
+
38
+
39
+ def allSourceDir = " ${ gwtBuildDir} /all-source"
40
+ def transformedSourceDir = " ${ gwtBuildDir} /transformed-source"
41
+ def transformedBuildDir = " ${ gwtBuildDir} /transformed-build"
42
+ def rsyncOutputDir = " ${ gwtBuildDir} /rsync-output"
39
43
40
44
def gwtSourceDirs = []
41
45
@@ -123,15 +127,17 @@ tasks.register('copySources') {
123
127
doLast {
124
128
// This file has all the rename mappings for TransformerCLI to use
125
129
def propFilePath = rootDir. toPath(). resolve(' jakarta-renames-reverse.properties' )
126
- def inputProjectPath = layout. buildDirectory. dir(" raw-source" ). get()
127
- def outputProjectPath = layout. buildDirectory. dir(" transformed-source" ). get()
130
+ def inputProjectPath = " ${ gwtBuildDir} /raw-source"
128
131
129
132
// Delete current source output.
130
133
delete inputProjectPath
131
134
135
+ def start = Instant . now()
136
+
132
137
// Copy all code into source output.
138
+ println (" copy project source (java/resources) => ${ inputProjectPath} " )
133
139
clientProjects. each { prj ->
134
- println (' copy: ' + prj. projectDir)
140
+ println (' ' + prj. projectDir)
135
141
copy {
136
142
from prj. projectDir. toPath(). resolve(' src' ). resolve(' main' ). resolve(' java' )
137
143
into inputProjectPath
@@ -141,44 +147,55 @@ tasks.register('copySources') {
141
147
into inputProjectPath
142
148
}
143
149
}
150
+ println (" ${ Duration.between(start, Instant.now())} " )
151
+ start = Instant . now()
144
152
145
153
// Transform code.
146
154
println ' Running eclipse TransformerCLI'
147
- println (' inputProjectPath : ' + inputProjectPath)
148
- println (' outputProjectPath : ' + outputProjectPath )
149
- delete outputProjectPath
155
+ println (' input : ' + inputProjectPath)
156
+ println (' output : ' + transformedSourceDir )
157
+ delete transformedSourceDir
150
158
151
159
javaexec {
152
160
classpath = files(sourceSets. jakartaTransformer. compileClasspath)
153
161
mainClass = " org.eclipse.transformer.cli.TransformerCLI"
154
162
args = [
155
163
inputProjectPath,
156
- outputProjectPath ,
164
+ transformedSourceDir ,
157
165
' -tr' , propFilePath,
158
166
]
159
167
}
168
+ println (" ${ Duration.between(start, Instant.now())} " )
169
+ start = Instant . now()
170
+
171
+ delete allSourceDir
160
172
161
- def allSourcePath = layout. buildDirectory. dir(" all-source" ). get()
162
- delete allSourcePath
163
- // Copy dep jars.
173
+ println (" copy dep jars => ${ allSourceDir} " )
164
174
sourceSets. gwtSource. compileClasspath. files. forEach {zipFile ->
165
- println (' copy: ' + zipFile)
175
+ println (' ' + zipFile)
166
176
copy {
167
177
from zipTree(zipFile)
168
- into allSourcePath
178
+ into allSourceDir
169
179
}
170
180
}
181
+ println (" ${ Duration.between(start, Instant.now())} " )
182
+ start = Instant . now()
183
+
184
+ println (" copy ${ transformedSourceDir} => ${ allSourceDir} " )
171
185
copy {
172
- from outputProjectPath
173
- into allSourcePath
186
+ from transformedSourceDir
187
+ into allSourceDir
174
188
}
189
+ println (" ${ Duration.between(start, Instant.now())} " )
175
190
}
176
191
}
177
192
178
193
tasks. register(' compileSources' , JavaCompile ) {
179
194
dependsOn copySources
180
- def sources = layout. buildDirectory. dir(" transformed-source" ). get()
181
- def build = layout. buildDirectory. dir(" transformed-build" ). get()
195
+ def sources = transformedSourceDir
196
+ new File (sources). mkdirs()
197
+ def build = transformedBuildDir
198
+ new File (build). mkdirs()
182
199
183
200
source = file(sources)
184
201
destinationDirectory. set(file(build))
@@ -193,40 +210,62 @@ tasks.register('makeGwtSourceDirs') {
193
210
group " gwt"
194
211
195
212
doLast {
196
- def rsyncInput = layout. buildDirectory. dir(" rsync-input" ). get()
197
- def rsyncOutput = layout. buildDirectory. dir(" rsync-output" ). get()
213
+ def rsyncInputDir = " ${ gwtBuildDir} /rsync-input"
214
+ delete rsyncInputDir
215
+
216
+ def start = Instant . now()
217
+
218
+ // Do this as two copies then one rsync rather than just two rsyncs
219
+ // so that we can be sure that any GWT classes that we have cloned and
220
+ // changed overwrite the original GWT version in rsyncInputDir
198
221
199
- println " copy ${ gwtSourceDirs.size()} gwtSourceDirs"
200
- delete rsyncInput
222
+ println (" copy ${ allSourceDir} => ${ rsyncInputDir} " )
201
223
copy {
202
- from layout . buildDirectory . dir( " all-source " ) . get()
203
- into rsyncInput;
224
+ from allSourceDir
225
+ into rsyncInputDir
204
226
}
227
+
228
+ println (" ${ Duration.between(start, Instant.now())} " )
229
+ start = Instant . now()
230
+
231
+ println (" copy ${ transformedBuildDir} => ${ rsyncInputDir} " )
205
232
copy {
206
- from layout . buildDirectory . dir( " transformed-build " ) . get()
207
- into rsyncInput;
233
+ from transformedBuildDir
234
+ into rsyncInputDir
208
235
}
209
236
210
- println " rsync ${ gwtSourceDirs.size()} gwtSourceDirs"
237
+ println (" ${ Duration.between(start, Instant.now())} " )
238
+ start = Instant . now()
239
+
240
+ // Rsync the files so that we don't delete all the files that superdev is monitoring,
241
+ // which it doesn't like. Rsync should only change the files that have actually changed
242
+ // i.e. when doing superdev code changes.
243
+ println " rsync ${ rsyncInputDir} => ${ rsyncOutputDir} "
211
244
exec {
212
245
executable = ' rsync'
213
- args = [" --recursive" , " --checksum" , " --delete" , rsyncInput. toString() + " /" , rsyncOutput]
246
+ args = [
247
+ " --recursive" ,
248
+ " --checksum" ,
249
+ " --delete" ,
250
+ " --stats" ,
251
+ rsyncInputDir + " /" ,
252
+ rsyncOutputDir]
214
253
}
215
254
255
+ println (" ${ Duration.between(start, Instant.now())} " )
256
+ start = Instant . now()
216
257
258
+ // Now assemble the sourceDirs array for GWT to compile
217
259
gwtSourceDirs = []
218
-
219
260
// Add all of the library sources from the gwtSource source set defined above.
220
261
gwtSourceDirs. addAll(sourceSets. gwtDevSource. compileClasspath)
221
262
gwtSourceDirs. addAll(project(' :stroom-gwt' ). sourceSets. main. output. classesDirs)
222
-
223
- // gwtSourceDirs.add(layout.buildDirectory.dir("all-source").get())
224
- // gwtSourceDirs.add(layout.buildDirectory.dir("transformed-build").get())
225
- gwtSourceDirs. add(rsyncOutput)
263
+ // Add the rsync clone of our transformed build
264
+ gwtSourceDirs. add(rsyncOutputDir)
226
265
227
266
println " Dumping ${ gwtSourceDirs.size()} gwtSourceDirs"
228
267
gwtSourceDirs. each {
229
- println " ${ it.toString()} "
268
+ println " ${ it.toString()} "
230
269
}
231
270
}
232
271
}
@@ -263,7 +302,6 @@ tasks.register('gwtCompile', JavaExec) {
263
302
// gwtSourceDirs.each {
264
303
// println "${it.toString()}"
265
304
// }
266
- logger. info(' modifiedProjectsBasePath: ' + modifiedProjectsBasePath)
267
305
268
306
gwtSourceDirs. each {
269
307
if (it instanceof java.nio.file.Path && Files . exists(it)) {
@@ -436,14 +474,8 @@ tasks.register('gwtClean') {
436
474
// println 'Deleting GWT unit cache: ' + unitCacheDir.toString()
437
475
// delete unitCacheDir
438
476
439
- logger. info(' Deleting GWT compiled output: ' + outputDir. toString())
440
- delete outputDir
441
- logger. info(' Deleting GWT build dir: ' + gwtBuildDir. toString())
477
+ logger. info(' Deleting gwtBuildDir: ' + gwtBuildDir. toString())
442
478
delete gwtBuildDir
443
- logger. info(' Deleting modified projects: ' + modifiedProjectsBasePath. toString())
444
- delete modifiedProjectsBasePath
445
- logger. info(' Deleting modified projects (GWT copy): ' + modifiedProjectsBasePathGwt. toString())
446
- delete modifiedProjectsBasePathGwt
447
479
448
480
logger. info(" Ensuring directory gwtBuildDir ${ gwtBuildDir} " )
449
481
new File (gwtBuildDir). mkdirs()
0 commit comments