Allow flavors and build types when using plugins (#71738)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user