From f1003b2a67bb396d659a7540693a8973f173d6a9 Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Tue, 27 Feb 2024 16:44:48 -0500 Subject: [PATCH] fix(flavors): migrate Android gradle to new syntax (#9) * fix(flavors): migrate Android gradle to new syntax * remove non-working very_good command --- .github/actions/flutter_app/action.yaml | 1 - flavors/android/app/build.gradle | 17 ++++++-------- flavors/android/build.gradle | 13 ----------- flavors/android/settings.gradle | 30 ++++++++++++++++++------- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.github/actions/flutter_app/action.yaml b/.github/actions/flutter_app/action.yaml index 35ba17c..d794820 100644 --- a/.github/actions/flutter_app/action.yaml +++ b/.github/actions/flutter_app/action.yaml @@ -54,7 +54,6 @@ runs: shell: ${{ inputs.shell }} run: | flutter pub global activate very_good_cli - very_good --analytics false very_good packages get --recursive - name: Format diff --git a/flavors/android/app/build.gradle b/flavors/android/app/build.gradle index 982e5d9..e25a081 100644 --- a/flavors/android/app/build.gradle +++ b/flavors/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()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.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 flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,10 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { namespace "com.example.flavors" compileSdkVersion flutter.compileSdkVersion @@ -81,5 +78,5 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10" } diff --git a/flavors/android/build.gradle b/flavors/android/build.gradle index f7eb7f6..bc157bd 100644 --- a/flavors/android/build.gradle +++ b/flavors/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/flavors/android/settings.gradle b/flavors/android/settings.gradle index 44e62bc..536165d 100644 --- a/flavors/android/settings.gradle +++ b/flavors/android/settings.gradle @@ -1,11 +1,25 @@ -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 + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$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.3.0" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false +} + +include ":app"