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
9884f998
Commit
9884f998
authored
Dec 18, 2019
by
Emmanuel Garcia
Committed by
Flutter GitHub Bot
Dec 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change meaning of a plugin not supporting the android platform (#47015)
parent
b3e14cc6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
12 deletions
+34
-12
plugin_dependencies_test.dart
dev/devicelab/bin/tasks/plugin_dependencies_test.dart
+3
-1
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+15
-6
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+3
-2
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+13
-3
No files found.
dev/devicelab/bin/tasks/plugin_dependencies_test.dart
View file @
9884f998
...
@@ -74,7 +74,9 @@ Future<void> main() async {
...
@@ -74,7 +74,9 @@ Future<void> main() async {
);
);
});
});
File
(
path
.
join
(
pluginCDirectory
.
path
,
'android'
)).
deleteSync
(
recursive:
true
);
// https://github.com/flutter/flutter/issues/46898
// https://github.com/flutter/flutter/issues/39657
File
(
path
.
join
(
pluginCDirectory
.
path
,
'android'
,
'build.gradle'
)).
deleteSync
();
final
File
pluginCpubspec
=
File
(
path
.
join
(
pluginCDirectory
.
path
,
'pubspec.yaml'
));
final
File
pluginCpubspec
=
File
(
path
.
join
(
pluginCDirectory
.
path
,
'pubspec.yaml'
));
await
pluginCpubspec
.
writeAsString
(
'''
await
pluginCpubspec
.
writeAsString
(
'''
...
...
packages/flutter_tools/gradle/flutter.gradle
View file @
9884f998
...
@@ -331,15 +331,24 @@ class FlutterPlugin implements Plugin<Project> {
...
@@ -331,15 +331,24 @@ class FlutterPlugin implements Plugin<Project> {
}
}
}
}
// Returns `true` if the given path contains an `android/build.gradle` file.
//
// TODO(egarciad): Fix https://github.com/flutter/flutter/issues/39657.
// Android Studio may create empty android directories due to the logic in <app>/android/settings.gradle,
// which imports all plugins regardless of whether they support the android platform.
private
Boolean
doesSupportAndroidPlatform
(
String
path
)
{
File
editableAndroidProject
=
new
File
(
path
,
'android'
+
File
.
separator
+
'build.gradle'
)
return
editableAndroidProject
.
exists
()
}
// Add the dependencies on other plugin projects to the plugin project.
// Add the dependencies on other plugin projects to the plugin project.
// A plugin A can depend on plugin B. As a result, this dependency must be surfaced by
// A plugin A can depend on plugin B. As a result, this dependency must be surfaced by
// making the Gradle plugin project A depend on the Gradle plugin project B.
// making the Gradle plugin project A depend on the Gradle plugin project B.
private
void
configurePluginDependencies
(
Object
dependencyObject
)
{
private
void
configurePluginDependencies
(
Object
dependencyObject
)
{
assert
dependencyObject
.
name
instanceof
String
assert
dependencyObject
.
name
instanceof
String
Project
pluginProject
=
project
.
rootProject
.
findProject
(
":${dependencyObject.name}"
)
Project
pluginProject
=
project
.
rootProject
.
findProject
(
":${dependencyObject.name}"
)
if
(
pluginProject
==
null
)
{
if
(
pluginProject
==
null
||
// Ignore plugins that don't have a project since most likely they don't
!
doesSupportAndroidPlatform
(
pluginProject
.
projectDir
.
parentFile
.
path
))
{
// have an android/ directory.
return
return
}
}
assert
dependencyObject
.
dependencies
instanceof
List
assert
dependencyObject
.
dependencies
instanceof
List
...
@@ -349,7 +358,8 @@ class FlutterPlugin implements Plugin<Project> {
...
@@ -349,7 +358,8 @@ class FlutterPlugin implements Plugin<Project> {
return
return
}
}
Project
dependencyProject
=
project
.
rootProject
.
findProject
(
":$pluginDependencyName"
)
Project
dependencyProject
=
project
.
rootProject
.
findProject
(
":$pluginDependencyName"
)
if
(!
dependencyProject
.
projectDir
.
exists
()
||
dependencyProject
==
null
)
{
if
(
dependencyProject
==
null
||
!
doesSupportAndroidPlatform
(
dependencyProject
.
projectDir
.
parentFile
.
path
))
{
return
return
}
}
// Wait for the Android plugin to load and add the dependency to the plugin project.
// Wait for the Android plugin to load and add the dependency to the plugin project.
...
@@ -366,8 +376,7 @@ class FlutterPlugin implements Plugin<Project> {
...
@@ -366,8 +376,7 @@ class FlutterPlugin implements Plugin<Project> {
Properties
allPlugins
=
readPropertiesIfExist
(
pluginsFile
)
Properties
allPlugins
=
readPropertiesIfExist
(
pluginsFile
)
Properties
androidPlugins
=
new
Properties
()
Properties
androidPlugins
=
new
Properties
()
allPlugins
.
each
{
name
,
path
->
allPlugins
.
each
{
name
,
path
->
File
editableAndroidProject
=
new
File
(
path
,
'android'
+
File
.
separator
+
'build.gradle'
)
if
(
doesSupportAndroidPlatform
(
path
))
{
if
(
editableAndroidProject
.
exists
())
{
androidPlugins
.
setProperty
(
name
,
path
)
androidPlugins
.
setProperty
(
name
,
path
)
}
}
// TODO(amirh): log an error if this plugin was specified to be an Android
// TODO(amirh): log an error if this plugin was specified to be an Android
...
...
packages/flutter_tools/lib/src/android/gradle.dart
View file @
9884f998
...
@@ -716,8 +716,9 @@ Future<void> buildPluginsAsAar(
...
@@ -716,8 +716,9 @@ Future<void> buildPluginsAsAar(
assert
(
pluginDirectory
.
existsSync
());
assert
(
pluginDirectory
.
existsSync
());
final
String
pluginName
=
pluginParts
.
first
;
final
String
pluginName
=
pluginParts
.
first
;
if
(!
pluginDirectory
.
childDirectory
(
'android'
).
existsSync
())
{
final
File
buildGradleFile
=
pluginDirectory
.
childDirectory
(
'android'
).
childFile
(
'build.gradle'
);
printTrace
(
'Skipping plugin
$pluginName
since it doesn
\'
t have an android directory'
);
if
(!
buildGradleFile
.
existsSync
())
{
printTrace
(
'Skipping plugin
$pluginName
since it doesn
\'
t have a android/build.gradle file'
);
continue
;
continue
;
}
}
logger
.
printStatus
(
'Building plugin
$pluginName
...'
);
logger
.
printStatus
(
'Building plugin
$pluginName
...'
);
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
9884f998
...
@@ -897,7 +897,10 @@ flutter:
...
@@ -897,7 +897,10 @@ flutter:
androidPackage: irrelevant
androidPackage: irrelevant
'''
);
'''
);
plugin1
.
childDirectory
(
'android'
).
createSync
();
plugin1
.
childDirectory
(
'android'
)
.
childFile
(
'build.gradle'
)
.
createSync
(
recursive:
true
);
final
Directory
plugin2
=
fs
.
directory
(
'plugin2.'
);
final
Directory
plugin2
=
fs
.
directory
(
'plugin2.'
);
plugin2
plugin2
...
@@ -910,7 +913,10 @@ flutter:
...
@@ -910,7 +913,10 @@ flutter:
androidPackage: irrelevant
androidPackage: irrelevant
'''
);
'''
);
plugin2
.
childDirectory
(
'android'
).
createSync
();
plugin2
.
childDirectory
(
'android'
)
.
childFile
(
'build.gradle'
)
.
createSync
(
recursive:
true
);
androidDirectory
androidDirectory
.
childFile
(
'.flutter-plugins'
)
.
childFile
(
'.flutter-plugins'
)
...
@@ -976,7 +982,7 @@ plugin2=${plugin2.path}
...
@@ -976,7 +982,7 @@ plugin2=${plugin2.path}
GradleUtils:
()
=>
FakeGradleUtils
(),
GradleUtils:
()
=>
FakeGradleUtils
(),
});
});
testUsingContext
(
'skips plugin without a
n android directory
'
,
()
async
{
testUsingContext
(
'skips plugin without a
android/build.gradle file
'
,
()
async
{
final
Directory
androidDirectory
=
fs
.
directory
(
'android.'
);
final
Directory
androidDirectory
=
fs
.
directory
(
'android.'
);
androidDirectory
.
createSync
();
androidDirectory
.
createSync
();
androidDirectory
androidDirectory
...
@@ -999,6 +1005,10 @@ flutter:
...
@@ -999,6 +1005,10 @@ flutter:
.
writeAsStringSync
(
'''
.
writeAsStringSync
(
'''
plugin1=
${plugin1.path}
plugin1=
${plugin1.path}
'''
);
'''
);
// Create an empty android directory.
// https://github.com/flutter/flutter/issues/46898
plugin1
.
childDirectory
(
'android'
).
createSync
();
final
Directory
buildDirectory
=
androidDirectory
.
childDirectory
(
'build'
);
final
Directory
buildDirectory
=
androidDirectory
.
childDirectory
(
'build'
);
buildDirectory
buildDirectory
...
...
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