mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
flutter build aar should also build plugins as AARs (#43994)
This commit is contained in:
parent
f1186b0758
commit
ee032f67c7
@ -42,7 +42,7 @@ Future<void> main() async {
|
|||||||
String content = pubspec.readAsStringSync();
|
String content = pubspec.readAsStringSync();
|
||||||
content = content.replaceFirst(
|
content = content.replaceFirst(
|
||||||
'\ndependencies:\n',
|
'\ndependencies:\n',
|
||||||
'\ndependencies:\n device_info:\n package_info:\n',
|
'\ndependencies:\n device_info: 0.4.1\n package_info: 0.4.0+9\n',
|
||||||
);
|
);
|
||||||
pubspec.writeAsStringSync(content, flush: true);
|
pubspec.writeAsStringSync(content, flush: true);
|
||||||
await inDirectory(projectDir, () async {
|
await inDirectory(projectDir, () async {
|
||||||
@ -69,6 +69,8 @@ Future<void> main() async {
|
|||||||
'repo',
|
'repo',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
section('Check release Maven artifacts');
|
||||||
|
|
||||||
checkFileExists(path.join(
|
checkFileExists(path.join(
|
||||||
repoPath,
|
repoPath,
|
||||||
'io',
|
'io',
|
||||||
@ -93,12 +95,59 @@ Future<void> main() async {
|
|||||||
|
|
||||||
checkFileExists(releasePom);
|
checkFileExists(releasePom);
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'deviceinfo',
|
||||||
|
'device_info_release',
|
||||||
|
'1.0',
|
||||||
|
'device_info_release-1.0.aar',
|
||||||
|
));
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'deviceinfo',
|
||||||
|
'device_info_release',
|
||||||
|
'1.0',
|
||||||
|
'device_info_release-1.0.pom',
|
||||||
|
));
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'packageinfo',
|
||||||
|
'package_info_release',
|
||||||
|
'1.0',
|
||||||
|
'package_info_release-1.0.aar',
|
||||||
|
));
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'packageinfo',
|
||||||
|
'package_info_release',
|
||||||
|
'1.0',
|
||||||
|
'package_info_release-1.0.pom',
|
||||||
|
));
|
||||||
|
|
||||||
section('Check AOT blobs in release POM');
|
section('Check AOT blobs in release POM');
|
||||||
|
|
||||||
checkFileContains(<String>[
|
checkFileContains(<String>[
|
||||||
'flutter_embedding_release',
|
'flutter_embedding_release',
|
||||||
'armeabi_v7a_release',
|
'armeabi_v7a_release',
|
||||||
'arm64_v8a_release',
|
'arm64_v8a_release',
|
||||||
|
'x86_64_release',
|
||||||
|
'package_info_release',
|
||||||
|
'device_info_release',
|
||||||
], releasePom);
|
], releasePom);
|
||||||
|
|
||||||
section('Check assets in release AAR');
|
section('Check assets in release AAR');
|
||||||
@ -109,6 +158,7 @@ Future<void> main() async {
|
|||||||
// AOT snapshots
|
// AOT snapshots
|
||||||
'jni/arm64-v8a/libapp.so',
|
'jni/arm64-v8a/libapp.so',
|
||||||
'jni/armeabi-v7a/libapp.so',
|
'jni/armeabi-v7a/libapp.so',
|
||||||
|
'jni/x86_64/libapp.so',
|
||||||
],
|
],
|
||||||
await getFilesInAar(
|
await getFilesInAar(
|
||||||
path.join(
|
path.join(
|
||||||
@ -133,6 +183,8 @@ Future<void> main() async {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
section('Check debug Maven artifacts');
|
||||||
|
|
||||||
checkFileExists(path.join(
|
checkFileExists(path.join(
|
||||||
repoPath,
|
repoPath,
|
||||||
'io',
|
'io',
|
||||||
@ -157,6 +209,50 @@ Future<void> main() async {
|
|||||||
|
|
||||||
checkFileExists(debugPom);
|
checkFileExists(debugPom);
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'deviceinfo',
|
||||||
|
'device_info_debug',
|
||||||
|
'1.0',
|
||||||
|
'device_info_debug-1.0.aar',
|
||||||
|
));
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'deviceinfo',
|
||||||
|
'device_info_debug',
|
||||||
|
'1.0',
|
||||||
|
'device_info_debug-1.0.pom',
|
||||||
|
));
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'packageinfo',
|
||||||
|
'package_info_debug',
|
||||||
|
'1.0',
|
||||||
|
'package_info_debug-1.0.aar',
|
||||||
|
));
|
||||||
|
|
||||||
|
checkFileExists(path.join(
|
||||||
|
repoPath,
|
||||||
|
'io',
|
||||||
|
'flutter',
|
||||||
|
'plugins',
|
||||||
|
'packageinfo',
|
||||||
|
'package_info_debug',
|
||||||
|
'1.0',
|
||||||
|
'package_info_debug-1.0.pom',
|
||||||
|
));
|
||||||
|
|
||||||
section('Check AOT blobs in debug POM');
|
section('Check AOT blobs in debug POM');
|
||||||
|
|
||||||
checkFileContains(<String>[
|
checkFileContains(<String>[
|
||||||
@ -165,6 +261,8 @@ Future<void> main() async {
|
|||||||
'x86_64_debug',
|
'x86_64_debug',
|
||||||
'armeabi_v7a_debug',
|
'armeabi_v7a_debug',
|
||||||
'arm64_v8a_debug',
|
'arm64_v8a_debug',
|
||||||
|
'package_info_debug',
|
||||||
|
'device_info_debug',
|
||||||
], debugPom);
|
], debugPom);
|
||||||
|
|
||||||
section('Check assets in debug AAR');
|
section('Check assets in debug AAR');
|
||||||
|
@ -79,7 +79,7 @@ String getFlutterRoot(Project project) {
|
|||||||
|
|
||||||
void addAarTask(Project project, variant) {
|
void addAarTask(Project project, variant) {
|
||||||
String variantName = variant.name.capitalize()
|
String variantName = variant.name.capitalize()
|
||||||
String taskName = "assembleAar${variantName}"
|
String taskName = "assembleAar$variantName"
|
||||||
project.tasks.create(name: taskName) {
|
project.tasks.create(name: taskName) {
|
||||||
// This check is required to be able to configure the archives before `uploadArchives` runs.
|
// This check is required to be able to configure the archives before `uploadArchives` runs.
|
||||||
if (!project.gradle.startParameter.taskNames.contains(taskName)) {
|
if (!project.gradle.startParameter.taskNames.contains(taskName)) {
|
||||||
@ -136,13 +136,32 @@ projectsEvaluated {
|
|||||||
assert rootProject.hasProperty("is-plugin")
|
assert rootProject.hasProperty("is-plugin")
|
||||||
if (rootProject.property("is-plugin").toBoolean()) {
|
if (rootProject.property("is-plugin").toBoolean()) {
|
||||||
assert rootProject.hasProperty("output-dir")
|
assert rootProject.hasProperty("output-dir")
|
||||||
// In plugin projects, the Android library is the root project.
|
// In plugin projects, the root project is the plugin.
|
||||||
configureProject(rootProject, rootProject.property("output-dir"))
|
configureProject(rootProject, rootProject.property("output-dir"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// In module projects, the Android library project is the `:flutter` subproject.
|
// The module project is the `:flutter` subproject.
|
||||||
Project androidLibraryProject = rootProject.subprojects.find { it.name == "flutter" }
|
Project moduleProject = rootProject.subprojects.find { it.name == "flutter" }
|
||||||
assert androidLibraryProject != null
|
assert moduleProject != null
|
||||||
assert androidLibraryProject.hasProperty("output-dir")
|
assert moduleProject.hasProperty("output-dir")
|
||||||
configureProject(androidLibraryProject, androidLibraryProject.property("output-dir"))
|
configureProject(moduleProject, moduleProject.property("output-dir"))
|
||||||
|
|
||||||
|
// Gets the plugin subprojects.
|
||||||
|
Set<Project> modulePlugins = rootProject.subprojects.findAll {
|
||||||
|
it.name != "flutter" && it.name != "app"
|
||||||
|
}
|
||||||
|
// When a module is built as a Maven artifacts, plugins must also be built this way
|
||||||
|
// because the module POM's file will include a dependency on the plugin Maven artifact.
|
||||||
|
// This is due to the Android Gradle Plugin expecting all library subprojects to be published
|
||||||
|
// as Maven artifacts.
|
||||||
|
modulePlugins.each { pluginProject ->
|
||||||
|
configureProject(pluginProject, moduleProject.property("output-dir"))
|
||||||
|
moduleProject.android.libraryVariants.all { variant ->
|
||||||
|
// Configure the `assembleAar<variantName>` task for each plugin's projects and make
|
||||||
|
// the module's equivalent task depend on the plugin's task.
|
||||||
|
String variantName = variant.name.capitalize()
|
||||||
|
moduleProject.tasks.findByPath("assembleAar$variantName")
|
||||||
|
.dependsOn(pluginProject.tasks.findByPath("assembleAar$variantName"))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,18 +264,9 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
if (useLocalEngine()) {
|
if (useLocalEngine()) {
|
||||||
throw new GradleException("Local engine isn't supported when building the plugins as AAR")
|
throw new GradleException("Local engine isn't supported when building the plugins as AAR")
|
||||||
}
|
}
|
||||||
List<Project> projects = [project]
|
project.repositories {
|
||||||
// Module projects set the `hostProjects` extra property in `include_flutter.groovy`.
|
maven {
|
||||||
// This is required to set the local repository in each host app project.
|
url "${getPluginBuildDir()}/outputs/repo"
|
||||||
if (project.ext.has("hostProjects")) {
|
|
||||||
projects.addAll(project.ext.get("hostProjects"))
|
|
||||||
}
|
|
||||||
// Configure the repository for the plugins.
|
|
||||||
projects.each { hostProject ->
|
|
||||||
hostProject.repositories {
|
|
||||||
maven {
|
|
||||||
url "${getPluginBuildDir()}/outputs/repo"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPluginList().each { pluginName, pluginPath ->
|
getPluginList().each { pluginName, pluginPath ->
|
||||||
|
@ -6,37 +6,24 @@ def flutterProjectRoot = new File(scriptFile).parentFile.parentFile
|
|||||||
gradle.include ':flutter'
|
gradle.include ':flutter'
|
||||||
gradle.project(':flutter').projectDir = new File(flutterProjectRoot, '.android/Flutter')
|
gradle.project(':flutter').projectDir = new File(flutterProjectRoot, '.android/Flutter')
|
||||||
|
|
||||||
if (System.getProperty('build-plugins-as-aars') != 'true') {
|
def plugins = new Properties()
|
||||||
def plugins = new Properties()
|
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
|
||||||
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
|
if (pluginsFile.exists()) {
|
||||||
if (pluginsFile.exists()) {
|
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
||||||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.each { name, path ->
|
|
||||||
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
|
|
||||||
gradle.include ":$name"
|
|
||||||
gradle.project(":$name").projectDir = pluginDirectory
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins.each { name, path ->
|
||||||
|
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
|
||||||
|
gradle.include ":$name"
|
||||||
|
gradle.project(":$name").projectDir = pluginDirectory
|
||||||
|
}
|
||||||
|
|
||||||
gradle.getGradle().projectsLoaded { g ->
|
gradle.getGradle().projectsLoaded { g ->
|
||||||
g.rootProject.beforeEvaluate { p ->
|
g.rootProject.beforeEvaluate { p ->
|
||||||
_mainModuleName = binding.variables['mainModuleName']
|
_mainModuleName = binding.variables['mainModuleName']
|
||||||
if (_mainModuleName != null && !_mainModuleName.empty) {
|
if (_mainModuleName != null && !_mainModuleName.empty) {
|
||||||
p.ext.mainModuleName = _mainModuleName
|
p.ext.mainModuleName = _mainModuleName
|
||||||
}
|
}
|
||||||
def subprojects = []
|
|
||||||
def flutterProject
|
|
||||||
p.subprojects { sp ->
|
|
||||||
if (sp.name == 'flutter') {
|
|
||||||
flutterProject = sp
|
|
||||||
} else {
|
|
||||||
subprojects.add(sp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert flutterProject != null
|
|
||||||
flutterProject.ext.hostProjects = subprojects
|
|
||||||
flutterProject.ext.pluginBuildDir = new File(flutterProjectRoot, 'build/host')
|
|
||||||
}
|
}
|
||||||
g.rootProject.afterEvaluate { p ->
|
g.rootProject.afterEvaluate { p ->
|
||||||
p.subprojects { sp ->
|
p.subprojects { sp ->
|
||||||
|
@ -6,37 +6,24 @@ def flutterProjectRoot = new File(scriptFile).parentFile.parentFile
|
|||||||
gradle.include ':flutter'
|
gradle.include ':flutter'
|
||||||
gradle.project(':flutter').projectDir = new File(flutterProjectRoot, '.android/Flutter')
|
gradle.project(':flutter').projectDir = new File(flutterProjectRoot, '.android/Flutter')
|
||||||
|
|
||||||
if (System.getProperty('build-plugins-as-aars') != 'true') {
|
def plugins = new Properties()
|
||||||
def plugins = new Properties()
|
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
|
||||||
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
|
if (pluginsFile.exists()) {
|
||||||
if (pluginsFile.exists()) {
|
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
||||||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.each { name, path ->
|
|
||||||
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
|
|
||||||
gradle.include ":$name"
|
|
||||||
gradle.project(":$name").projectDir = pluginDirectory
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins.each { name, path ->
|
||||||
|
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
|
||||||
|
gradle.include ":$name"
|
||||||
|
gradle.project(":$name").projectDir = pluginDirectory
|
||||||
|
}
|
||||||
|
|
||||||
gradle.getGradle().projectsLoaded { g ->
|
gradle.getGradle().projectsLoaded { g ->
|
||||||
g.rootProject.beforeEvaluate { p ->
|
g.rootProject.beforeEvaluate { p ->
|
||||||
_mainModuleName = binding.variables['mainModuleName']
|
_mainModuleName = binding.variables['mainModuleName']
|
||||||
if (_mainModuleName != null && !_mainModuleName.empty) {
|
if (_mainModuleName != null && !_mainModuleName.empty) {
|
||||||
p.ext.mainModuleName = _mainModuleName
|
p.ext.mainModuleName = _mainModuleName
|
||||||
}
|
}
|
||||||
def subprojects = []
|
|
||||||
def flutterProject
|
|
||||||
p.subprojects { sp ->
|
|
||||||
if (sp.name == 'flutter') {
|
|
||||||
flutterProject = sp
|
|
||||||
} else {
|
|
||||||
subprojects.add(sp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert flutterProject != null
|
|
||||||
flutterProject.ext.hostProjects = subprojects
|
|
||||||
flutterProject.ext.pluginBuildDir = new File(flutterProjectRoot, 'build/host')
|
|
||||||
}
|
}
|
||||||
g.rootProject.afterEvaluate { p ->
|
g.rootProject.afterEvaluate { p ->
|
||||||
p.subprojects { sp ->
|
p.subprojects { sp ->
|
||||||
|
Loading…
Reference in New Issue
Block a user