From 475678fdd837f8e84d205dcc275c73d2270e236f Mon Sep 17 00:00:00 2001 From: Mikkel Nygaard Ravn Date: Wed, 20 Jun 2018 16:07:05 +0200 Subject: [PATCH] Make Gradle script support Flutter-as-lib (#18633) --- packages/flutter_tools/gradle/flutter.gradle | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/flutter_tools/gradle/flutter.gradle b/packages/flutter_tools/gradle/flutter.gradle index 8be915eca8..232a1a5483 100644 --- a/packages/flutter_tools/gradle/flutter.gradle +++ b/packages/flutter_tools/gradle/flutter.gradle @@ -53,7 +53,7 @@ class FlutterPlugin implements Plugin { 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 { 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 { into "lib/x86_64" } } - // Add flutter.jar dependencies to all Implementation configurations, including custom ones + // Add flutter.jar dependencies to all 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 { } /** - * 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"; }