Skip to content

Commit 94a2990

Browse files
Clarify aar_init_script comments from the adversarial review
- checkProjectsHaveRequestedVariants: a requested task that matches no project's variant is left to Gradle's task selector error. - aarComponents: describe what the filter returns. - addAarTask: state the effect of the requested-task guard, and drop the "all" note from the publication comment (the filter is in aarComponents).
1 parent da9646a commit 94a2990

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/flutter_tools/gradle/aar_init_script.gradle‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ static String getFlutterRoot(Project project) {
8282
return project.property("flutter-root")
8383
}
8484

85-
// The software components that AGP creates for `singleVariant` publishing. `addAarTask` registers
86-
// one `assembleAar<Variant>` task for each of them.
85+
// Every software component of the project except "all". AGP adds one component for each
86+
// `singleVariant` or `multipleVariants` publishing declaration, named after it. `addAarTask`
87+
// registers one `assembleAar<Variant>` task for each.
8788
static Collection<SoftwareComponent> aarComponents(Project project) {
8889
return project.components.findAll { it.name != "all" }
8990
}
@@ -101,12 +102,12 @@ void addAarTask(Project project, component) {
101102
finalizedBy "publish"
102103
}
103104

104-
// This check is required to be able to configure the archives before `publish` runs.
105+
// Only requested variants get a publication, so the `publish` finalizer publishes only those.
105106
if (!project.gradle.startParameter.taskNames.contains(taskName)) {
106107
return
107108
}
108109

109-
// Create a default MavenPublication for the variant (except "all" since that is used to publish artifacts in the new way)
110+
// Create a default MavenPublication for the variant.
110111
// This runs outside the task's configuration action because maven-publish registers tasks for
111112
// each publication, and Gradle doesn't allow registering tasks while it realizes a task.
112113
project.publishing.publications.create(component.name, MavenPublication) { pub ->
@@ -130,7 +131,9 @@ static boolean isDuplicateSingleVariantError(Exception e, String variantName) {
130131

131132
// Checks that the module and each Android plugin have every variant whose `assembleAar<Variant>`
132133
// task the tool requested. Returns normally if they do. Otherwise throws a GradleException that
133-
// names the variant and the first project without it.
134+
// names the variant and the first project without it. A requested task that matches no project's
135+
// variant (for example a misspelled `--flavor`) is left to Gradle, which fails with
136+
// `Task '<name>' not found in root project`.
134137
//
135138
// A project without the requested variant publishes no AAR, and the module's POM depends on each
136139
// plugin's AAR for the same variant name.

0 commit comments

Comments
 (0)