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.
This commit is contained in:
@@ -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<Project> {
|
||||
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<Project> {
|
||||
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."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user