From fe07ede153aa165f0d9c032cc45a4177c63e7c43 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 23 May 2024 02:46:42 -0700 Subject: [PATCH] Bump Gradle dependencies (#952) * bump Gradle dependencies * example: upgrade to declarative Gradle buildfiles * bump to Gradle 8.7 * more bumps * example: remove dependency on android_path_provider * downgrade androidx.annotation:annotation to 1.6.0 * example app: make to build to Gradle/AGP 8, set java bytecode to 8 * bump min Flutter to 3.19 * bump Dart deps * add build example app step --- .github/workflows/prepare.yaml | 12 +++++- CHANGELOG.md | 7 ++++ android/build.gradle | 39 +++++++++---------- example/android/app/build.gradle | 38 ++++++++++-------- .../android/app/src/main/AndroidManifest.xml | 2 +- example/android/build.gradle | 22 +---------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 30 +++++++++----- example/pubspec.yaml | 13 +++---- pubspec.yaml | 6 +-- 10 files changed, 91 insertions(+), 80 deletions(-) diff --git a/.github/workflows/prepare.yaml b/.github/workflows/prepare.yaml index c180a99d..b477d381 100644 --- a/.github/workflows/prepare.yaml +++ b/.github/workflows/prepare.yaml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - flutter-version: ["3.10.x", "3.13.x", "3.16.x", "3.19.x"] + flutter-version: ["3.19.x"] steps: - name: Clone repository @@ -25,9 +25,19 @@ jobs: channel: stable flutter-version: ${{ matrix.flutter-version }} + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - name: flutter pub get run: flutter pub get + - name: Build example app + working-directory: example + run: flutter build apk --debug + - name: dart format run: dart format --set-exit-if-changed . diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a016a85..2151c4cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.11.8 + +- Dependencies update (#952) + - Gradle buildscripts on Android + - Bump minimum Android SDK to 21 + - Bump minimum Flutter to 3.19 + ## 1.11.7 - Update dependencies (#946) diff --git a/android/build.gradle b/android/build.gradle index 8382a960..78f9b70b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,7 @@ +group = "vn.hunghd.flutterdownloader" +version = "1.0-SNAPSHOT" + buildscript { - ext.kotlin_version = "1.9.0" repositories { google() mavenCentral() @@ -8,28 +10,23 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:7.4.2" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0" classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.0" } } +repositories { + google() + mavenCentral() +} + apply plugin: "com.android.library" apply plugin: "kotlin-android" apply plugin: "org.jlleitschuh.gradle.ktlint" -group "vn.hunghd.flutterdownloader" -version "1.0-SNAPSHOT" - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - android { - namespace "vn.hunghd.flutterdownloader" - compileSdk 34 + namespace = "vn.hunghd.flutterdownloader" + compileSdk = 34 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -37,21 +34,23 @@ android { } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = JavaVersion.VERSION_1_8 + // allWarningsAsErrors = true // TODO(bartekpacia): Re-enable } sourceSets { main.java.srcDirs += "src/main/kotlin" + test.java.srcDirs += "src/test/kotlin" } defaultConfig { - minSdk 19 - targetSdk 33 + minSdk = 21 + targetSdk = 34 } } dependencies { - implementation "androidx.work:work-runtime:2.7.1" - implementation "androidx.annotation:annotation:1.5.0" - implementation "androidx.core:core-ktx:1.9.0" + compileOnly "androidx.annotation:annotation:1.6.0" + implementation "androidx.core:core-ktx:1.13.1" + implementation "androidx.work:work-runtime:2.9.0" } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index a46c965a..a4d5275e 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "org.jetbrains.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,21 +22,26 @@ 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 { - compileSdk 34 - - namespace "vn.hunghd.example" + namespace = "vn.hunghd.example" + compileSdk = 34 + ndkVersion = flutter.ndkVersion defaultConfig { applicationId "vn.hunghd.example" - minSdk 19 - targetSdk 33 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + minSdk = 21 + targetSdk = 34 + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 } buildTypes { diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 7796dc82..d5e3a033 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + xmlns:tools="http://schemas.android.com/tools"> diff --git a/example/android/build.gradle b/example/android/build.gradle index 80bb3e10..2b1df4ec 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,23 +1,3 @@ -buildscript { - ext.kotlin_version = "1.7.22" - repositories { - google() - mavenCentral() - } - - dependencies { - classpath "com.android.tools.build:gradle:7.4.2" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" @@ -27,5 +7,5 @@ subprojects { } tasks.register("clean", Delete) { - delete rootProject.buildDir + delete(rootProject.buildDir) } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index ec915a81..d951fac2 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index f29f78b3..3c239623 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +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 flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), ".flutter-plugins") -if (pluginsFile.exists()) { - pluginsFile.withReader("UTF-8") { reader -> plugins.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve("android").toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id("dev.flutter.flutter-plugin-loader") + id("com.android.application") version ("8.3.1") apply false + id("org.jetbrains.kotlin.android") version ("1.9.23") apply false } + +include(":app") diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 51aa73a6..a81cae34 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,23 +4,22 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=3.0.0 <4.0.0" - flutter: ">=3.10.0" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: - android_path_provider: ^0.3.0 - device_info_plus: ^8.0.0 + device_info_plus: ^10.1.0 flutter: sdk: flutter flutter_downloader: path: ../ - path_provider: ^2.1.2 - permission_handler: ^10.0.0 + path_provider: ^2.1.3 + permission_handler: ^11.3.1 dev_dependencies: flutter_test: sdk: flutter - leancode_lint: ^4.0.0+2 + leancode_lint: ^12.1.0 flutter: uses-material-design: true diff --git a/pubspec.yaml b/pubspec.yaml index 91b351d5..efba9663 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,8 +15,8 @@ flutter: pluginClass: FlutterDownloaderPlugin environment: - sdk: ">=3.0.0 <4.0.0" - flutter: ">=3.10.0" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: flutter: @@ -25,4 +25,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - leancode_lint: ^4.0.0+2 + leancode_lint: ^12.1.0