From 370f40e6dfbf742d7b980dc7cc38152975ed8d84 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Fri, 26 Jan 2024 10:46:18 +0100 Subject: [PATCH] flutter.groovy: update for Gradle Kotlin DSL compatibility (#142144) This PR fixes 2 small mistakes in `FlutterExtension`: - all fields must be `public` in order to be used in Gradle Kotlin DSL the same as in Gradle Groovy DSL - using `logger` instead of `project.logger` throws an error when executed This PR re-adds a subset of changes from #141541 which broke the tree and has been reverted. --- .../gradle/src/main/groovy/flutter.groovy | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy index b6650a19575..6f3708f695e 100644 --- a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy +++ b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -42,10 +42,10 @@ import org.gradle.internal.os.OperatingSystem class FlutterExtension { /** Sets the compileSdkVersion used by default in Flutter app projects. */ - final int compileSdkVersion = 34 + public final int compileSdkVersion = 34 /** Sets the minSdkVersion used by default in Flutter app projects. */ - final int minSdkVersion = 19 + public final int minSdkVersion = 19 /** * Sets the targetSdkVersion used by default in Flutter app projects. @@ -53,14 +53,14 @@ class FlutterExtension { * * See https://developer.android.com/guide/topics/manifest/uses-sdk-element. */ - final int targetSdkVersion = 33 + public final int targetSdkVersion = 33 /** * Sets the ndkVersion used by default in Flutter app projects. * Chosen as default version of the AGP version below as found in * https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp. */ - final String ndkVersion = "23.1.7779620" + public final String ndkVersion = "23.1.7779620" /** * Specifies the relative directory to the Flutter project directory. @@ -72,13 +72,13 @@ class FlutterExtension { String target /** The versionCode that was read from app's local.properties. */ - String flutterVersionCode = null + public String flutterVersionCode = null /** The versionName that was read from app's local.properties. */ - String flutterVersionName = null + public String flutterVersionName = null /** Returns flutterVersionCode as an integer with error handling. */ - Integer versionCode() { + public Integer versionCode() { if (flutterVersionCode == null) { throw new GradleException("flutterVersionCode must not be null.") } @@ -91,7 +91,7 @@ class FlutterExtension { } /** Returns flutterVersionName with error handling. */ - String versionName() { + public String versionName() { if (flutterVersionName == null) { throw new GradleException("flutterVersionName must not be null.") } @@ -704,7 +704,7 @@ class FlutterPlugin implements Plugin { File buildGradle = new File(path, 'android' + File.separator + 'build.gradle') File buildGradleKts = new File(path, 'android' + File.separator + 'build.gradle.kts') if (buildGradle.exists() && buildGradleKts.exists()) { - logger.error( + project.logger.error( "Both build.gradle and build.gradle.kts exist, so " + "build.gradle.kts is ignored. This is likely a mistake." ) @@ -722,7 +722,7 @@ class FlutterPlugin implements Plugin { File settingsGradle = new File(project.projectDir.parentFile, "settings.gradle") File settingsGradleKts = new File(project.projectDir.parentFile, "settings.gradle.kts") if (settingsGradle.exists() && settingsGradleKts.exists()) { - logger.error( + project.logger.error( "Both settings.gradle and settings.gradle.kts exist, so " + "settings.gradle.kts is ignored. This is likely a mistake." )