Apply multidex config in kotlin dsl gradle file (#114660)
* Apply multidex login in kotlin dsl gradle file * Cleanup * Remove plugin parameter passing * Cleanup * Restore dependencies block * Analyzer * Compiles * Cleanup * Cleanup
This commit is contained in:
parent
530324d232
commit
69a542dade
@ -237,15 +237,10 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
flutterExecutable = Paths.get(flutterRoot.absolutePath, "bin", flutterExecutableName).toFile();
|
flutterExecutable = Paths.get(flutterRoot.absolutePath, "bin", flutterExecutableName).toFile();
|
||||||
|
|
||||||
if (project.hasProperty("multidex-enabled") &&
|
if (project.hasProperty("multidex-enabled") &&
|
||||||
project.property("multidex-enabled").toBoolean() &&
|
project.property("multidex-enabled").toBoolean()) {
|
||||||
project.android.defaultConfig.minSdkVersion <= 20) {
|
|
||||||
String flutterMultidexKeepfile = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
|
String flutterMultidexKeepfile = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
|
||||||
"gradle", "flutter_multidex_keepfile.txt")
|
"gradle", "flutter_multidex_keepfile.txt")
|
||||||
project.android {
|
project.android {
|
||||||
defaultConfig {
|
|
||||||
multiDexEnabled true
|
|
||||||
manifestPlaceholders.applicationName = "io.flutter.app.FlutterMultiDexApplication"
|
|
||||||
}
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
multiDexKeepFile project.file(flutterMultidexKeepfile)
|
multiDexKeepFile project.file(flutterMultidexKeepfile)
|
||||||
@ -255,18 +250,9 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
project.dependencies {
|
project.dependencies {
|
||||||
implementation "androidx.multidex:multidex:2.0.1"
|
implementation "androidx.multidex:multidex:2.0.1"
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
String baseApplicationName = "android.app.Application"
|
|
||||||
if (project.hasProperty("base-application-name")) {
|
|
||||||
baseApplicationName = project.property("base-application-name")
|
|
||||||
}
|
|
||||||
project.android {
|
|
||||||
defaultConfig {
|
|
||||||
// Setting to android.app.Application is the same as omitting the attribute.
|
|
||||||
manifestPlaceholders.applicationName = baseApplicationName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Use Kotlin DSL to handle baseApplicationName logic due to Groovy dynamic dispatch bug.
|
||||||
|
project.apply from: Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools", "gradle", "flutter.gradle.kts")
|
||||||
|
|
||||||
String flutterProguardRules = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
|
String flutterProguardRules = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
|
||||||
"gradle", "flutter_proguard_rules.pro")
|
"gradle", "flutter_proguard_rules.pro")
|
||||||
|
33
packages/flutter_tools/gradle/flutter.gradle.kts
Normal file
33
packages/flutter_tools/gradle/flutter.gradle.kts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
apply<FlutterPluginKts>()
|
||||||
|
|
||||||
|
class FlutterPluginKts : Plugin<Project> {
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
// Use withGroovyBuilder and getProperty() to access Groovy metaprogramming.
|
||||||
|
project.withGroovyBuilder {
|
||||||
|
getProperty("android").withGroovyBuilder {
|
||||||
|
getProperty("defaultConfig").withGroovyBuilder {
|
||||||
|
if (project.hasProperty("multidex-enabled") &&
|
||||||
|
project.property("multidex-enabled").toString().toBoolean()) {
|
||||||
|
setProperty("multiDexEnabled", true)
|
||||||
|
getProperty("manifestPlaceholders").withGroovyBuilder {
|
||||||
|
setProperty("applicationName", "io.flutter.app.FlutterMultiDexApplication")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var baseApplicationName: String = "android.app.Application"
|
||||||
|
if (project.hasProperty("base-application-name")) {
|
||||||
|
baseApplicationName = project.property("base-application-name").toString()
|
||||||
|
}
|
||||||
|
// Setting to android.app.Application is the same as omitting the attribute.
|
||||||
|
getProperty("manifestPlaceholders").withGroovyBuilder {
|
||||||
|
setProperty("applicationName", baseApplicationName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user