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
d35dd9f8
Unverified
Commit
d35dd9f8
authored
Dec 07, 2020
by
Emmanuel Garcia
Committed by
GitHub
Dec 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow flavors and build types when using plugins (#71738)
parent
90f08769
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
20 deletions
+49
-20
gradle_plugin_light_apk_test.dart
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
+30
-0
apk_utils.dart
dev/devicelab/lib/framework/apk_utils.dart
+5
-2
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+14
-18
No files found.
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
View file @
d35dd9f8
...
...
@@ -8,6 +8,7 @@ import 'package:flutter_devicelab/framework/apk_utils.dart';
import
'package:flutter_devicelab/framework/framework.dart'
;
import
'package:flutter_devicelab/framework/task_result.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
import
'package:path/path.dart'
as
path
;
Future
<
void
>
main
()
async
{
await
task
(()
async
{
...
...
@@ -207,6 +208,35 @@ Future<void> main() async {
await
project
.
runGradleTask
(
'assembleLocal'
);
});
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'gradlew assembleLocal with plugin (custom debug build)'
);
final
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_plugin.'
);
final
Directory
pluginDir
=
Directory
(
path
.
join
(
tempDir
.
path
,
'plugin_under_test'
));
section
(
'Create plugin'
);
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab.plugin'
,
'--template=plugin'
,
'--platforms=android,ios'
,
pluginDir
.
path
,
],
);
});
section
(
'Configure'
);
project
.
addPlugin
(
'plugin_under_test'
,
value:
'
$platformLineSep
path:
${pluginDir.path}
'
);
await
project
.
addCustomBuildType
(
'local'
,
initWith:
'debug'
);
await
project
.
getPackages
();
section
(
'Build APK'
);
await
project
.
runGradleTask
(
'assembleLocal'
);
});
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'gradlew assembleBeta (custom release build)'
);
await
project
.
addCustomBuildType
(
'beta'
,
initWith:
'release'
);
...
...
dev/devicelab/lib/framework/apk_utils.dart
View file @
d35dd9f8
...
...
@@ -280,12 +280,15 @@ subprojects {
'''
);
}
Future
<
void
>
addPlugin
(
String
plugin
)
async
{
/// Adds a plugin to the pubspec.
/// In pubspec, each dependency is expressed as key, value pair joined by a colon `:`.
/// such as `plugin_a`:`^0.0.1` or `plugin_a`:`\npath: /some/path`.
Future
<
void
>
addPlugin
(
String
plugin
,
{
String
value
=
''
})
async
{
final
File
pubspec
=
File
(
path
.
join
(
rootPath
,
'pubspec.yaml'
));
String
content
=
await
pubspec
.
readAsString
();
content
=
content
.
replaceFirst
(
'
${platformLineSep}
dependencies:
$platformLineSep
'
,
'
${platformLineSep}
dependencies:
$platformLineSep
$plugin
:
$platformLineSep
'
,
'
${platformLineSep}
dependencies:
$platformLineSep
$plugin
:
$
value$
platformLineSep
'
,
);
await
pubspec
.
writeAsString
(
content
,
flush:
true
);
}
...
...
packages/flutter_tools/gradle/flutter.gradle
View file @
d35dd9f8
...
...
@@ -149,19 +149,16 @@ class FlutterPlugin implements Plugin<Project> {
String
flutterExecutableName
=
Os
.
isFamily
(
Os
.
FAMILY_WINDOWS
)
?
"flutter.bat"
:
"flutter"
flutterExecutable
=
Paths
.
get
(
flutterRoot
.
absolutePath
,
"bin"
,
flutterExecutableName
).
toFile
();
// Add custom build types.
String
flutterProguardRules
=
Paths
.
get
(
flutterRoot
.
absolutePath
,
"packages"
,
"flutter_tools"
,
"gradle"
,
"flutter_proguard_rules.pro"
)
project
.
android
.
buildTypes
{
// Add profile build type.
profile
{
initWith
debug
if
(
it
.
hasProperty
(
"matchingFallbacks"
))
{
matchingFallbacks
=
[
"debug"
,
"release"
]
}
}
}
String
flutterProguardRules
=
Paths
.
get
(
flutterRoot
.
absolutePath
,
"packages"
,
"flutter_tools"
,
"gradle"
,
"flutter_proguard_rules.pro"
)
project
.
android
.
buildTypes
{
release
{
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
...
...
@@ -315,20 +312,19 @@ class FlutterPlugin implements Plugin<Project> {
if
(!
supportsBuildMode
(
flutterBuildMode
))
{
return
}
addApiDependencies
(
pluginProject
,
buildType
.
name
,
"io.flutter:flutter_embedding_$flutterBuildMode:$engineVersion"
)
// Copy build types from the app to the plugin.
// This allows to build apps with plugins and custom build types or flavors.
pluginProject
.
android
.
buildTypes
{
"${buildType.name}"
{}
}
pluginProject
.
dependencies
.
add
(
"${buildType.name}CompileOnly"
,
"io.flutter:flutter_embedding_$flutterBuildMode:$engineVersion"
)
}
// Wait until the Android plugin loaded.
pluginProject
.
afterEvaluate
{
pluginProject
.
android
.
buildTypes
{
profile
{
initWith
debug
}
}
pluginProject
.
android
.
buildTypes
.
each
addEmbeddingCompileOnlyDependency
pluginProject
.
android
.
buildTypes
.
whenObjectAdded
addEmbeddingCompileOnlyDependency
project
.
android
.
buildTypes
.
each
addEmbeddingCompileOnlyDependency
project
.
android
.
buildTypes
.
whenObjectAdded
addEmbeddingCompileOnlyDependency
}
}
...
...
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