From 32ba7e32b78ccc62b163412e9284d9b1325d40d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Wed, 21 Feb 2024 23:58:38 +0100 Subject: [PATCH] Remove deprecation in flutter gradle plugin --- android/app/build.gradle | 14 ++++++-------- android/build.gradle | 13 +------------ android/gradle.properties | 4 ++-- android/settings.gradle | 31 +++++++++++++++++++++++-------- pubspec.yaml | 2 +- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index c6b5d48..714964c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -14,11 +20,6 @@ if (gradlePropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def appVersionCode = gradleProperties.getProperty('app.versionCode') if (appVersionCode == null) { appVersionCode = '1' @@ -29,9 +30,6 @@ if (appVersionName == null) { appVersionName = '1.0' } -apply plugin: 'com.android.application' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { diff --git a/android/build.gradle b/android/build.gradle index 942b40b..bc157bd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,18 +1,7 @@ -buildscript { - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' - } -} - allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/android/gradle.properties b/android/gradle.properties index 60209e3..6b2d4c0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=1.0.47 -app.versionCode=48 +app.versionName=1.0.48 +app.versionCode=49 diff --git a/android/settings.gradle b/android/settings.gradle index 44e62bc..8cc46c0 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,11 +1,26 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.2.2" apply false + id "org.jetbrains.kotlin.android" version "1.9.22" apply false +} + +include ":app" diff --git a/pubspec.yaml b/pubspec.yaml index 57a9307..2f14702 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A random application, for testing purpose only. publish_to: 'none' -version: 1.0.47+48 +version: 1.0.48+49 environment: sdk: '^3.0.0' -- GitLab