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.
This commit is contained in:
Bartek Pacia 2025-02-04 03:28:35 +01:00 committed by GitHub
parent 052be9c41a
commit 015cfa88d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -186,13 +186,15 @@ class FlutterPlugin implements Plugin<Project> {
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")
}
}
}
}