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
d2b5f34b
Unverified
Commit
d2b5f34b
authored
Feb 08, 2022
by
Emmanuel Garcia
Committed by
GitHub
Feb 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix how Gradle resolves Android plugin" (#98050)
parent
0ee8e0e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
168 deletions
+27
-168
app_plugin_loader.gradle
packages/flutter_tools/gradle/app_plugin_loader.gradle
+0
-1
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+27
-47
android_skip_unsupported_plugin.dart
...st/integration.shard/android_skip_unsupported_plugin.dart
+0
-120
No files found.
packages/flutter_tools/gradle/app_plugin_loader.gradle
View file @
d2b5f34b
...
...
@@ -20,7 +20,6 @@ assert object instanceof Map
assert
object
.
plugins
instanceof
Map
assert
object
.
plugins
.
android
instanceof
List
// Includes the Flutter plugins that support the Android platform.
// This logic must be kept in sync with the logic in flutter.gradle.
object
.
plugins
.
android
.
each
{
androidPlugin
->
assert
androidPlugin
.
name
instanceof
String
assert
androidPlugin
.
path
instanceof
String
...
...
packages/flutter_tools/gradle/flutter.gradle
View file @
d2b5f34b
...
...
@@ -48,7 +48,7 @@ class FlutterExtension {
* Specifies the relative directory to the Flutter project directory.
* In an app project, this is ../.. since the app's build.gradle is under android/app.
*/
String
source
=
'../..'
String
source
/** Allows to override the target file. Otherwise, the target is lib/main.dart. */
String
target
...
...
@@ -418,7 +418,7 @@ class FlutterPlugin implements Plugin<Project> {
/**
* Compares semantic versions ignoring labels.
*
*
* If the versions are equal (ignoring labels), returns one of the two strings arbitrarily.
*
* If minor or patch are omitted (non-conformant to semantic versioning), they are considered zero.
...
...
@@ -459,9 +459,6 @@ class FlutterPlugin implements Plugin<Project> {
getPluginList
().
each
{
plugin
->
Project
pluginProject
=
project
.
rootProject
.
findProject
(
plugin
.
key
)
if
(
pluginProject
==
null
)
{
return
}
pluginProject
.
afterEvaluate
{
int
pluginCompileSdkVersion
=
pluginProject
.
android
.
compileSdkVersion
.
substring
(
8
)
as
int
maxPluginCompileSdkVersion
=
Math
.
max
(
pluginCompileSdkVersion
,
maxPluginCompileSdkVersion
)
...
...
@@ -479,7 +476,15 @@ class FlutterPlugin implements Plugin<Project> {
}
}
}
}
}
}
/**
* Returns `true` if the given path contains an `android/build.gradle` file.
*/
private
Boolean
doesSupportAndroidPlatform
(
String
path
)
{
File
editableAndroidProject
=
new
File
(
path
,
'android'
+
File
.
separator
+
'build.gradle'
)
return
editableAndroidProject
.
exists
()
}
/**
...
...
@@ -490,7 +495,8 @@ class FlutterPlugin implements Plugin<Project> {
private
void
configurePluginDependencies
(
Object
dependencyObject
)
{
assert
dependencyObject
.
name
instanceof
String
Project
pluginProject
=
project
.
rootProject
.
findProject
(
":${dependencyObject.name}"
)
if
(
pluginProject
==
null
)
{
if
(
pluginProject
==
null
||
!
doesSupportAndroidPlatform
(
pluginProject
.
projectDir
.
parentFile
.
path
))
{
return
}
assert
dependencyObject
.
dependencies
instanceof
List
...
...
@@ -500,7 +506,8 @@ class FlutterPlugin implements Plugin<Project> {
return
}
Project
dependencyProject
=
project
.
rootProject
.
findProject
(
":$pluginDependencyName"
)
if
(
dependencyProject
==
null
)
{
if
(
dependencyProject
==
null
||
!
doesSupportAndroidPlatform
(
dependencyProject
.
projectDir
.
parentFile
.
path
))
{
return
}
// Wait for the Android plugin to load and add the dependency to the plugin project.
...
...
@@ -512,27 +519,17 @@ class FlutterPlugin implements Plugin<Project> {
}
}
/** Gets the list of plugins that support the Android platform. */
private
Properties
getPluginList
()
{
Map
meta
=
getDependenciesMetadata
()
File
pluginsFile
=
new
File
(
project
.
projectDir
.
parentFile
.
parentFile
,
'.flutter-plugins'
)
Properties
allPlugins
=
readPropertiesIfExist
(
pluginsFile
)
Properties
androidPlugins
=
new
Properties
()
if
(
meta
==
null
)
{
return
androidPlugins
}
assert
meta
.
plugins
instanceof
Map
assert
meta
.
plugins
.
android
instanceof
List
// This logic must be kept in sync with the logic in app_plugin_loader.gradle.
meta
.
plugins
.
android
.
each
{
androidPlugin
->
assert
androidPlugin
.
name
instanceof
String
assert
androidPlugin
.
path
instanceof
String
// Skip plugins that have no native build (such as a Dart-only implementation
// of a federated plugin).
def
needsBuild
=
androidPlugin
.
containsKey
(
'native_build'
)
?
androidPlugin
[
'native_build'
]
:
true
if
(!
needsBuild
)
{
return
allPlugins
.
each
{
name
,
path
->
if
(
doesSupportAndroidPlatform
(
path
))
{
androidPlugins
.
setProperty
(
name
,
path
)
}
androidPlugins
.
setProperty
(
androidPlugin
.
name
,
androidPlugin
.
path
)
// TODO(amirh): log an error if this plugin was specified to be an Android
// plugin according to the new schema, and was missing a build.gradle file.
// https://github.com/flutter/flutter/issues/40784
}
return
androidPlugins
}
...
...
@@ -560,31 +557,14 @@ class FlutterPlugin implements Plugin<Project> {
// This means, `plugin-a` depends on `plugin-b` and `plugin-c`.
// `plugin-b` depends on `plugin-c`.
// `plugin-c` doesn't depend on anything.
Map
meta
=
getDependenciesMetadata
()
if
(
meta
==
null
)
{
return
[]
}
assert
meta
.
dependencyGraph
instanceof
List
return
meta
.
dependencyGraph
}
private
Map
parsedFlutterPluginsDependencies
/**
* Parses <project-src>/.flutter-plugins-dependencies
*/
private
Map
getDependenciesMetadata
()
{
if
(
parsedFlutterPluginsDependencies
)
{
return
parsedFlutterPluginsDependencies
}
File
pluginsDependencyFile
=
new
File
(
getFlutterSourceDirectory
(),
'.flutter-plugins-dependencies'
)
File
pluginsDependencyFile
=
new
File
(
project
.
projectDir
.
parentFile
.
parentFile
,
'.flutter-plugins-dependencies'
)
if
(
pluginsDependencyFile
.
exists
())
{
def
object
=
new
JsonSlurper
().
parseText
(
pluginsDependencyFile
.
text
)
assert
object
instanceof
Map
parsedFlutterPluginsDependencies
=
objec
t
return
object
assert
object
.
dependencyGraph
instanceof
Lis
t
return
object
.
dependencyGraph
}
return
null
return
[]
}
private
static
String
toCammelCase
(
List
<
String
>
parts
)
{
...
...
packages/flutter_tools/test/integration.shard/android_skip_unsupported_plugin.dart
deleted
100644 → 0
View file @
0ee8e0e6
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'../src/common.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
late
Directory
tempDir
;
setUp
(()
{
Cache
.
flutterRoot
=
getFlutterRoot
();
tempDir
=
createResolvedTempDirectorySync
(
'flutter_plugin_test.'
);
});
tearDown
(()
async
{
tryToDelete
(
tempDir
);
});
// Regression test for https://github.com/flutter/flutter/issues/97729.
test
(
'skip plugin if it does not support the Android platform'
,
()
async
{
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
,
);
// Create dummy plugin that *only* supports iOS.
processManager
.
runSync
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'create'
,
'--template=plugin'
,
'--platforms=ios'
,
'test_plugin'
,
],
workingDirectory:
tempDir
.
path
);
final
Directory
pluginAppDir
=
tempDir
.
childDirectory
(
'test_plugin'
);
// Create an android directory and a build.gradle file within.
final
File
pluginGradleFile
=
pluginAppDir
.
childDirectory
(
'android'
)
.
childFile
(
'build.gradle'
)
..
createSync
(
recursive:
true
);
expect
(
pluginGradleFile
,
exists
);
pluginGradleFile
.
writeAsStringSync
(
r''
'
buildscript {
ext.kotlin_version = '
1.5
.
31
'
repositories {
google()
mavenCentral()
}
dependencies {
classpath '
com
.
android
.
tools
.
build
:
gradle:
7.0
.
0
'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:
$kotlin_version
"
}
configurations.classpath {
resolutionStrategy.activateDependencyLocking()
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '
../
build
'
subprojects {
project.buildDir = "
${rootProject.buildDir}
/
${project.name}
"
}
subprojects {
project.evaluationDependsOn('
:
app
')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
'''
);
final
Directory
pluginExampleAppDir
=
pluginAppDir
.
childDirectory
(
'example'
);
// Add android support to the plugin's example app.
final
ProcessResult
addAndroidResult
=
processManager
.
runSync
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'create'
,
'--template=app'
,
'--platforms=android'
,
'.'
,
],
workingDirectory:
pluginExampleAppDir
.
path
);
expect
(
addAndroidResult
.
exitCode
,
equals
(
0
),
reason:
'flutter create exited with non 0 code:
${addAndroidResult.stderr}
'
);
// Run flutter build apk to build plugin example project.
final
ProcessResult
buildApkResult
=
processManager
.
runSync
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'apk'
,
'--debug'
,
],
workingDirectory:
pluginExampleAppDir
.
path
);
expect
(
buildApkResult
.
exitCode
,
equals
(
0
),
reason:
'flutter build apk exited with non 0 code:
${buildApkResult.stderr}
'
);
});
}
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