mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fix flutter build aar
for modules that use a plugin (#154757)
https://github.com/flutter/flutter/pull/151675 bumped module templates to AGP 8.1. In doing so, I tried to work around a behavior change [that was new in AGP 8.0](https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes): > AGP 8.0 creates no SoftwareComponent by default. Instead AGP creates SoftwareComponents only for variants that are configured to be published using the publishing DSL. by using AGP's publishing DSL to define which variants to publish in the module's ephemeral gradle files: ``` android.buildTypes.all {buildType -> if (!android.productFlavors.isEmpty()) { android.productFlavors.all{productFlavor -> android.publishing.singleVariant(productFlavor.name + buildType.name.capitalize()) { withSourcesJar() withJavadocJar() } } } else { android.publishing.singleVariant(buildType.name) { withSourcesJar() withJavadocJar() } } } ``` The problem is that this doesn't get applied to the plugin projects used by the module, so if a module uses any plugin it breaks. This PR fixes that by applying similar logic, but to each project (not just the module's project). Tested manually with https://github.com/gmackall/GrayAddToApp, and also re-enabled an old test that tested this use case as a part of the PR. Fixes: https://github.com/flutter/flutter/issues/154371
This commit is contained in:
parent
7e2de37336
commit
f964f15dcb
22
.ci.yaml
22
.ci.yaml
@ -424,6 +424,28 @@ targets:
|
||||
task_name: android_views
|
||||
timeout: 60
|
||||
|
||||
- name: Linux build_aar_module_test
|
||||
bringup: true
|
||||
recipe: devicelab/devicelab_drone
|
||||
timeout: 60
|
||||
properties:
|
||||
add_recipes_cq: "true"
|
||||
dependencies: >-
|
||||
[
|
||||
{"dependency": "android_sdk", "version": "version:34v3"},
|
||||
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"},
|
||||
{"dependency": "open_jdk", "version": "17"}
|
||||
]
|
||||
tags: >
|
||||
["devicelab","hostonly"]
|
||||
task_name: build_aar_module_test
|
||||
scheduler: luci
|
||||
runIf:
|
||||
- dev/**
|
||||
- packages/flutter_tools/**
|
||||
- bin/**
|
||||
- .ci.yaml
|
||||
|
||||
- name: Linux build_tests_1_5
|
||||
bringup: true
|
||||
recipe: flutter/flutter_drone
|
||||
|
@ -65,7 +65,6 @@ Future<void> main() async {
|
||||
' path: ../plugin_with_android$platformLineSep'
|
||||
' plugin_without_android:$platformLineSep'
|
||||
' path: ../plugin_without_android$platformLineSep'
|
||||
' webcrypto: 0.5.2$platformLineSep', // Plugin that uses NDK.
|
||||
);
|
||||
modulePubspec.writeAsStringSync(content, flush: true);
|
||||
|
||||
|
@ -116,6 +116,39 @@ allprojects {
|
||||
apply plugin: "maven-publish"
|
||||
}
|
||||
|
||||
afterProject { project ->
|
||||
// Exit early if either:
|
||||
// 1. The project doesn't have the Android Gradle plugin applied.
|
||||
// 2. The project has already defined which variants to publish (trying to re-define which
|
||||
// variants to publish will result in an error).
|
||||
if (!project.hasProperty("android")) {
|
||||
return
|
||||
}
|
||||
if (project.android.publishing.singleVariants.size() != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
Closure addSingleVariants = {buildType ->
|
||||
if (!project.android.productFlavors.isEmpty()) {
|
||||
project.android.productFlavors.all{productFlavor ->
|
||||
project.android.publishing.singleVariant(
|
||||
productFlavor.name + buildType.name.capitalize()
|
||||
) {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
project.android.publishing.singleVariant(buildType.name) {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.android.buildTypes.all(addSingleVariants)
|
||||
}
|
||||
|
||||
projectsEvaluated {
|
||||
assert rootProject.hasProperty("is-plugin")
|
||||
if (rootProject.property("is-plugin").toBoolean()) {
|
||||
|
@ -47,21 +47,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
android.buildTypes.all {buildType ->
|
||||
if (!android.productFlavors.isEmpty()) {
|
||||
android.productFlavors.all{productFlavor ->
|
||||
android.publishing.singleVariant(productFlavor.name + buildType.name.capitalize()) {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
android.publishing.singleVariant(buildType.name) {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
source = "../.."
|
||||
|
Loading…
Reference in New Issue
Block a user