Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ee032f67
Unverified
Commit
ee032f67
authored
5 years ago
by
Emmanuel Garcia
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flutter build aar should also build plugins as AARs (#43994)
parent
f1186b07
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
66 deletions
+148
-66
build_aar_module_test.dart
dev/devicelab/bin/tasks/build_aar_module_test.dart
+99
-1
aar_init_script.gradle
packages/flutter_tools/gradle/aar_init_script.gradle
+26
-7
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+3
-12
include_flutter.groovy.copy.tmpl
...s/module/android/library/include_flutter.groovy.copy.tmpl
+10
-23
include_flutter.groovy.copy.tmpl
...id/library_new_embedding/include_flutter.groovy.copy.tmpl
+10
-23
No files found.
dev/devicelab/bin/tasks/build_aar_module_test.dart
View file @
ee032f67
...
@@ -42,7 +42,7 @@ Future<void> main() async {
...
@@ -42,7 +42,7 @@ Future<void> main() async {
String
content
=
pubspec
.
readAsStringSync
();
String
content
=
pubspec
.
readAsStringSync
();
content
=
content
.
replaceFirst
(
content
=
content
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
device_info:
\n
package_info:
\n
'
,
'
\n
dependencies:
\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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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'
);
...
...
This diff is collapsed.
Click to expand it.
packages/flutter_tools/gradle/aar_init_script.gradle
View file @
ee032f67
...
@@ -79,7 +79,7 @@ String getFlutterRoot(Project project) {
...
@@ -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 {
...
@@ -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"
))
}
}
}
}
This diff is collapsed.
Click to expand it.
packages/flutter_tools/gradle/flutter.gradle
View file @
ee032f67
...
@@ -264,18 +264,9 @@ class FlutterPlugin implements Plugin<Project> {
...
@@ -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
->
...
...
This diff is collapsed.
Click to expand it.
packages/flutter_tools/templates/module/android/library/include_flutter.groovy.copy.tmpl
View file @
ee032f67
...
@@ -6,37 +6,24 @@ def flutterProjectRoot = new File(scriptFile).parentFile.parentFile
...
@@ -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 ->
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
gradle.include ":$name"
gradle.include ":$name"
gradle.project(":$name").projectDir = pluginDirectory
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 ->
...
...
This diff is collapsed.
Click to expand it.
packages/flutter_tools/templates/module/android/library_new_embedding/include_flutter.groovy.copy.tmpl
View file @
ee032f67
...
@@ -6,37 +6,24 @@ def flutterProjectRoot = new File(scriptFile).parentFile.parentFile
...
@@ -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 ->
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
def pluginDirectory = flutterProjectRoot.toPath().resolve(path).resolve('android').toFile()
gradle.include ":$name"
gradle.include ":$name"
gradle.project(":$name").projectDir = pluginDirectory
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 ->
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment