Skip to content

Commit a039550

Browse files
committed
Change gwt builds to use /tmp more
1 parent 9d3ad60 commit a039550

File tree

3 files changed

+105
-68
lines changed

3 files changed

+105
-68
lines changed

Diff for: build.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ ext.getPropertyOrDefault = { propName, defaultValue ->
7474
return val;
7575
}
7676

77+
// Convert the abs root project dir into a string that can be used as a dir
78+
// to allow us to have a dir for multiple repo instances that don't conflict
79+
// e.g. 'home+dev+git_work+gchq+stroom'
80+
ext.rootProjectAbsPathStr = project.rootProject.rootDir
81+
.toPath()
82+
.toAbsolutePath()
83+
.toString()
84+
.replaceAll("^/", "")
85+
.replaceAll("/", "+");
86+
7787
ext.gwtCompilerProps = [
7888
mainClass: 'stroom.gwt.GwtCompilerWrapper',
7989
minHeap : getPropertyOrDefault('gwtCompilerMinHeap', '50M'),

Diff for: stroom-app-gwt/build.gradle

+77-45
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import java.nio.file.Files
2+
import java.time.Duration
3+
import java.time.Instant
24

35
ext.moduleName = 'stroom.app.gwt'
46

@@ -23,7 +25,7 @@ def outputDir = "${warDir}/stroom"
2325
def javaIoTmpDir = getSysPropertyOrDefault("java.io.tmpdir", "/tmp")
2426
logger.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"
2729
gwtBuildDir = gwtBuildDir.replaceAll('//', '/')
2830
logger.info('gwtBuildDir: ' + gwtBuildDir)
2931

@@ -32,10 +34,12 @@ logger.info('gwtTmpDir: ' + gwtTmpDir)
3234
def workDir = "${gwtBuildDir}/work"
3335
def deployDir = "${gwtBuildDir}/deploy"
3436
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"
3943

4044
def 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

178193
tasks.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()

Diff for: stroom-dashboard-gwt/build.gradle

+18-23
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def outputDir = "${warDir}/dashboard"
2323
def javaIoTmpDir = getSysPropertyOrDefault("java.io.tmpdir", "/tmp")
2424
logger.info('javaIoTmpDir: ' + javaIoTmpDir)
2525
// Append the rootDir so gwt builds from different dirs don't conflict
26-
def gwtBuildDir = javaIoTmpDir + "/dashboard-gwt_build/" + rootDir
26+
def gwtBuildDir = "${javaIoTmpDir}/gwt/${rootProjectAbsPathStr}/dashboard-gwt_build"
2727
gwtBuildDir = gwtBuildDir.replaceAll('//', '/')
2828
logger.info('gwtBuildDir: ' + gwtBuildDir)
2929

@@ -32,10 +32,11 @@ logger.info('gwtTmpDir: ' + gwtTmpDir)
3232
def workDir = "${gwtBuildDir}/work"
3333
def deployDir = "${gwtBuildDir}/deploy"
3434
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"
35+
36+
def allSourceDir = "${gwtBuildDir}/all-source"
37+
def transformedSourceDir = "${gwtBuildDir}/transformed-source"
38+
def transformedBuildDir = "${gwtBuildDir}/transformed-build"
39+
def rsyncOutputDir = "${gwtBuildDir}/rsync-output"
3940

4041
def gwtSourceDirs = []
4142

@@ -119,8 +120,7 @@ tasks.register('copySources') {
119120
doLast {
120121
// This file has all the rename mappings for TransformerCLI to use
121122
def propFilePath = rootDir.toPath().resolve('jakarta-renames-reverse.properties')
122-
def inputProjectPath = layout.buildDirectory.dir("raw-source").get()
123-
def outputProjectPath = layout.buildDirectory.dir("transformed-source").get()
123+
def inputProjectPath = "${gwtBuildDir}/raw-source"
124124

125125
// Delete current source output.
126126
delete inputProjectPath
@@ -140,16 +140,16 @@ tasks.register('copySources') {
140140

141141
// Transform code.
142142
println 'Running eclipse TransformerCLI'
143-
println('inputProjectPath: ' + inputProjectPath)
144-
println('outputProjectPath: ' + outputProjectPath)
145-
delete outputProjectPath
143+
println(' input: ' + inputProjectPath)
144+
println(' outpu: ' + transformedSourceDir)
145+
delete transformedSourceDir
146146

147147
javaexec {
148148
classpath = files(sourceSets.jakartaTransformer.compileClasspath)
149149
mainClass = "org.eclipse.transformer.cli.TransformerCLI"
150150
args = [
151151
inputProjectPath,
152-
outputProjectPath,
152+
transformedSourceDir,
153153
'-tr', propFilePath,
154154
]
155155
}
@@ -158,8 +158,10 @@ tasks.register('copySources') {
158158

159159
tasks.register('compileSources', JavaCompile) {
160160
dependsOn copySources
161-
def sources = layout.buildDirectory.dir("transformed-source").get()
162-
def build = layout.buildDirectory.dir("transformed-build").get()
161+
def sources = transformedSourceDir
162+
new File(sources).mkdirs()
163+
def build = transformedBuildDir
164+
new File(build).mkdirs()
163165

164166
source = file(sources)
165167
destinationDirectory.set(file(build))
@@ -180,8 +182,8 @@ tasks.register('makeGwtSourceDirs') {
180182

181183
gwtSourceDirs.addAll(project(':stroom-gwt').sourceSets.main.output.classesDirs)
182184

183-
gwtSourceDirs.add(layout.buildDirectory.dir("transformed-source").get())
184-
gwtSourceDirs.add(layout.buildDirectory.dir("transformed-build").get())
185+
gwtSourceDirs.add(transformedSourceDir)
186+
gwtSourceDirs.add(transformedBuildDir)
185187

186188
println "Dumping ${gwtSourceDirs.size()} gwtSourceDirs"
187189
gwtSourceDirs.each {
@@ -222,7 +224,6 @@ tasks.register('gwtCompile', JavaExec) {
222224
//gwtSourceDirs.each {
223225
//println "${it.toString()}"
224226
//}
225-
logger.info('modifiedProjectsBasePath: ' + modifiedProjectsBasePath)
226227

227228
gwtSourceDirs.each {
228229
if (it instanceof java.nio.file.Path && Files.exists(it)) {
@@ -395,14 +396,8 @@ tasks.register('gwtClean') {
395396
// println 'Deleting GWT unit cache: ' + unitCacheDir.toString()
396397
// delete unitCacheDir
397398

398-
logger.info('Deleting GWT compiled output: ' + outputDir.toString())
399-
delete outputDir
400-
logger.info('Deleting GWT build dir: ' + gwtBuildDir.toString())
399+
logger.info('Deleting gwtBuildDir: ' + gwtBuildDir.toString())
401400
delete gwtBuildDir
402-
logger.info('Deleting modified projects: ' + modifiedProjectsBasePath.toString())
403-
delete modifiedProjectsBasePath
404-
logger.info('Deleting modified projects (GWT copy): ' + modifiedProjectsBasePathGwt.toString())
405-
delete modifiedProjectsBasePathGwt
406401

407402
logger.info("Ensuring directory gwtBuildDir ${gwtBuildDir}")
408403
new File(gwtBuildDir).mkdirs()

0 commit comments

Comments
 (0)