Skip to content

Commit a8e45be

Browse files
authored
Fix Gradle remote build cache relocatability (#7999)
* build: make cacheable test inputs relocatable * Disabled caching for all test tasks, ecept for :test, as they have utputs.upToDateWhen { false } configured, which effectively disabled caching anyway * build: fix missing task dependencies causing cache disabled for correctness - Add sourcesJar.dependsOn(generateGrammarSource) in geode-core so the sourcesJar task declares its dependency on antlr-generated sources. - Replace taskGraph.whenReady combineReports wiring with eager subprojects configuration so Gradle sees the dependency declarations during configuration phase instead of after task graph finalization. * build: use mustRunAfter instead of dependsOn for combineReports dependsOn forces all test tasks to execute when combineReports runs. The original whenReady wiring never triggered tasks because the graph was already sealed. mustRunAfter preserves ordering without forcing execution. * build: revert eager combineReports wiring, fix geode-old-versions only reportOn creates implicit file dependencies that trigger all test tasks. Revert to original whenReady block and instead add the missing finalizedBy/mustRunAfter wiring in geode-old-versions, which is the only project that lacks it since it doesn't apply geode-test.gradle. * build: exclude geode-old-versions version dirs from rat task inputs The version subdirectories (1.10.0, 1.11.0, etc.) are empty Gradle project directories with no source files. Gradle creates them during the build, so their presence differs between clean builds in different locations, causing a rat task cache miss. * build: clean geode-old-versions subproject dirs to fix rat cache miss The version subdirectories (1.10.0, 1.11.0, etc.) are not in git but get created during the build as Gradle project directories. On subsequent clean builds from the same location, these dirs persist after clean and cause rat task input fingerprint mismatches. Add a deleteOldGeodeVersions task finalized by clean to remove them.
1 parent 37f72de commit a8e45be

6 files changed

Lines changed: 16 additions & 5 deletions

File tree

build-tools/scripts/src/main/groovy/geode-test.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ configure([integrationTest, distributedTest, performanceTest, acceptanceTest, ui
9191
TestPropertiesWriter.writeTestProperties(buildDir, name)
9292
}
9393
outputs.upToDateWhen { false }
94+
outputs.doNotCacheIf("Forced rerun") { true }
9495
}
9596

9697
if (project.hasProperty("forceTest")) {
9798
// All test facets already force rerun. Only :test can be upToDate.
9899
test {
99100
outputs.upToDateWhen { false }
101+
outputs.doNotCacheIf("Forced rerun") { true }
100102
}
101103
}
102104

@@ -148,6 +150,7 @@ configure([repeatDistributedTest, repeatIntegrationTest, repeatUpgradeTest, repe
148150
testFramework.options.excludeTags += "org.apache.geode.test.junit.categories.IgnoreInRepeatTestTasks"
149151

150152
outputs.upToDateWhen { false }
153+
outputs.doNotCacheIf("Forced rerun") { true }
151154

152155
if (project.hasProperty("failOnNoMatchingTests")) {
153156
filter {

build-tools/scripts/src/main/groovy/jmh.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
jmh {
3636
zip64 = true
3737
duplicateClassesStrategy = 'exclude'
38-
jvmArgs += ['-javaagent:' + configurations.javaagent.singleFile]
38+
jvmArgs += ["-javaagent:${project.relativePath(configurations.javaagent.singleFile)}"]
3939

4040
include = project.hasProperty('jmh.include') ? project.property('jmh.include').tokenize() : ['.*']
4141
profilers = project.hasProperty('jmh.profilers') ? project.property('jmh.profilers').tokenize() : []
@@ -69,4 +69,3 @@ jmhTest {
6969
configurations {
7070
jmhTestRuntimeOnly.extendsFrom(jmhRuntimeOnly)
7171
}
72-

geode-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ dependencies {
438438
}
439439

440440
tasks.eclipse.dependsOn(generateGrammarSource)
441+
sourcesJar.dependsOn(generateGrammarSource)
441442

442443
distributedTest {
443444
// Some tests have inner tests that should be ignored

geode-jmh/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ jar {
4343

4444
test {
4545
jvmArgs += [
46-
'-javaagent:' + jar.outputs.files.singleFile
46+
"-javaagent:../libs/${jar.archiveFileName.get()}"
4747
]
4848
dependsOn jar
4949
}
5050

5151
repeatUnitTest {
5252
jvmArgs += [
53-
'-javaagent:' + jar.outputs.files.singleFile
53+
"-javaagent:../libs/${jar.archiveFileName.get()}"
5454
]
5555
dependsOn jar
5656
}

geode-old-versions/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,13 @@ tasks.register('createGeodeClasspathsFile') {
110110
}
111111
}
112112

113+
tasks.register('deleteOldGeodeVersions', Delete) {
114+
delete subprojects.collect { it.projectDir }
115+
}
116+
113117
tasks.named('clean') {
114118
dependsOn subprojects.collect { it.tasks.named('clean') }
119+
finalizedBy deleteOldGeodeVersions
115120
}
116121

117122
project.createGeodeClasspathsFile.mustRunAfter(clean)
@@ -141,3 +146,6 @@ tasks.register('geodeOldVersionClasspathsJar', Jar) {
141146
artifacts {
142147
classpathsOutput tasks.named('geodeOldVersionClasspathsJar')
143148
}
149+
150+
test.finalizedBy rootProject.tasks.combineReports
151+
rootProject.tasks.combineReports.mustRunAfter test

geode-server-all/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jar {
7575
].each {
7676
tasks.named(it).configure {
7777
systemProperty 'test.buildVersion', version
78-
systemProperty 'test.buildDirectory', buildDir
78+
systemProperty 'test.buildDirectory', '..'
7979
dependsOn(tasks.named('jar'))
8080
}
8181
}

0 commit comments

Comments
 (0)