Unverified Commit 475678fd authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

Make Gradle script support Flutter-as-lib (#18633)

parent 0a3179fb
...@@ -53,7 +53,7 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -53,7 +53,7 @@ class FlutterPlugin implements Plugin<Project> {
private String resolveProperty(Project project, String name, String defaultValue) { private String resolveProperty(Project project, String name, String defaultValue) {
if (localProperties == null) { if (localProperties == null) {
localProperties = readPropertiesIfExist(project.rootProject.file("local.properties")) localProperties = readPropertiesIfExist(new File(project.projectDir.parentFile, "local.properties"))
} }
String result String result
if (project.hasProperty(name)) { if (project.hasProperty(name)) {
...@@ -107,8 +107,8 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -107,8 +107,8 @@ class FlutterPlugin implements Plugin<Project> {
localEngineSrcPath = engineOut.parentFile.parent localEngineSrcPath = engineOut.parentFile.parent
project.dependencies { project.dependencies {
if (project.getConfigurations().findByName("implementation")) { if (project.getConfigurations().findByName("api")) {
implementation project.files(flutterJar) api project.files(flutterJar)
} else { } else {
compile project.files(flutterJar) compile project.files(flutterJar)
} }
...@@ -146,16 +146,16 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -146,16 +146,16 @@ class FlutterPlugin implements Plugin<Project> {
into "lib/x86_64" 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. // added after applying the Flutter plugin.
project.android.buildTypes.each { addFlutterJarImplementationDependency(project, it) } project.android.buildTypes.each { addFlutterJarApiDependency(project, it) }
project.android.buildTypes.whenObjectAdded { addFlutterJarImplementationDependency(project, it) } project.android.buildTypes.whenObjectAdded { addFlutterJarApiDependency(project, it) }
} }
project.extensions.create("flutter", FlutterExtension) project.extensions.create("flutter", FlutterExtension)
project.afterEvaluate this.&addFlutterTask 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) Properties plugins = readPropertiesIfExist(pluginsFile)
plugins.each { name, _ -> plugins.each { name, _ ->
...@@ -199,15 +199,15 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -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. * 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 { project.dependencies {
String configuration; String configuration;
if (project.getConfigurations().findByName("implementation")) { if (project.getConfigurations().findByName("api")) {
configuration = buildType.name + "Implementation"; configuration = buildType.name + "Api";
} else { } else {
configuration = buildType.name + "Compile"; configuration = buildType.name + "Compile";
} }
......
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