Repository navigation
forceNdkDownload should skip configuring cmake when ndk-build is used - #187201
Merged
Merged
Conversation
…g cmake when ndk-build is used
- Clean up redundant mocks in forceNdkDownload skips projects which are already configuring an ndk-build test. - Use buildTypes.all instead of forEach in forceNdkDownload to ensure custom build types are also configured. - Fix test imports to avoid using Gradle internal JUnit classes. - Workaround Java 26 Mockk issue by using real File instead of mock File in forceNdkDownload sets externalNativeBuild properties test. TAG=agy CONV=13ed21bd-350e-40f7-b19f-850084267652
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Gradle plugin utilities to skip forcing Ndk downloads when an ndk-build path is already configured, and updates associated tests. It also refactors buildTypes.forEach to buildTypes.all in FlutterPluginUtils.kt and updates test assertions to use JUnit 5 and Kotlin test libraries. However, the refactoring to buildTypes.all will cause a compilation error because Kotlin SAM conversion treats the lambda as (BuildType) -> Unit rather than BuildType.() -> Unit, meaning this does not refer to the BuildType instance. You should explicitly declare the lambda parameter to resolve this.
…compilation - Replace buildTypes.all with buildTypes.configureEach to resolve compilation errors. In Kotlin, buildTypes.all (which resolves to Iterable.all) expects a Boolean return predicate, causing compilation failures with void methods. - configureEach properly leverages Kotlin's DSL receiver scope (BuildType.() -> Unit) and ensures configuration remains lazy and performant according to modern Gradle best practices. TAG=agy CONV=d492ea8e-4d8e-443f-b7c7-76f68efb5fc4
reidbaker
previously approved these changes
Jun 8, 2026
Contributor
|
It seems like some of the deeplink test changes are unrelated. |
gmackall
requested review from
a team and
gmackall
and removed request for
reidbaker
June 30, 2026 21:03
# Conflicts: # packages/flutter_tools/gradle/src/test/kotlin/FlutterPluginUtilsTest.kt
reidbaker
previously approved these changes
Jul 20, 2026
reidbaker
approved these changes
Jul 23, 2026
This was referenced Jul 24, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Jul 24, 2026
flutter/flutter@2a2a79d...b65f4d9 2026-07-24 jason-simmons@users.noreply.github.com Add dart_runtime_service_vm_aot.dart.snapshot to the snapshot list in the macOS code signing configuration (flutter/flutter#189981) 2026-07-24 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from wLST_A-xfOeGT_5mj... to E8hJ1AfK8CtGtaES0... (flutter/flutter#189956) 2026-07-23 chingjun@google.com Consolidate AndroidArch and DarwinArch into CpuArch (flutter/flutter#189315) 2026-07-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 9258584f98b8 to e3fc57eae9eb (7 revisions) (flutter/flutter#189949) 2026-07-23 jason-simmons@users.noreply.github.com [flutter_tools] Do not always wait for the full timeout when running Spotlight to locate Android Studio on macOS (flutter/flutter#189952) 2026-07-23 engine-flutter-autoroll@skia.org Roll Skia from 1d8bf9270d8c to 6e9c4687c001 (15 revisions) (flutter/flutter#189954) 2026-07-23 jason-simmons@users.noreply.github.com [flutter_tools] Initialize Cache.flutterRoot at the start of the upgrade_test suite (flutter/flutter#189937) 2026-07-23 faheemabbas766@gmail.com Parse AndroidX property in gradle.properties (flutter/flutter#188372) 2026-07-23 60122246+xiaowei-guan@users.noreply.github.com [Impeller]Use the IO context for OpenGL program setup (flutter/flutter#185723) 2026-07-23 43089218+chika3742@users.noreply.github.com Allow building projects lacking Runner.xcworkspace (flutter/flutter#186239) 2026-07-23 bkonyi@google.com [flutter_tools] Invalidate WebEntrypointTarget when plugin set changes (flutter/flutter#189460) 2026-07-23 srawlins@google.com Bump devtools_shared to 13.1.0 (flutter/flutter#189507) 2026-07-23 matt.boetger@gmail.com forceNdkDownload should skip configuring cmake when ndk-build is used (flutter/flutter#187201) 2026-07-23 jason-simmons@users.noreply.github.com Disable execution order shuffling for the flutter_tools upgrade_test suite (flutter/flutter#189920) 2026-07-23 matej.knopp@gmail.com Move WindowManager outside of WidgetsApp (flutter/flutter#188866) 2026-07-23 engine-flutter-autoroll@skia.org Roll Skia from 3424966b8a2b to 1d8bf9270d8c (3 revisions) (flutter/flutter#189901) 2026-07-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from GswhlPRO-D1qSNclx... to 9org0yL3yZkp80x5S... (flutter/flutter#189898) 2026-07-23 116356835+AbdeMohlbi@users.noreply.github.com Remove outdated logs that were added to track #172636 (flutter/flutter#189282) 2026-07-23 engine-flutter-autoroll@skia.org Roll Skia from 5e183e5aeac5 to 3424966b8a2b (33 revisions) (flutter/flutter#189890) 2026-07-23 srawlins@google.com [examples] Use super parameters in missed spots (flutter/flutter#186194) 2026-07-23 bkonyi@google.com [flutter_tools] Bound Spotlight mdfind execution with timeout on macOS (flutter/flutter#189461) 2026-07-23 codedoctor@linwood.dev Fix non primary buttons not being captured on windows (flutter/flutter#188394) 2026-07-22 matt.boetger@gmail.com Listen to log reader before VM Service and make delay configurable (flutter/flutter#187202) 2026-07-22 engine-flutter-autoroll@skia.org Roll Dart SDK from 1e65011ee004 to 9258584f98b8 (7 revisions) (flutter/flutter#189883) 2026-07-22 30870216+gaaclarke@users.noreply.github.com Adds skill for generating engine diffs for new releases. (flutter/flutter#189869) 2026-07-22 chris@bracken.jp [ios,macos] Add Swift Sourcekit LSP support (flutter/flutter#189761) 2026-07-22 chris@bracken.jp [iOS] Mark DisplayLinkManager.shared and init() @mainactor (flutter/flutter#189815) 2026-07-22 97480502+b-luk@users.noreply.github.com Fix `Rect::ExpandToMinTransformedSize` to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (flutter/flutter#189808) 2026-07-22 15619084+vashworth@users.noreply.github.com Skip emulator.getEmulators test (flutter/flutter#189879) 2026-07-22 codedoctor@linwood.dev Fix null terminator in input truncates clipboard (flutter/flutter#188652) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
10 tasks done
reidbaker
pushed a commit
to reidbaker-agent/flutter
that referenced
this pull request
Sep 1, 2026
… NDK fallback to public DSL This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). - Exposes `externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`, setting `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` via the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - Updates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), removes `import io.mockk.called` and all `com.android.build.gradle.internal.*` imports, asserts CMake arguments by list content, and deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference.
reidbaker
pushed a commit
to reidbaker-agent/flutter
that referenced
this pull request
Sep 1, 2026
… NDK fallback to public DSL This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). - Exposes `externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`, setting `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` via the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - Updates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), removes `import io.mockk.called` and all `com.android.build.gradle.internal.*` imports, asserts CMake arguments by list content, and deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference.
reidbaker
pushed a commit
to reidbaker-agent/flutter
that referenced
this pull request
Sep 1, 2026
… NDK fallback to public DSL This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). - Exposes `externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`, setting `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` via the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - Updates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), removes `import io.mockk.called` and all `com.android.build.gradle.internal.*` imports, asserts CMake arguments by list content, and deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference.
reidbaker
pushed a commit
to reidbaker-agent/flutter
that referenced
this pull request
Sep 1, 2026
… NDK fallback to public DSL This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). - Exposes `externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`, setting `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` via the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - Updates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), removes `import io.mockk.called` and all `com.android.build.gradle.internal.*` imports, asserts CMake arguments by list content, and deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference.
reidbaker
pushed a commit
to reidbaker-agent/flutter
that referenced
this pull request
Sep 1, 2026
… NDK fallback to public DSL This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). - Exposes `externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`, setting `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` via the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - Updates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), removes `import io.mockk.called` and all `com.android.build.gradle.internal.*` imports, asserts CMake arguments by list content, and deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference.
reidbaker
pushed a commit
to reidbaker-agent/flutter
that referenced
this pull request
Sep 1, 2026
… NDK fallback to public DSL This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). - Exposes `externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`, setting `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` via the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - Updates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), removes all `com.android.build.gradle.internal.*` imports, asserts CMake arguments by list content, and deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference.
bkonyi
pushed a commit
to bkonyi/flutter
that referenced
this pull request
Sep 4, 2026
… NDK fallback to public DSL (flutter#192116) This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` / newdsl migration stack. Add externalNativeBuild to the shared type. Extracted some shared mocking logic to a utility. No external visible changes expected. Also improved the README.md so that the test file for multiple agp versions was a markdown link. - @reidbaker --- Standard review context for this pr stack This is PR is part of an 11 pr stack to migrate the "newdsl" `gradle-api` specifically in agp 9.1.0. All of the code was LLM authored. A mix of manual prompting, automatic prompting, several models and adversarial review. The combined sessions are enough that I cannot include relevant prompts like I have been doing on other prs. If you want to review the pr stack you can find it here. These prs will be abandoned/closed as prs land into flutter/flutter. 1. reidbaker-agent#1 (branch: agp-api-doc) 2. reidbaker-agent#2 (branch: agp-internal-utils) 3. reidbaker-agent#3 (branch: agp-buildmode-deps) 4. reidbaker-agent#4 (branch: agp-plugin-buildtypes) 5. reidbaker-agent#5 (branch: agp-ndk-fallback) 6. reidbaker-agent#6 (branch: agp-assets-onvariants) 7. reidbaker-agent#7 (branch: agp-apk-copy-versioncode) 8. reidbaker-agent#8 (branch: agp-add-to-app) 9. reidbaker-agent#9 (branch: agp-aar-script) 10. reidbaker-agent#10 (branch: agp-newdsl-flip) 11. reidbaker-agent#11 (branch: agp-gradle-api) This work is urgent in the sense that we are worried that android will publish agp 10 with no opt out but not so urgent that we are willing to break flutter users because we didn't review or understand the code because we were in a rush. Breaking changes are expected as part of this work. There are patterns the android team explicitly does not want apps to use and apis that have no equivalent. As part of the effort to ensure this work does not slip into ai slop, prs from this stack will be reviewed by me (@reidbaker) before asking for review. Then we will have 2 android expert reviewers also review every pr. --- Agent authored description. This is PR 5 of 11 in the AGP 9.1.0 / public `gradle-api` migration stack (flutter#180137, flutter#166550). ### Key Changes - **Public DSL Wrapper `externalNativeBuild`**: Exposes `val externalNativeBuild: ExternalNativeBuild` in `AgpCommonExtensionWrapper.kt` dispatching across `ApplicationExtension`, `LibraryExtension`, `DynamicFeatureExtension`, and `TestExtension` without referencing `CommonExtension` (bypassing AGP binary incompatibility). - **Zero Legacy `BaseExtension` in Production Sources**: Deletes `getLegacyAndroidExtension(project: Project): BaseExtension` and removes the `com.android.build.gradle.BaseExtension` import from `FlutterPluginUtils.kt`. - **Public DSL NDK Fallback Configuration**: Migrates `forceNdkDownload` and `configureSyntheticExternalNativeBuildFallback` in `FlutterPluginUtils.kt` to `getAndroidExtension(gradleProject)` using `externalNativeBuild.cmake` / `externalNativeBuild.ndkBuild`. Sets `cmake.path = File(...)`, `cmake.buildStagingDirectory = ...`, and `buildType.externalNativeBuild.cmake.arguments += ...` through the public DSL while preserving the upstream PR flutter#187201 `ndkBuild.path` check. - **Unit Test Public DSL Mocking & Cleanup**: Migrates unit tests in `FlutterPluginUtilsTest.kt` to mock public DSL types (`ApplicationExtension`, `Cmake`, `NdkBuild`), asserts CMake arguments by list content, deletes obsolete tests asserting `ApplicationExtension`-vs-`BaseExtension` `ndkVersion` preference, and removes unused `import io.mockk.called` as well as all legacy `com.android.build.gradle.internal.*` imports. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #175968
Pre-launch Checklist
///).