From 61e13a67e66a42b0d010fe23035126a327e23024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20L=C3=B3pez=20Ma=C3=B1as?= Date: Tue, 28 May 2024 18:22:01 +0200 Subject: [PATCH] chore: updated Kotlin to 2.0.0 and migration Catalogue (#256) * chore: updated Kotlin to 2.0.0 and migration Catalogue * chore: moved dependencies into the Catalogue * chore: moved plugins into Catalogue * chore: fixed file --- app/build.gradle | 28 ++++++++--------- build.gradle | 26 ++++++++-------- gradle/libs.versions.toml | 64 +++++++++++++++++++++++++++++++++++++++ places-ktx/build.gradle | 41 +++++++++++-------------- 4 files changed, 108 insertions(+), 51 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle b/app/build.gradle index 246ad16..5671c33 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,5 @@ /** - * Copyright 2023 Google Inc. + * Copyright 2024 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,12 @@ plugins { } android { - compileSdk 34 + compileSdk libs.versions.androidCompileSdk.get().toInteger() defaultConfig { applicationId "com.google.maps.android.ktx.demo" - minSdk 21 - targetSdk 34 + minSdk libs.versions.androidMinSdk.get().toInteger() + targetSdk libs.versions.androidTargetSdk.get().toInteger() versionCode 1 versionName "1.0" multiDexEnabled true @@ -58,18 +58,18 @@ android { } dependencies { - implementation "androidx.appcompat:appcompat:1.6.1" - implementation "androidx.core:core-ktx:1.12.0" - implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.24" - implementation 'androidx.multidex:multidex:2.0.1' - implementation "com.google.android.gms:play-services-maps:18.2.0" - implementation "androidx.fragment:fragment-ktx:1.6.2" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0' - implementation 'com.google.android.material:material:1.11.0' - implementation 'com.android.volley:volley:1.2.1' + implementation libs.appcompat + implementation libs.core.ktx + implementation libs.kotlin.stdlib + implementation libs.multidex + implementation libs.play.services.maps + implementation libs.fragment.ktx + implementation libs.lifecycle.runtime.ktx + implementation libs.material + implementation libs.volley // Hilt - implementation "com.google.dagger:hilt-android:2.51" + implementation libs.hilt.android kapt "com.google.dagger:hilt-android-compiler:2.51.1" implementation project(':places-ktx') diff --git a/build.gradle b/build.gradle index 0f24a7e..08a1738 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /** - * Copyright 2023 Google Inc. + * Copyright 2024 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,12 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:8.4.0' - classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.9.10' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24" - classpath "com.google.dagger:hilt-android-gradle-plugin:2.51" - classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" - classpath 'com.mxalbert.gradle:jacoco-android:0.2.1' + classpath libs.gradle + classpath libs.dokka.gradle.plugin + classpath libs.kotlin.gradle.plugin + classpath libs.hilt.android.gradle.plugin + classpath libs.secrets.gradle.plugin + classpath libs.jacoco.android } } @@ -66,11 +66,11 @@ allprojects { subprojects { project -> if (project.ext.artifactId == null) return - apply plugin: 'com.android.library' - apply plugin: 'maven-publish' - apply plugin: 'org.jetbrains.dokka' - apply plugin: 'com.mxalbert.gradle.jacoco-android' - apply plugin: 'signing' + plugins.apply(libs.plugins.androidLibrary.get().pluginId) + plugins.apply(libs.plugins.mavenPublish.get().pluginId) + plugins.apply(libs.plugins.dokka.get().pluginId) + plugins.apply(libs.plugins.jacocoAndroid.get().pluginId) + plugins.apply(libs.plugins.signing.get().pluginId) // Code coverage jacoco { @@ -167,5 +167,5 @@ subprojects { project -> } tasks.register('clean', Delete) { - delete rootProject.buildDir + delete rootProject.layout.buildDirectory } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..2b557f1 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,64 @@ +[versions] +androidCompileSdk = "34" +androidMinSdk = "21" +androidTargetSdk = "34" + +appcompat = "1.6.1" +coreKtx = "1.13.1" +dokkaGradlePlugin = "1.9.20" +fragmentKtx = "1.7.1" +gradle = "8.4.1" +hiltAndroid = "2.51.1" +jacocoAndroid = "0.2.1" +kotlin = "2.0.0" +kotlinGradlePlugin = "1.9.24" +kotlinx-coroutines-core = "1.8.1" +lifecycle-viewmodel-ktx = "2.8.0" +material = "1.12.0" +playServicesMaps = "18.2.0" +secretsGradlePlugin = "2.0.1" +truth = "1.4.2" +volley = "1.2.1" +multidex = "2.0.1" +kotlinx-coroutines-play-services = "1.8.1" +places = "3.4.0" +junit-ext = "1.1.5" +test-core = "1.5.0" +mockito-kotlin = "2.2.0" +junit = "4.13.2" +mockito-core = "5.9.0" + +[libraries] +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" } +dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokkaGradlePlugin" } +fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragmentKtx" } +gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } +hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" } +hilt-android-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "hiltAndroid" } +jacoco-android = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacocoAndroid" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinGradlePlugin" } +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" } +lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle-viewmodel-ktx" } +lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle-viewmodel-ktx" } +material = { module = "com.google.android.material:material", version.ref = "material" } +play-services-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "playServicesMaps" } +secrets-gradle-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secretsGradlePlugin" } +truth = { module = "com.google.truth:truth", version.ref = "truth" } +volley = { group = "com.android.volley", name = "volley", version.ref = "volley" } +multidex = { group = "androidx.multidex", name = "multidex", version.ref = "multidex" } +kotlinx-coroutines-play-services = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines-play-services" } +places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } +junit-ext = { group = "androidx.test.ext", name = "junit", version.ref = "junit-ext" } +test-core = { group = "androidx.test", name = "core", version.ref = "test-core" } +mockito-kotlin = { group = "com.nhaarman.mockitokotlin2", name = "mockito-kotlin", version.ref = "mockito-kotlin" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito-core" } + +[plugins] +androidLibrary = { id = "com.android.library" } +mavenPublish = { id = "maven-publish" } +dokka = { id = "org.jetbrains.dokka" } +jacocoAndroid = { id = "com.mxalbert.gradle.jacoco-android" } +signing = { id = "signing" } diff --git a/places-ktx/build.gradle b/places-ktx/build.gradle index 8a26610..683d815 100644 --- a/places-ktx/build.gradle +++ b/places-ktx/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2020 Google Inc. + * Copyright 2024 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,11 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdk 34 + compileSdk libs.versions.androidCompileSdk.get().toInteger() defaultConfig { - minSdk 21 - targetSdk 34 + minSdk libs.versions.androidMinSdk.get().toInteger() + targetSdk libs.versions.androidTargetSdk.get().toInteger() testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' multiDexEnabled true @@ -42,30 +42,23 @@ android { testOptions { unitTests.returnDefaultValues = true } - - buildTypes { - debug { - testCoverageEnabled = true - } - } - namespace "com.google.android.libraries.places.ktx" } dependencies { - implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.24' - implementation('org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1') - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.0" - implementation "com.android.volley:volley:1.2.1" - implementation 'androidx.multidex:multidex:2.0.1' - api "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.1" - api 'com.google.android.libraries.places:places:3.4.0' + implementation libs.kotlin.stdlib + implementation libs.kotlinx.coroutines.core + implementation libs.lifecycle.viewmodel.ktx + implementation libs.volley + implementation libs.multidex + api libs.kotlinx.coroutines.play.services + api libs.places // Tests - testImplementation "androidx.test.ext:junit:1.1.5" - testImplementation "androidx.test:core:1.5.0" - testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" - testImplementation "junit:junit:4.13.2" - testImplementation "org.mockito:mockito-core:5.11.0" - testImplementation "com.google.truth:truth:1.4.2" + testImplementation libs.junit.ext + testImplementation libs.test.core + testImplementation libs.mockito.kotlin + testImplementation libs.junit + testImplementation libs.mockito.core + testImplementation libs.truth } \ No newline at end of file