Skip to content

Commit dce9106

Browse files
authored
Merge pull request #4811 from gchq/gradle_fixes2
Gradle fixes
2 parents 75f971b + f29c17a commit dce9106

File tree

10 files changed

+110
-99
lines changed

10 files changed

+110
-99
lines changed

Diff for: build.gradle

+11-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugins {
4545

4646
alias(libs.plugins.flyway) apply false
4747

48-
alias(libs.plugins.jdeps)
48+
// alias(libs.plugins.jdeps)
4949

5050
// id 'org.javamodularity.moduleplugin' apply false
5151

@@ -72,7 +72,7 @@ java {
7272
//if the project has a value for the passed property (i.e from the cmd line via -PpropName=xxx)
7373
//use that, else use a default value
7474
ext.getPropertyOrDefault = { propName, defaultValue ->
75-
def val;
75+
def val
7676
if (project.hasProperty(propName)
7777
&& project.getProperty(propName) != "unspecified"
7878
&& project.getProperty(propName) != "") {
@@ -82,7 +82,7 @@ ext.getPropertyOrDefault = { propName, defaultValue ->
8282
val = defaultValue
8383
logger.info("Property [$propName] has no value, using default value [$val]")
8484
}
85-
return val;
85+
return val
8686
}
8787

8888
// Try to determine the jdbc url from local.yml so that when using
@@ -99,7 +99,7 @@ if (localYamlFile.exists()) {
9999
if (yamlVal != null) {
100100
// Strip all the param substitution stuff
101101
yamlVal = yamlVal.replaceAll('^\\$\\{STROOM_JDBC_DRIVER_URL:-', '')
102-
.replaceAll('\\}$', '')
102+
.replaceAll('\\}$', '')
103103
ext.jdbcUrl = yamlVal
104104
// Extract the schema name from the url
105105
ext.dbSchema = (yamlVal =~ /jdbc:mysql:\/\/[^:]+:[0-9]+\/([^?]+)\?.*/)[0][1]
@@ -127,7 +127,7 @@ ext.gwtCompilerProps = [
127127
//version numbers for libs that share version numbers, e.g. dropwizard-*, or for github repo release versions
128128
ext.versions = [
129129
//----------Stroom-----------------
130-
stroom : getPropertyOrDefault('version', 'SNAPSHOT').replaceFirst(/^v/, ""),
130+
stroom: getPropertyOrDefault('version', 'SNAPSHOT').replaceFirst(/^v/, ""),
131131
]
132132

133133
// Defines the content packs that will be downloaded/copied for SetupSampleData,
@@ -293,7 +293,7 @@ subprojects {
293293
}
294294
}
295295

296-
reports.html.outputLocation = file("${reporting.baseDir}/${name}")
296+
reports.html.outputLocation = file("${reporting.baseDirectory.getAsFile().get()}/${name}")
297297

298298
afterSuite { descriptor, result ->
299299
if (descriptor != null
@@ -447,9 +447,9 @@ subprojects {
447447
}
448448
}
449449

450-
jdepsReport {
451-
multiRelease = '15'
452-
}
450+
// jdepsReport {
451+
// multiRelease = '15'
452+
// }
453453
}
454454

455455

@@ -491,8 +491,8 @@ subprojects {
491491
// config files in config/checkstyle
492492

493493
checkstyle {
494-
ignoreFailures false
495-
showViolations true
494+
ignoreFailures = false
495+
showViolations = true
496496
toolVersion = "10.4"
497497
}
498498

Diff for: gradlew

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ done
8686
# shellcheck disable=SC2034
8787
APP_BASE_NAME=${0##*/}
8888
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89-
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90-
' "$PWD" ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9190

9291
# Use the maximum available, or set MAX_FD != -1 to use that value.
9392
MAX_FD=maximum

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

+15-13
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,20 @@ dependencies {
8181
implementation libs.gwtp.mvp.client
8282
implementation libs.jackson.annotations
8383
implementation libs.jaxb.api.gwt
84-
implementation libs.swagger.annotations // needed so gwt can compile the stroom-query code that contains swagger annotations
84+
// needed so gwt can compile the stroom-query code that contains swagger annotations
85+
implementation libs.swagger.annotations
8586
implementation libs.ws.rs.api.gwt
8687

8788
gwtSourceImplementation libs.gin
8889
gwtSourceImplementation libs.gwt.user
8990
gwtSourceImplementation libs.gwtp.mvp.client
9091
gwtSourceImplementation libs.jaxb.api.gwt
91-
gwtSourceImplementation libs.swagger.annotations // needed so gwt can compile the stroom-query code that contains swagger annotations
92+
// needed so gwt can compile the stroom-query code that contains swagger annotations
93+
gwtSourceImplementation libs.swagger.annotations
9294
gwtSourceImplementation libs.restygwt
9395
gwtSourceImplementation libs.ws.rs.api.gwt
9496

97+
gwtDevSourceImplementation project(':stroom-gwt')
9598
gwtDevSourceImplementation libs.gwt.dev
9699

97100
jakartaTransformerImplementation libs.eclipse.transformer.cli
@@ -151,22 +154,22 @@ tasks.register('copySources') {
151154
println(' output: ' + transformedSourceDir)
152155
delete transformedSourceDir
153156

154-
javaexec {
157+
providers.javaexec {
155158
classpath = files(sourceSets.jakartaTransformer.compileClasspath)
156159
mainClass = "org.eclipse.transformer.cli.TransformerCLI"
157160
args = [
158161
inputProjectPath,
159162
transformedSourceDir,
160163
'-tr', propFilePath,
161164
]
162-
}
165+
}.result.get()
163166
println("${Duration.between(start, Instant.now())}")
164167
start = Instant.now()
165168

166169
delete allSourceDir
167170

168171
println("copy dep jars => ${allSourceDir}")
169-
sourceSets.gwtSource.compileClasspath.files.forEach {zipFile ->
172+
sourceSets.gwtSource.compileClasspath.files.forEach { zipFile ->
170173
println(' ' + zipFile)
171174
copy {
172175
from zipTree(zipFile)
@@ -202,7 +205,7 @@ tasks.register('compileSources', JavaCompile) {
202205

203206
tasks.register('makeGwtSourceDirs') {
204207
dependsOn compileSources
205-
group "gwt"
208+
group = "gwt"
206209

207210
doLast {
208211
def rsyncInputDir = "${gwtBuildDir}/rsync-input"
@@ -237,7 +240,7 @@ tasks.register('makeGwtSourceDirs') {
237240
// which it doesn't like. Rsync should only change the files that have actually changed
238241
// i.e. when doing superdev code changes.
239242
println "rsync ${rsyncInputDir} => ${rsyncOutputDir}"
240-
exec {
243+
providers.exec {
241244
executable = 'rsync'
242245
args = [
243246
"--recursive",
@@ -246,7 +249,7 @@ tasks.register('makeGwtSourceDirs') {
246249
"--stats",
247250
rsyncInputDir + "/",
248251
rsyncOutputDir]
249-
}
252+
}.result.get()
250253

251254
println("${Duration.between(start, Instant.now())}")
252255
start = Instant.now()
@@ -255,7 +258,6 @@ tasks.register('makeGwtSourceDirs') {
255258
gwtSourceDirs = []
256259
// Add all of the library sources from the gwtSource source set defined above.
257260
gwtSourceDirs.addAll(sourceSets.gwtDevSource.compileClasspath)
258-
gwtSourceDirs.addAll(project(':stroom-gwt').sourceSets.main.output.classesDirs)
259261
// Add the rsync clone of our transformed build
260262
gwtSourceDirs.add(rsyncOutputDir)
261263

@@ -268,7 +270,7 @@ tasks.register('makeGwtSourceDirs') {
268270

269271
tasks.register('gwtCompile', JavaExec) {
270272
dependsOn classes
271-
group "gwt"
273+
group = "gwt"
272274
dependsOn 'makeGwtSourceDirs'
273275

274276
def module = 'stroom.app.App'
@@ -340,7 +342,7 @@ tasks.register('gwtCompile', JavaExec) {
340342

341343
tasks.register('gwtDraftCompile', JavaExec) {
342344
dependsOn classes
343-
group "gwt"
345+
group = "gwt"
344346
dependsOn 'makeGwtSourceDirs'
345347

346348
def module = 'stroom.app.AppSuperDevModeChrome'
@@ -403,7 +405,7 @@ tasks.register('gwtDraftCompile', JavaExec) {
403405

404406
tasks.register('gwtSuperDevMode', JavaExec) {
405407
dependsOn classes
406-
group "gwt"
408+
group = "gwt"
407409
dependsOn 'makeGwtSourceDirs'
408410

409411
def module = 'stroom.app.AppSuperDevModeChrome'
@@ -467,7 +469,7 @@ tasks.register('gwtSuperDevMode', JavaExec) {
467469
}
468470

469471
tasks.register('gwtClean') {
470-
group "gwt"
472+
group = "gwt"
471473
doLast {
472474
// println 'Deleting GWT unit cache: ' + unitCacheDir.toString()
473475
// delete unitCacheDir

Diff for: stroom-app/build.gradle

+22-31
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ ext.moduleName = 'stroom.app'
2929
def fatJarName = 'stroom-app-all.jar'
3030
def sendToStroomScriptVersion = 'send-to-stroom-v3.2.2-1'
3131
def releaseBuildDir = "${projectDir}/build/release"
32-
def configDefaultsFile = "${releaseBuildDir}/config/config-defaults.yml"
33-
def configSchemaFile = "${releaseBuildDir}/config/config-schema.yml"
3432
def stroomZipDistContentPacksDir = "${releaseBuildDir}/content_packs"
3533
def stroomDockerBuildDir = "${projectDir}/docker/build"
3634
def stroomDockerContentPacksDir = "${stroomDockerBuildDir}/content_packs"
3735

3836
apply plugin: 'application'
3937
apply plugin: 'com.gradleup.shadow'
4038
apply plugin: "io.swagger.core.v3.swagger-gradle-plugin"
41-
apply plugin: "java"
4239

43-
mainClassName = 'stroom.app.App'
40+
application {
41+
mainClass = 'stroom.app.App'
42+
}
4443

4544
dependencies {
4645
implementation project(':stroom-activity:stroom-activity-api')
@@ -378,7 +377,7 @@ shadowJar {
378377
dependsOn resolve
379378

380379
// Allows us to build fat jars with lots of files
381-
zip64 true
380+
zip64 = true
382381

383382
// Ensure we include the GWT and Rest generated resources.
384383
from './src/main/resources'
@@ -405,7 +404,7 @@ tasks.register('migrate', JavaExec) {
405404
dependsOn ':stroom-config:stroom-config-app:compileJava'
406405

407406
classpath = sourceSets.main.runtimeClasspath
408-
mainClass = mainClassName
407+
mainClass = application.mainClass.get()
409408
args 'migrate', '../local.yml'
410409
}
411410

@@ -633,15 +632,15 @@ tasks.register('copySupportingFiles', Copy) {
633632
into releaseBuildDir
634633

635634
doLast {
636-
exec {
635+
providers.exec {
637636
// Move the banner.txt into bin where it is expected
638637
commandLine 'mv', "${releaseBuildDir}/banner.txt", "${releaseBuildDir}/bin/banner.txt"
639-
}
638+
}.result.get()
640639
// This is a sym-link so it seems to go into the zip with +x perms
641640
// which we don't want
642-
//exec {
643-
//commandLine 'chmod', '644', "${releaseBuildDir}/config/config.yml"
644-
//}
641+
//providers.exec {
642+
// commandLine 'chmod', '644', "${releaseBuildDir}/config/config.yml"
643+
//}.result.get()
645644
}
646645
}
647646

@@ -674,10 +673,10 @@ tasks.register('downloadSendArgs', Download) {
674673
tasks.register('makeSendExecutable') {
675674
dependsOn downloadSend
676675
doLast {
677-
// The args script is sourced so doesn't need execute perms
678-
exec {
676+
providers.exec {
677+
// The args script is sourced so doesn't need execute perms
679678
commandLine 'chmod', '+x', "${releaseBuildDir}/bin/send_to_stroom.sh"
680-
}
679+
}.result.get()
681680
}
682681
}
683682

@@ -686,16 +685,6 @@ tasks.register('makeSendExecutable') {
686685
//into "${releaseBuildDir}/contentPacks"
687686
//}
688687

689-
// Create an example yaml config file from the compile-time defaults
690-
tasks.register('generateConfigDefaultsYamlFile', JavaExec) {
691-
dependsOn ':stroom-config:stroom-config-app:compileJava'
692-
dependsOn ':stroom-config:stroom-config-app:compileTestJava'
693-
694-
classpath = project(':stroom-config:stroom-config-app').sourceSets.test.runtimeClasspath
695-
mainClass = 'stroom.config.app.GenerateExpectedYaml'
696-
args = [configDefaultsFile, configSchemaFile]
697-
}
698-
699688
// Build the release distribution zip for stroom
700689
tasks.register('buildDistribution', Zip) {
701690

@@ -707,7 +696,7 @@ tasks.register('buildDistribution', Zip) {
707696
dependsOn makeSendExecutable
708697
dependsOn downloadStroomContentForZipDist
709698
dependsOn generateConfigFiles
710-
dependsOn generateConfigDefaultsYamlFile
699+
dependsOn ':stroom-config:stroom-config-app:generateConfigDefaultsYamlFile'
711700

712701
from releaseBuildDir
713702
}
@@ -717,12 +706,14 @@ tasks.register('buildDistribution', Zip) {
717706
def thisProject = project
718707
rootProject.subprojects { subProj ->
719708
//println "subProj ${subProj.name} project ${thisProject.name}"
720-
if (!subProj.name.equals(thisProject.name)) {
721-
subProj.tasks.withType(Test) { otherTestTask ->
722-
//println "subProj ${subProj}, task ${it.name} thisProject.tasks.test ${thisProject.tasks.test}"
723-
thisProject.tasks.test.mustRunAfter otherTestTask.path
724-
thisProject.tasks.jar.mustRunAfter otherTestTask.path
725-
thisProject.tasks.shadowJar.mustRunAfter otherTestTask.path
709+
if (subProj.name != thisProject.name) {
710+
subProj.tasks.withType(Test).tap {
711+
configureEach { otherTestTask ->
712+
//println "subProj ${subProj}, task ${it.name} thisProject.tasks.test ${thisProject.tasks.test}"
713+
thisProject.tasks.test.mustRunAfter otherTestTask.path
714+
thisProject.tasks.jar.mustRunAfter otherTestTask.path
715+
thisProject.tasks.shadowJar.mustRunAfter otherTestTask.path
716+
}
726717
}
727718
}
728719
}

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

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
ext.moduleName = 'stroom.config.app'
22

3+
def releaseBuildDir = "${projectDir}/../../stroom-app/build/release"
4+
def configDefaultsFile = "${releaseBuildDir}/config/config-defaults.yml"
5+
def configSchemaFile = "${releaseBuildDir}/config/config-schema.yml"
6+
37
dependencies {
48
implementation project(':stroom-activity:stroom-activity-impl-db')
59
implementation project(':stroom-analytics:stroom-analytics-impl')
@@ -90,3 +94,13 @@ dependencies {
9094
testRuntimeOnly libs.logback.classic
9195
testRuntimeOnly libs.logback.core
9296
}
97+
98+
// Create an example yaml config file from the compile-time defaults
99+
tasks.register('generateConfigDefaultsYamlFile', JavaExec) {
100+
dependsOn compileJava
101+
dependsOn compileTestJava
102+
103+
classpath = sourceSets.test.runtimeClasspath
104+
mainClass = 'stroom.config.app.GenerateExpectedYaml'
105+
args = [configDefaultsFile, configSchemaFile]
106+
}

0 commit comments

Comments
 (0)