11import java.nio.file.Files
2+ import java.time.Duration
3+ import java.time.Instant
24
35ext. moduleName = ' stroom.app.gwt'
46
@@ -23,7 +25,7 @@ def outputDir = "${warDir}/stroom"
2325def javaIoTmpDir = getSysPropertyOrDefault(" java.io.tmpdir" , " /tmp" )
2426logger. info(' javaIoTmpDir: ' + javaIoTmpDir)
2527// 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"
2729gwtBuildDir = gwtBuildDir. replaceAll(' //' , ' /' )
2830logger. info(' gwtBuildDir: ' + gwtBuildDir)
2931
@@ -32,10 +34,12 @@ logger.info('gwtTmpDir: ' + gwtTmpDir)
3234def workDir = " ${ gwtBuildDir} /work"
3335def deployDir = " ${ gwtBuildDir} /deploy"
3436def 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"
3943
4044def gwtSourceDirs = []
4145
@@ -123,15 +127,17 @@ tasks.register('copySources') {
123127 doLast {
124128 // This file has all the rename mappings for TransformerCLI to use
125129 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"
128131
129132 // Delete current source output.
130133 delete inputProjectPath
131134
135+ def start = Instant . now()
136+
132137 // Copy all code into source output.
138+ println (" copy project source (java/resources) => ${ inputProjectPath} " )
133139 clientProjects. each { prj ->
134- println (' copy: ' + prj. projectDir)
140+ println (' ' + prj. projectDir)
135141 copy {
136142 from prj. projectDir. toPath(). resolve(' src' ). resolve(' main' ). resolve(' java' )
137143 into inputProjectPath
@@ -141,44 +147,55 @@ tasks.register('copySources') {
141147 into inputProjectPath
142148 }
143149 }
150+ println (" ${ Duration.between(start, Instant.now())} " )
151+ start = Instant . now()
144152
145153 // Transform code.
146154 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
150158
151159 javaexec {
152160 classpath = files(sourceSets. jakartaTransformer. compileClasspath)
153161 mainClass = " org.eclipse.transformer.cli.TransformerCLI"
154162 args = [
155163 inputProjectPath,
156- outputProjectPath ,
164+ transformedSourceDir ,
157165 ' -tr' , propFilePath,
158166 ]
159167 }
168+ println (" ${ Duration.between(start, Instant.now())} " )
169+ start = Instant . now()
170+
171+ delete allSourceDir
160172
161- def allSourcePath = layout. buildDirectory. dir(" all-source" ). get()
162- delete allSourcePath
163- // Copy dep jars.
173+ println (" copy dep jars => ${ allSourceDir} " )
164174 sourceSets. gwtSource. compileClasspath. files. forEach {zipFile ->
165- println (' copy: ' + zipFile)
175+ println (' ' + zipFile)
166176 copy {
167177 from zipTree(zipFile)
168- into allSourcePath
178+ into allSourceDir
169179 }
170180 }
181+ println (" ${ Duration.between(start, Instant.now())} " )
182+ start = Instant . now()
183+
184+ println (" copy ${ transformedSourceDir} => ${ allSourceDir} " )
171185 copy {
172- from outputProjectPath
173- into allSourcePath
186+ from transformedSourceDir
187+ into allSourceDir
174188 }
189+ println (" ${ Duration.between(start, Instant.now())} " )
175190 }
176191}
177192
178193tasks. register(' compileSources' , JavaCompile ) {
179194 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()
182199
183200 source = file(sources)
184201 destinationDirectory. set(file(build))
@@ -193,40 +210,62 @@ tasks.register('makeGwtSourceDirs') {
193210 group " gwt"
194211
195212 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
198221
199- println " copy ${ gwtSourceDirs.size()} gwtSourceDirs"
200- delete rsyncInput
222+ println (" copy ${ allSourceDir} => ${ rsyncInputDir} " )
201223 copy {
202- from layout . buildDirectory . dir( " all-source " ) . get()
203- into rsyncInput;
224+ from allSourceDir
225+ into rsyncInputDir
204226 }
227+
228+ println (" ${ Duration.between(start, Instant.now())} " )
229+ start = Instant . now()
230+
231+ println (" copy ${ transformedBuildDir} => ${ rsyncInputDir} " )
205232 copy {
206- from layout . buildDirectory . dir( " transformed-build " ) . get()
207- into rsyncInput;
233+ from transformedBuildDir
234+ into rsyncInputDir
208235 }
209236
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} "
211244 exec {
212245 executable = ' rsync'
213- args = [" --recursive" , " --checksum" , " --delete" , rsyncInput. toString() + " /" , rsyncOutput]
246+ args = [
247+ " --recursive" ,
248+ " --checksum" ,
249+ " --delete" ,
250+ " --stats" ,
251+ rsyncInputDir + " /" ,
252+ rsyncOutputDir]
214253 }
215254
255+ println (" ${ Duration.between(start, Instant.now())} " )
256+ start = Instant . now()
216257
258+ // Now assemble the sourceDirs array for GWT to compile
217259 gwtSourceDirs = []
218-
219260 // Add all of the library sources from the gwtSource source set defined above.
220261 gwtSourceDirs. addAll(sourceSets. gwtDevSource. compileClasspath)
221262 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)
226265
227266 println " Dumping ${ gwtSourceDirs.size()} gwtSourceDirs"
228267 gwtSourceDirs. each {
229- println " ${ it.toString()} "
268+ println " ${ it.toString()} "
230269 }
231270 }
232271}
@@ -263,7 +302,6 @@ tasks.register('gwtCompile', JavaExec) {
263302 // gwtSourceDirs.each {
264303 // println "${it.toString()}"
265304 // }
266- logger. info(' modifiedProjectsBasePath: ' + modifiedProjectsBasePath)
267305
268306 gwtSourceDirs. each {
269307 if (it instanceof java.nio.file.Path && Files . exists(it)) {
@@ -436,14 +474,8 @@ tasks.register('gwtClean') {
436474// println 'Deleting GWT unit cache: ' + unitCacheDir.toString()
437475// delete unitCacheDir
438476
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())
442478 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
447479
448480 logger. info(" Ensuring directory gwtBuildDir ${ gwtBuildDir} " )
449481 new File (gwtBuildDir). mkdirs()
0 commit comments