From 015cfa88d4d592aa33d3cec6de1329cd06661d70 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 4 Feb 2025 03:28:35 +0100 Subject: [PATCH] Fix FGP's generateLockfiles task always executing its action at configuration time (#162220) ![drake](https://github.com/user-attachments/assets/50ffcda6-263d-48c8-8853-207e757da6e0) This PR attempts to fix #110559 This PR supersedes #147837 Original attempt at fixing this by @GaryQian: #112723 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --- .../gradle/src/main/groovy/flutter.groovy | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy index b4ec30052b..21a71e430f 100644 --- a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy +++ b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -186,13 +186,15 @@ class FlutterPlugin implements Plugin { Project rootProject = project.rootProject if (isFlutterAppProject()) { rootProject.tasks.register("generateLockfiles") { - rootProject.subprojects.each { subproject -> - String gradlew = (OperatingSystem.current().isWindows()) ? - "${rootProject.projectDir}/gradlew.bat" : "${rootProject.projectDir}/gradlew" - rootProject.exec { - workingDir(rootProject.projectDir) - executable(gradlew) - args(":${subproject.name}:dependencies", "--write-locks") + doLast { + rootProject.subprojects.each { subproject -> + String gradlew = (OperatingSystem.current().isWindows()) ? + "${rootProject.projectDir}/gradlew.bat" : "${rootProject.projectDir}/gradlew" + rootProject.exec { + workingDir(rootProject.projectDir) + executable(gradlew) + args(":${subproject.name}:dependencies", "--write-locks") + } } } }