Unverified Commit 69a542da authored by Gary Qian's avatar Gary Qian Committed by GitHub

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
parent 530324d2
......@@ -237,15 +237,10 @@ class FlutterPlugin implements Plugin<Project> {
flutterExecutable = Paths.get(flutterRoot.absolutePath, "bin", flutterExecutableName).toFile();
if (project.hasProperty("multidex-enabled") &&
project.property("multidex-enabled").toBoolean() &&
project.android.defaultConfig.minSdkVersion <= 20) {
project.property("multidex-enabled").toBoolean()) {
String flutterMultidexKeepfile = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
"gradle", "flutter_multidex_keepfile.txt")
project.android {
defaultConfig {
multiDexEnabled true
manifestPlaceholders.applicationName = "io.flutter.app.FlutterMultiDexApplication"
}
buildTypes {
release {
multiDexKeepFile project.file(flutterMultidexKeepfile)
......@@ -255,18 +250,9 @@ class FlutterPlugin implements Plugin<Project> {
project.dependencies {
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",
"gradle", "flutter_proguard_rules.pro")
......
// 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)
}
}
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment