Skip to content

Commit aabb5de

Browse files
ci: pass only the mirror init script to Gradle functional tests (#27550) (CP: 25.2) (#27557)
This PR cherry-picks changes from the original PR #27550 to branch 25.2. The original commit conflicts on 25.2, so this PR picks the 25.3 pick #27556 instead, which already adapted the change to an older branch. > [!WARNING] > The conflicts of the 25.3 pick #27556 were resolved automatically by Claude Code, and this pick builds on them. Please review the changes carefully. --- > Follow-up to #27463 > > **build failure** · flow-gradle-plugin · Gradle functional tests on TeamCity > > The Gradle functional tests that use the configuration cache fail on TeamCity since #27463 (13 tests). The nested test builds were given every init script of the outer build, including the TeamCity runner's own script, which registers build listeners. The configuration cache does not allow those, so the nested builds fail before they start. > > **Risks:** > - ✅ No product code changes: only the Gradle plugin's test harness. > > **Context.** The functional tests run nested builds through TestKit, which uses a Gradle user home of its own, so #27463 passed the outer build's init scripts on to them for the Maven Central mirror. On TeamCity the outer build also gets `/opt/agent/plugins/gradle-runner/scripts/init.gradle`, which calls `Gradle.addListener` and `Gradle.useLogger`. > > - The `functionalTest` task now passes on only `central-mirror.init.gradle`, and drops any other init script of the outer build. > - Without that script, local runs behave as before. > Co-authored-by: Marco Collovati <marco@vaadin.com>
1 parent 9cfa23f commit aabb5de

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎.github/gradle/central-mirror.init.gradle‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
// a 404, so plugins that only the portal hosts still resolve.
1919
//
2020
// The Gradle steps in validation.yml and warm-caches.yml pass it with
21-
// --init-script. The functionalTest task hands the init scripts of the outer
22-
// build on to the nested TestKit builds, which run under a Gradle user home of
23-
// their own and so would not see a script in ~/.gradle/init.d.
21+
// --init-script. The functionalTest task in flow-gradle-plugin/build.gradle
22+
// hands this script on to the nested TestKit builds, which run under a Gradle
23+
// user home of their own and so would not see a script in ~/.gradle/init.d.
24+
// It finds the script among the outer build's init scripts by its file name,
25+
// so a rename has to be made there too: otherwise the nested builds go to
26+
// Central directly again and fail with 429 on GitHub-hosted runners.
2427

2528
def centralHost = 'repo.maven.apache.org'
2629
def centralMirror = 'https://maven-central.storage-download.googleapis.com/maven2/'

‎flow-plugins/flow-gradle-plugin/build.gradle‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,15 @@ task functionalTest(type: Test) {
137137
// project version.
138138
environment('vaadin.version', version.toString())
139139
// The nested builds run under a Gradle user home of their own, so an init
140-
// script in ~/.gradle/init.d does not reach them. Hand them the ones this
141-
// build was started with instead, see TestProject.
140+
// script in ~/.gradle/init.d does not reach them. Hand them the Maven
141+
// Central mirror script if this build was started with it, see
142+
// TestProject. Only that one: other init scripts, such as the one the
143+
// TeamCity Gradle runner adds, register build listeners, which makes the
144+
// nested builds that use the configuration cache fail.
142145
systemProperty('functionalTest.initScripts',
143-
gradle.startParameter.initScripts*.absolutePath.join(File.pathSeparator))
146+
gradle.startParameter.initScripts
147+
.findAll { it.name == 'central-mirror.init.gradle' }
148+
*.absolutePath.join(File.pathSeparator))
144149
testLogging {
145150
exceptionFormat = 'full'
146151
showStandardStreams = true

‎flow-plugins/flow-gradle-plugin/src/functionalTest/kotlin/com/vaadin/gradle/TestUtils.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ class TestProject(val gradleVersion: String = FlowPlugin.GRADLE_MINIMUM_SUPPORTE
254254
.withGradleVersion(gradleVersion)
255255

256256
/**
257-
* The `--init-script` arguments for the init scripts the outer build was
258-
* started with, which the `functionalTest` task passes on. CI uses one to
259-
* read Maven Central through a mirror.
257+
* The `--init-script` argument for the Maven Central mirror init script,
258+
* which the `functionalTest` task passes on when the outer build was
259+
* started with it. CI uses it to read Maven Central through a mirror.
260260
*/
261261
private val initScriptArgs: List<String> =
262262
(System.getProperty("functionalTest.initScripts") ?: "")

0 commit comments

Comments
 (0)