From 202cdac963fedbe82a02fee465434a162ad3da69 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Thu, 4 Apr 2024 12:12:18 +0200 Subject: [PATCH] Move Gradle dependencies to Gradle version catalog (#2229) --- benchmark/android/.gitignore | 1 + platform/android/MapLibreAndroid/build.gradle | 32 +++---- .../android/MapLibreAndroidLint/build.gradle | 14 ++-- .../MapLibreAndroidTestApp/build.gradle | 40 ++++----- platform/android/build.gradle | 4 +- .../android/gradle/android-nitpick.gradle | 45 +--------- platform/android/gradle/dependencies.gradle | 79 ------------------ platform/android/gradle/libs.versions.toml | 83 +++++++++++++++++++ test/android/.gitignore | 1 + 9 files changed, 131 insertions(+), 168 deletions(-) create mode 100644 benchmark/android/.gitignore create mode 100644 platform/android/gradle/libs.versions.toml create mode 100644 test/android/.gitignore diff --git a/benchmark/android/.gitignore b/benchmark/android/.gitignore new file mode 100644 index 000000000..ac96206f3 --- /dev/null +++ b/benchmark/android/.gitignore @@ -0,0 +1 @@ +.gradle/ \ No newline at end of file diff --git a/platform/android/MapLibreAndroid/build.gradle b/platform/android/MapLibreAndroid/build.gradle index 968dcecf7..2dab4e279 100644 --- a/platform/android/MapLibreAndroid/build.gradle +++ b/platform/android/MapLibreAndroid/build.gradle @@ -12,25 +12,25 @@ apply from: "${rootDir}/gradle/native-build.gradle" dependencies { lintChecks project(":MapLibreAndroidLint") - api dependenciesList.mapboxJavaGeoJSON - api dependenciesList.mapboxAndroidGestures + api libs.maplibreJavaGeoJSON + api libs.mapboxAndroidGestures - implementation dependenciesList.mapboxJavaTurf - implementation dependenciesList.supportAnnotations - implementation dependenciesList.supportFragmentV4 - implementation dependenciesList.okhttp3 - implementation dependenciesList.timber - implementation dependenciesList.interpolator + implementation libs.maplibreJavaTurf + implementation libs.supportAnnotations + implementation libs.supportFragmentV4 + implementation libs.okhttp3 + implementation libs.timber + implementation libs.interpolator - testImplementation dependenciesList.junit - testImplementation dependenciesList.mockito - testImplementation dependenciesList.mockk - testImplementation dependenciesList.robolectric - testImplementation dependenciesList.commonsIO - testImplementation dependenciesList.assertjcore + testImplementation libs.junit + testImplementation libs.mockito + testImplementation libs.mockk + testImplementation libs.robolectric + testImplementation libs.commonsIO + testImplementation libs.assertjcore - androidTestImplementation dependenciesList.testRunner - androidTestImplementation dependenciesList.testRules + androidTestImplementation libs.testRunner + androidTestImplementation libs.testRules } tasks.withType(DokkaTask.class) { diff --git a/platform/android/MapLibreAndroidLint/build.gradle b/platform/android/MapLibreAndroidLint/build.gradle index 5b74b737d..8be192bd9 100644 --- a/platform/android/MapLibreAndroidLint/build.gradle +++ b/platform/android/MapLibreAndroidLint/build.gradle @@ -8,14 +8,14 @@ apply plugin: 'kotlin' dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - compileOnly dependenciesList.lint - compileOnly dependenciesList.lintApi - compileOnly dependenciesList.lintChecks - compileOnly dependenciesList.supportAnnotations + compileOnly libs.lint + compileOnly libs.lintApi + compileOnly libs.lintChecks + compileOnly libs.supportAnnotations - testImplementation dependenciesList.junit - testImplementation dependenciesList.robolectric - testImplementation dependenciesList.lintTests + testImplementation libs.junit + testImplementation libs.robolectric + testImplementation libs.lintTests } sourceCompatibility = "1.8" diff --git a/platform/android/MapLibreAndroidTestApp/build.gradle b/platform/android/MapLibreAndroidTestApp/build.gradle index d34154d91..3792b2f1a 100644 --- a/platform/android/MapLibreAndroidTestApp/build.gradle +++ b/platform/android/MapLibreAndroidTestApp/build.gradle @@ -94,32 +94,32 @@ android { dependencies { implementation project(':MapLibreAndroid') - implementation dependenciesList.mapboxJavaTurf + implementation libs.maplibreJavaTurf - implementation dependenciesList.supportAppcompatV7 - implementation dependenciesList.supportRecyclerView - implementation dependenciesList.supportDesign - implementation dependenciesList.supportConstraintLayout - implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0' + implementation libs.supportAppcompatV7 + implementation libs.supportRecyclerView + implementation libs.supportDesign + implementation libs.supportConstraintLayout + implementation libs.kotlinxSerializationJson - implementation dependenciesList.multidex + implementation libs.multidex - implementation dependenciesList.timber + implementation libs.timber - implementation dependenciesList.okhttp3 + implementation libs.okhttp3 - debugImplementation dependenciesList.leakCanary + debugImplementation libs.leakCanary - androidTestImplementation dependenciesList.supportAnnotations - androidTestImplementation dependenciesList.testRunner - androidTestImplementation dependenciesList.testRules - androidTestImplementation dependenciesList.testEspressoCore - androidTestImplementation dependenciesList.testEspressoIntents - androidTestImplementation dependenciesList.testEspressoContrib - androidTestImplementation dependenciesList.testUiAutomator - androidTestImplementation dependenciesList.appCenter - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test:core-ktx:1.5.0' + androidTestImplementation libs.supportAnnotations + androidTestImplementation libs.testRunner + androidTestImplementation libs.testRules + androidTestImplementation libs.testEspressoCore + androidTestImplementation libs.testEspressoIntents + androidTestImplementation libs.testEspressoContrib + androidTestImplementation libs.testUiAutomator + androidTestImplementation libs.appCenter + androidTestImplementation libs.androidxTestExtJUnit + androidTestImplementation libs.androidxTestCoreKtx } diff --git a/platform/android/build.gradle b/platform/android/build.gradle index 3db385e00..196353c9c 100644 --- a/platform/android/build.gradle +++ b/platform/android/build.gradle @@ -8,9 +8,9 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:8.1.4' - classpath dependenciesList.licensesPlugin + classpath libs.licensesPlugin // classpath dependenciesList.jacocoPlugin - classpath dependenciesList.gradleNexus + classpath libs.gradleNexus classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21" } } diff --git a/platform/android/gradle/android-nitpick.gradle b/platform/android/gradle/android-nitpick.gradle index e1d69e367..a90c5d7b7 100644 --- a/platform/android/gradle/android-nitpick.gradle +++ b/platform/android/gradle/android-nitpick.gradle @@ -1,60 +1,17 @@ apply from: "${rootDir}/gradle/dependencies.gradle" -//def MAPBOX_JAVA_DIR = 'maplibre-java' -//def MAPBOX_JAVA_TAG_PREFIX = 'v' - -def MAPBOX_GESTURES_DIR = 'mapbox-gestures-android' -def MAPBOX_GESTURES_TAG_PREFIX = 'v' - task androidNitpick { doLast { println "Running android nitpick script" - println "Verify vendor submodule pins" - // Will enter a task to re-evaluate and restore if needed verifyVendorSubmodulePin(MAPBOX_JAVA_DIR, MAPBOX_JAVA_TAG_PREFIX, versions.mapLibreServices) - verifyVendorSubmodulePin(MAPBOX_GESTURES_DIR, MAPBOX_GESTURES_TAG_PREFIX, versions.mapboxGestures) - verifyLicenseGeneration() } } -private def verifyVendorSubmodulePin(def dir, def prefix, def version) { - println "Verify vendor submodule pin: ${dir} (${prefix + version})" - exec { - workingDir = "${rootDir}/vendor/${dir}" - commandLine "git", "fetch", "-t" - } - - def output = new ByteArrayOutputStream() - exec { - workingDir = "${rootDir}/vendor/${dir}" - commandLine "git", "rev-list", "-n", "1", "tags/${prefix + version}" - standardOutput = output - } - def expectedCommit = output.toString().trim() - output.reset() - - exec { - workingDir = "${rootDir}/vendor/${dir}" - commandLine "git", "rev-parse", "HEAD" - standardOutput = output - } - def actualCommit = output.toString().trim() - - if (actualCommit != expectedCommit) { - throw new IllegalStateException("${dir} vendor repository is not checked out on the consumed binary's tag.\n" + - "Expected commit: " + expectedCommit + "(${prefix + version} tag).\n" + - "Actual commit: " + actualCommit + ".\n" + - "If you've updated the version in the dependencies.gradle file, make sure to bump the submodule pin in the /vendor directory to match the release tag.\n" + - "If you've bumped the pin, make sure to verify the version tag prefix in the android-nitpick.gradle file.") - } - output.close() -} - private def verifyLicenseGeneration() { println "Verify license generation with git diff..." exec { workingDir = "${rootDir}" - commandLine "python", "scripts/validate-license.py" + commandLine "python3", "scripts/validate-license.py" } } \ No newline at end of file diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle index d9eacb7d0..137a046eb 100644 --- a/platform/android/gradle/dependencies.gradle +++ b/platform/android/gradle/dependencies.gradle @@ -1,5 +1,4 @@ ext { - androidVersions = [ minSdkVersion : 21, targetSdkVersion : 33, @@ -11,82 +10,4 @@ ext { ndkVersion : '25.1.8937393', cmakeVersion : '3.18.1+', ] - - versions = [ - mapLibreServices: '5.9.0', - mapboxCore : '2.0.1', - mapboxGestures : '0.7.0', - appCompat : '1.5.1', - constraintLayout: '2.1.4', - interpolator : '1.0.0', - recyclerView : '1.2.1', - material : '1.7.0', - uiAutomator : '2.2.0', - espresso : '3.5.0', - testRunner : '1.1.4', - testRules : '1.5.0', - fragment : '1.5.5', - annotation : '1.5.0', - leakCanary : '2.10', - junit : '4.13.2', - mockito : '4.10.0', - mockk : '1.13.3', - robolectric : '4.9.1', - timber : '5.0.1', - okhttp : '4.11.0', - kotlin : '1.9.21', - licenses : '0.8.80', - lint : '30.3.1', - // jacoco : '0.8.5', - appcenter : '1.5', - commonsIO : '2.11.0', - assertj : '3.23.1', - gradleNexus : "1.1.0", - multidex : "2.0.1" - ] - - dependenciesList = [ - mapboxJavaGeoJSON : "org.maplibre.gl:android-sdk-geojson:${versions.mapLibreServices}", - mapboxAndroidGestures : "com.mapbox.mapboxsdk:mapbox-android-gestures:${versions.mapboxGestures}", - mapboxJavaTurf : "org.maplibre.gl:android-sdk-turf:${versions.mapLibreServices}", - - junit : "junit:junit:${versions.junit}", - amdroidxJunit : "androidx.test.ext:junit:1.1.4", - mockito : "org.mockito:mockito-core:${versions.mockito}", - mockk : "io.mockk:mockk:${versions.mockk}", - robolectric : "org.robolectric:robolectric:${versions.robolectric}", - assertjcore : "org.assertj:assertj-core:${versions.assertj}", - - testRunner : "androidx.test.ext:junit:${versions.testRunner}", - testRules : "androidx.test:rules:${versions.testRules}", - testEspressoCore : "androidx.test.espresso:espresso-core:${versions.espresso}", - testEspressoIntents : "androidx.test.espresso:espresso-intents:${versions.espresso}", - testEspressoContrib : "androidx.test.espresso:espresso-contrib:${versions.espresso}", - testUiAutomator : "androidx.test.uiautomator:uiautomator:${versions.uiAutomator}", - supportAnnotations : "androidx.annotation:annotation:${versions.annotation}", - supportAppcompatV7 : "androidx.appcompat:appcompat:${versions.appCompat}", - supportFragmentV4 : "androidx.fragment:fragment:${versions.fragment}", - supportRecyclerView : "androidx.recyclerview:recyclerview:${versions.recyclerView}", - supportConstraintLayout: "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}", - interpolator : "androidx.interpolator:interpolator:${versions.interpolator}", - supportDesign : "com.google.android.material:material:${versions.material}", - multidex : "androidx.multidex:multidex:${versions.multidex}", - - appCenter : "com.microsoft.appcenter:espresso-test-extension:${versions.appcenter}", - commonsIO : "commons-io:commons-io:${versions.commonsIO}", - timber : "com.jakewharton.timber:timber:${versions.timber}", - okhttp3 : "com.squareup.okhttp3:okhttp:${versions.okhttp}", - leakCanary : "com.squareup.leakcanary:leakcanary-android:${versions.leakCanary}", - - kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}", - licensesPlugin : "com.jaredsburrows:gradle-license-plugin:${versions.licenses}", - // jacocoPlugin : "org.jacoco:org.jacoco.core:${versions.jacoco}", - - lint : "com.android.tools.lint:lint:${versions.lint}", - lintApi : "com.android.tools.lint:lint-api:${versions.lint}", - lintChecks : "com.android.tools.lint:lint-checks:${versions.lint}", - lintTests : "com.android.tools.lint:lint-tests:${versions.lint}", - - gradleNexus : "io.github.gradle-nexus:publish-plugin:${versions.gradleNexus}" - ] } diff --git a/platform/android/gradle/libs.versions.toml b/platform/android/gradle/libs.versions.toml new file mode 100644 index 000000000..d9a9bfb26 --- /dev/null +++ b/platform/android/gradle/libs.versions.toml @@ -0,0 +1,83 @@ +[versions] +mapLibreServices = "5.9.0" +mapboxGestures = "0.7.0" +appCompat = "1.5.1" +constraintLayout = "2.1.4" +interpolator = "1.0.0" +recyclerView = "1.2.1" +material = "1.7.0" +uiAutomator = "2.2.0" +espresso = "3.5.0" +testRunner = "1.1.4" +testRules = "1.5.0" +fragment = "1.5.5" +annotation = "1.5.0" +leakCanary = "2.10" +junit = "4.13.2" +mockito = "4.10.0" +mockk = "1.13.3" +robolectric = "4.9.1" +timber = "5.0.1" +okhttp = "4.11.0" +kotlin = "1.9.21" +licenses = "0.8.80" +lint = "30.3.1" +appcenter = "1.5" +commonsIO = "2.11.0" +assertj = "3.23.1" +gradleNexus = "1.1.0" +multidex = "2.0.1" + +androidxTestExtJUnit = "1.1.5" +androidxTestCoreKtx = "1.5.0" +kotlinxSerializationJson = "1.6.0" + + +[libraries] +maplibreJavaGeoJSON = { group = "org.maplibre.gl", name = "android-sdk-geojson", version.ref = "mapLibreServices" } +mapboxAndroidGestures = { group = "com.mapbox.mapboxsdk", name = "mapbox-android-gestures", version.ref = "mapboxGestures" } +maplibreJavaTurf = { group = "org.maplibre.gl", name = "android-sdk-turf", version.ref = "mapLibreServices" } + +junit = { group = "junit", name = "junit", version.ref = "junit" } +amdroidxJunit = { group = "androidx.test.ext", name = "junit", version.ref = "testRunner" } +mockito = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" } +mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } +robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" } +assertjcore = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" } + +testRunner = { group = "androidx.test.ext", name = "junit", version.ref = "testRunner" } +testRules = { group = "androidx.test", name = "rules", version.ref = "testRules" } +testEspressoCore = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" } +testEspressoIntents = { group = "androidx.test.espresso", name = "espresso-intents", version.ref = "espresso" } +testEspressoContrib = { group = "androidx.test.espresso", name = "espresso-contrib", version.ref = "espresso" } +testUiAutomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "uiAutomator" } +supportAnnotations = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } +supportAppcompatV7 = { group = "androidx.appcompat", name = "appcompat", version.ref = "appCompat" } +supportFragmentV4 = { group = "androidx.fragment", name = "fragment", version.ref = "fragment" } +supportRecyclerView = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerView" } +supportConstraintLayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintLayout" } +interpolator = { group = "androidx.interpolator", name = "interpolator", version.ref = "interpolator" } +supportDesign = { group = "com.google.android.material", name = "material", version.ref = "material" } +multidex = { group = "androidx.multidex", name = "multidex", version.ref = "multidex" } + +appCenter = { group = "com.microsoft.appcenter", name = "espresso-test-extension", version.ref = "appcenter" } +commonsIO = { group = "commons-io", name = "commons-io", version.ref = "commonsIO" } +timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } +okhttp3 = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" } +leakCanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakCanary" } + +kotlinPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +licensesPlugin = { group = "com.jaredsburrows", name = "gradle-license-plugin", version.ref = "licenses" } + +lint = { group = "com.android.tools.lint", name = "lint", version.ref = "lint" } +lintApi = { group = "com.android.tools.lint", name = "lint-api", version.ref = "lint" } +lintChecks = { group = "com.android.tools.lint", name = "lint-checks", version.ref = "lint" } +lintTests = { group = "com.android.tools.lint", name = "lint-tests", version.ref = "lint" } + +gradleNexus = { group = "io.github.gradle-nexus", name = "publish-plugin", version.ref = "gradleNexus" } + +androidxTestExtJUnit = { group = "androidx.test.ext", name = "junit", version = "1.1.5" } +androidxTestCoreKtx = { group = "androidx.test", name = "core-ktx", version = "1.5.0" } +kotlinxSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version = "1.6.0" } + +[plugins] \ No newline at end of file diff --git a/test/android/.gitignore b/test/android/.gitignore new file mode 100644 index 000000000..ac96206f3 --- /dev/null +++ b/test/android/.gitignore @@ -0,0 +1 @@ +.gradle/ \ No newline at end of file