Make Gradle script support Flutter-as-lib (#18633)
This commit is contained in:
committed by
GitHub
parent
0a3179fbab
commit
475678fdd8
@@ -53,7 +53,7 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
|
||||
private String resolveProperty(Project project, String name, String defaultValue) {
|
||||
if (localProperties == null) {
|
||||
localProperties = readPropertiesIfExist(project.rootProject.file("local.properties"))
|
||||
localProperties = readPropertiesIfExist(new File(project.projectDir.parentFile, "local.properties"))
|
||||
}
|
||||
String result
|
||||
if (project.hasProperty(name)) {
|
||||
@@ -107,8 +107,8 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
localEngineSrcPath = engineOut.parentFile.parent
|
||||
|
||||
project.dependencies {
|
||||
if (project.getConfigurations().findByName("implementation")) {
|
||||
implementation project.files(flutterJar)
|
||||
if (project.getConfigurations().findByName("api")) {
|
||||
api project.files(flutterJar)
|
||||
} else {
|
||||
compile project.files(flutterJar)
|
||||
}
|
||||
@@ -146,16 +146,16 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
into "lib/x86_64"
|
||||
}
|
||||
}
|
||||
// Add flutter.jar dependencies to all <buildType>Implementation configurations, including custom ones
|
||||
// Add flutter.jar dependencies to all <buildType>Api configurations, including custom ones
|
||||
// added after applying the Flutter plugin.
|
||||
project.android.buildTypes.each { addFlutterJarImplementationDependency(project, it) }
|
||||
project.android.buildTypes.whenObjectAdded { addFlutterJarImplementationDependency(project, it) }
|
||||
project.android.buildTypes.each { addFlutterJarApiDependency(project, it) }
|
||||
project.android.buildTypes.whenObjectAdded { addFlutterJarApiDependency(project, it) }
|
||||
}
|
||||
|
||||
project.extensions.create("flutter", FlutterExtension)
|
||||
project.afterEvaluate this.&addFlutterTask
|
||||
|
||||
File pluginsFile = new File(project.rootProject.projectDir.parentFile, '.flutter-plugins')
|
||||
File pluginsFile = new File(project.projectDir.parentFile.parentFile, '.flutter-plugins')
|
||||
Properties plugins = readPropertiesIfExist(pluginsFile)
|
||||
|
||||
plugins.each { name, _ ->
|
||||
@@ -199,15 +199,15 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds suitable flutter.jar implementation dependencies to the specified buildType.
|
||||
* Adds suitable flutter.jar api dependencies to the specified buildType.
|
||||
*
|
||||
* Note: The BuildType DSL type is not public, and is therefore omitted from the signature.
|
||||
*/
|
||||
private void addFlutterJarImplementationDependency(Project project, buildType) {
|
||||
private void addFlutterJarApiDependency(Project project, buildType) {
|
||||
project.dependencies {
|
||||
String configuration;
|
||||
if (project.getConfigurations().findByName("implementation")) {
|
||||
configuration = buildType.name + "Implementation";
|
||||
if (project.getConfigurations().findByName("api")) {
|
||||
configuration = buildType.name + "Api";
|
||||
} else {
|
||||
configuration = buildType.name + "Compile";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user