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
Nov 02, 2019
by
Emmanuel Garcia
Committed by
GitHub
Nov 02, 2019
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 {
String
content
=
pubspec
.
readAsStringSync
();
content
=
content
.
replaceFirst
(
'
\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
);
await
inDirectory
(
projectDir
,
()
async
{
...
...
@@ -69,6 +69,8 @@ Future<void> main() async {
'repo'
,
);
section
(
'Check release Maven artifacts'
);
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
...
...
@@ -93,12 +95,59 @@ Future<void> main() async {
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'
);
checkFileContains
(<
String
>[
'flutter_embedding_release'
,
'armeabi_v7a_release'
,
'arm64_v8a_release'
,
'x86_64_release'
,
'package_info_release'
,
'device_info_release'
,
],
releasePom
);
section
(
'Check assets in release AAR'
);
...
...
@@ -109,6 +158,7 @@ Future<void> main() async {
// AOT snapshots
'jni/arm64-v8a/libapp.so'
,
'jni/armeabi-v7a/libapp.so'
,
'jni/x86_64/libapp.so'
,
],
await
getFilesInAar
(
path
.
join
(
...
...
@@ -133,6 +183,8 @@ Future<void> main() async {
);
});
section
(
'Check debug Maven artifacts'
);
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
...
...
@@ -157,6 +209,50 @@ Future<void> main() async {
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'
);
checkFileContains
(<
String
>[
...
...
@@ -165,6 +261,8 @@ Future<void> main() async {
'x86_64_debug'
,
'armeabi_v7a_debug'
,
'arm64_v8a_debug'
,
'package_info_debug'
,
'device_info_debug'
,
],
debugPom
);
section
(
'Check assets in debug AAR'
);
...
...
packages/flutter_tools/gradle/aar_init_script.gradle
View file @
ee032f67
...
...
@@ -79,7 +79,7 @@ String getFlutterRoot(Project project) {
void
addAarTask
(
Project
project
,
variant
)
{
String
variantName
=
variant
.
name
.
capitalize
()
String
taskName
=
"assembleAar$
{variantName}
"
String
taskName
=
"assembleAar$
variantName
"
project
.
tasks
.
create
(
name:
taskName
)
{
// This check is required to be able to configure the archives before `uploadArchives` runs.
if
(!
project
.
gradle
.
startParameter
.
taskNames
.
contains
(
taskName
))
{
...
...
@@ -136,13 +136,32 @@ projectsEvaluated {
assert
rootProject
.
hasProperty
(
"is-plugin"
)
if
(
rootProject
.
property
(
"is-plugin"
).
toBoolean
())
{
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"
))
return
}
// In module projects, the Android library project is the `:flutter` subproject.
Project
androidLibraryProject
=
rootProject
.
subprojects
.
find
{
it
.
name
==
"flutter"
}
assert
androidLibraryProject
!=
null
assert
androidLibraryProject
.
hasProperty
(
"output-dir"
)
configureProject
(
androidLibraryProject
,
androidLibraryProject
.
property
(
"output-dir"
))
// The module project is the `:flutter` subproject.
Project
moduleProject
=
rootProject
.
subprojects
.
find
{
it
.
name
==
"flutter"
}
assert
moduleProject
!=
null
assert
moduleProject
.
hasProperty
(
"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"
))
}
}
}
packages/flutter_tools/gradle/flutter.gradle
View file @
ee032f67
...
...
@@ -264,18 +264,9 @@ class FlutterPlugin implements Plugin<Project> {
if
(
useLocalEngine
())
{
throw
new
GradleException
(
"Local engine isn't supported when building the plugins as AAR"
)
}
List
<
Project
>
projects
=
[
project
]
// Module projects set the `hostProjects` extra property in `include_flutter.groovy`.
// This is required to set the local repository in each host app project.
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"
}
project
.
repositories
{
maven
{
url
"${getPluginBuildDir()}/outputs/repo"
}
}
getPluginList
().
each
{
pluginName
,
pluginPath
->
...
...
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
gradle.include ':flutter'
gradle.project(':flutter').projectDir = new File(flutterProjectRoot, '.android/Flutter')
if (System.getProperty('build-plugins-as-aars') != 'true') {
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
if (pluginsFile.exists()) {
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 ->
g.rootProject.beforeEvaluate { p ->
_mainModuleName = binding.variables['mainModuleName']
if (_mainModuleName != null && !_mainModuleName.empty) {
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 ->
p.subprojects { sp ->
...
...
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
gradle.include ':flutter'
gradle.project(':flutter').projectDir = new File(flutterProjectRoot, '.android/Flutter')
if (System.getProperty('build-plugins-as-aars') != 'true') {
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins')
if (pluginsFile.exists()) {
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 ->
g.rootProject.beforeEvaluate { p ->
_mainModuleName = binding.variables['mainModuleName']
if (_mainModuleName != null && !_mainModuleName.empty) {
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 ->
p.subprojects { sp ->
...
...
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