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
4465ff9e
Unverified
Commit
4465ff9e
authored
May 27, 2020
by
Emmanuel Garcia
Committed by
GitHub
May 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent building non-android plugins in build aar (#58018)
parent
84322041
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
82 deletions
+75
-82
build_aar_module_test.dart
dev/devicelab/bin/tasks/build_aar_module_test.dart
+66
-81
aar_init_script.gradle
packages/flutter_tools/gradle/aar_init_script.gradle
+9
-1
No files found.
dev/devicelab/bin/tasks/build_aar_module_test.dart
View file @
4465ff9e
...
...
@@ -24,11 +24,11 @@ Future<void> main() async {
return
TaskResult
.
failure
(
'Could not find Java'
);
print
(
'
\n
Using JAVA_HOME=
$javaHome
'
);
section
(
'Create module project'
);
final
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_module_test.'
);
final
Directory
projectDir
=
Directory
(
path
.
join
(
tempDir
.
path
,
'hello'
));
try
{
section
(
'Create module project'
);
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
...
...
@@ -36,15 +36,55 @@ Future<void> main() async {
);
});
section
(
'Add plugins'
);
section
(
'Create plugin that supports android platform'
);
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab'
,
'--template'
,
'plugin'
,
'plugin_with_android'
],
);
});
section
(
'Create plugin that doesn
\'
t support android project'
);
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab'
,
'--template'
,
'plugin'
,
'plugin_without_android'
],
);
});
final
File
pubspec
=
File
(
path
.
join
(
projectDir
.
path
,
'pubspec.yaml'
));
String
content
=
pubspec
.
readAsStringSync
();
// Delete the android/ directory.
File
(
path
.
join
(
tempDir
.
path
,
'plugin_without_android'
,
'android'
)).
deleteSync
(
recursive:
true
);
// Remove Android support from the plugin pubspec.yaml
final
File
pluginPubspec
=
File
(
path
.
join
(
tempDir
.
path
,
'plugin_without_android'
,
'pubspec.yaml'
));
pluginPubspec
.
writeAsStringSync
(
pluginPubspec
.
readAsStringSync
().
replaceFirst
(
'''
android:
package: io.flutter.devicelab.plugin_without_android
pluginClass: PluginWithoutAndroidPlugin
'''
,
''
),
flush:
true
);
section
(
'Add plugins to pubspec.yaml'
);
final
File
modulePubspec
=
File
(
path
.
join
(
projectDir
.
path
,
'pubspec.yaml'
));
String
content
=
modulePubspec
.
readAsStringSync
();
content
=
content
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
device_info: 0.4.1
\n
package_info: 0.4.0+9
\n
'
,
'
\n
dependencies:
\n
'
' plugin_with_android:
\n
'
' path: ../plugin_with_android
\n
'
' plugin_without_android:
\n
'
' path: ../plugin_without_android
\n
'
,
);
pubspec
.
writeAsStringSync
(
content
,
flush:
true
);
modulePubspec
.
writeAsStringSync
(
content
,
flush:
true
);
section
(
'Run packages get in module project'
);
await
inDirectory
(
projectDir
,
()
async
{
await
flutter
(
'packages'
,
...
...
@@ -57,7 +97,7 @@ Future<void> main() async {
await
inDirectory
(
projectDir
,
()
async
{
await
flutter
(
'build'
,
options:
<
String
>[
'aar'
,
'--
release'
,
'--
verbose'
],
options:
<
String
>[
'aar'
,
'--verbose'
],
);
});
...
...
@@ -99,44 +139,22 @@ Future<void> main() async {
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'
,
'devicelab'
,
'plugin_with_android'
,
'plugin_with_android_release'
,
'1.0'
,
'p
ackage_info
_release-1.0.aar'
,
'p
lugin_with_android
_release-1.0.aar'
,
));
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'
plugins
'
,
'p
ackageinfo
'
,
'p
ackage_info
_release'
,
'
devicelab
'
,
'p
lugin_with_android
'
,
'p
lugin_with_android
_release'
,
'1.0'
,
'p
ackage_info
_release-1.0.pom'
,
'p
lugin_with_android
_release-1.0.pom'
,
));
section
(
'Check AOT blobs in release POM'
);
...
...
@@ -146,8 +164,7 @@ Future<void> main() async {
'armeabi_v7a_release'
,
'arm64_v8a_release'
,
'x86_64_release'
,
'package_info_release'
,
'device_info_release'
,
'plugin_with_android_release'
,
],
releasePom
);
section
(
'Check assets in release AAR'
);
...
...
@@ -174,15 +191,6 @@ Future<void> main() async {
)
);
section
(
'Build debug AAR'
);
await
inDirectory
(
projectDir
,
()
async
{
await
flutter
(
'build'
,
options:
<
String
>[
'aar'
,
'--verbose'
,
'--debug'
],
);
});
section
(
'Check debug Maven artifacts'
);
checkFileExists
(
path
.
join
(
...
...
@@ -213,44 +221,22 @@ Future<void> main() async {
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'
,
'devicelab'
,
'plugin_with_android'
,
'plugin_with_android_debug'
,
'1.0'
,
'p
ackage_info
_debug-1.0.aar'
,
'p
lugin_with_android
_debug-1.0.aar'
,
));
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'
plugins
'
,
'p
ackageinfo
'
,
'p
ackage_info
_debug'
,
'
devicelab
'
,
'p
lugin_with_android
'
,
'p
lugin_with_android
_debug'
,
'1.0'
,
'p
ackage_info
_debug-1.0.pom'
,
'p
lugin_with_android
_debug-1.0.pom'
,
));
section
(
'Check AOT blobs in debug POM'
);
...
...
@@ -261,8 +247,7 @@ Future<void> main() async {
'x86_64_debug'
,
'armeabi_v7a_debug'
,
'arm64_v8a_debug'
,
'package_info_debug'
,
'device_info_debug'
,
'plugin_with_android_debug'
,
],
debugPom
);
section
(
'Check assets in debug AAR'
);
...
...
packages/flutter_tools/gradle/aar_init_script.gradle
View file @
4465ff9e
...
...
@@ -73,6 +73,14 @@ void configureProject(Project project, String outputDir) {
}
}
void
configurePlugin
(
Project
project
,
String
outputDir
)
{
if
(!
project
.
hasProperty
(
"android"
))
{
// A plugin doesn't support the Android platform when this property isn't defined in the plugin.
return
}
configureProject
(
project
,
outputDir
)
}
String
getFlutterRoot
(
Project
project
)
{
if
(!
project
.
hasProperty
(
"flutter-root"
))
{
throw
new
GradleException
(
"The `-Pflutter-root` flag must be specified."
)
...
...
@@ -158,7 +166,7 @@ projectsEvaluated {
// This is due to the Android Gradle Plugin expecting all library subprojects to be published
// as Maven artifacts.
modulePlugins
.
each
{
pluginProject
->
configureP
roject
(
pluginProject
,
moduleProject
.
property
(
"output-dir"
))
configureP
lugin
(
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.
...
...
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