Skip to content

Commit b8cd39b

Browse files
Address review: clarify the variant gate and task registration comments
Explain why library variants skip the command-line gate, drop the application/library list from the assets comment, drop the 'public variant API' clause, and say what library variants lack in configureApplicationOutputs.
1 parent a6be160 commit b8cd39b

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

‎packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,11 @@ class FlutterPlugin : Plugin<Project> {
467467
* tracked by https://github.com/flutter/flutter/issues/109560, which also documents the
468468
* AGP behavior that made it necessary.
469469
*
470-
* Library (add-to-app module) variants are never gated: the command line names a host
471-
* task, and `matchingFallbacks` can map it to a module variant of any name. The tasks are
472-
* registered lazily, so only the module variant the host consumes runs.
470+
* Library variants (an add-to-app module) skip this check. The command line names a host
471+
* task such as `:app:assembleDemoStaging`, and the host's `matchingFallbacks` pick the
472+
* module variant it consumes, so the task name can't identify that variant. Registering
473+
* every library variant is safe because registration is lazy: Gradle only runs the module
474+
* tasks that the host build depends on.
473475
*/
474476
private fun shouldCompileFlutterForVariant(
475477
project: Project,
@@ -512,8 +514,7 @@ class FlutterPlugin : Plugin<Project> {
512514
)
513515
)
514516
}
515-
// The assets source set is expected to exist for application and library variants;
516-
// fail loudly rather than silently building an APK or AAR without Flutter assets.
517+
// Fail at configuration rather than silently build an APK or AAR without Flutter assets.
517518
val assetSources =
518519
variant.sources.assets
519520
?: throw GradleException(
@@ -558,10 +559,7 @@ class FlutterPlugin : Plugin<Project> {
558559
)
559560
}
560561

561-
/**
562-
* Registers the [FlutterTask] (the `flutter assemble` invocation) for [variant],
563-
* configured entirely from the public variant API.
564-
*/
562+
/** Registers the [FlutterTask] (the `flutter assemble` invocation) for [variant]. */
565563
private fun registerFlutterCompileTask(
566564
project: Project,
567565
variant: Variant,
@@ -643,8 +641,8 @@ class FlutterPlugin : Plugin<Project> {
643641
}
644642

645643
/**
646-
* Per-ABI versionCodes and the copy into `build/outputs/flutter-apk/`. Library variants
647-
* produce an AAR, so they need neither.
644+
* Configures the per-ABI versionCodes and the copy into `build/outputs/flutter-apk/`. Both
645+
* act on APK outputs, which library variants don't have.
648646
*/
649647
private fun configureApplicationOutputs(
650648
project: Project,

0 commit comments

Comments
 (0)