From dcf14d68fee51c1bbe206a673802f5eda85e7797 Mon Sep 17 00:00:00 2001 From: kaush <1042037+kaushikgopal@users.noreply.github.com> Date: Mon, 24 Apr 2023 23:50:27 -0700 Subject: [PATCH 1/5] ref: use gradle version catalog * https://developer.android.com/build/migrate-to-catalogs#groovy * https://github.com/android/architecture-samples/blob/master/gradle/libs.versions.toml --- app/build.gradle | 18 +++++++----------- gradle/libs.versions.toml | 33 +++++++++++++++++++++++++++++++++ library/build.gradle | 2 +- 3 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle b/app/build.gradle index b6c3af93..ca292f4f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,15 +46,11 @@ repositories { dependencies { implementation project(path: ':library') -// implementation 'com.github.instacart:truetime-android:4.0.0.alpha' - implementation 'com.github.instacart.truetime-android:library-extension-rx:3.5' - - implementation "org.jetbrains.kotlin:kotlin-stdlib" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.0' - - implementation "io.reactivex.rxjava2:rxandroid:2.1.1" +// implementation(libs.truetime) + implementation(libs.truetime.rx) + implementation(libs.kotlin.stdlib) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.rxjava.android) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..25530480 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,33 @@ +[versions] +compileSdk = "33" +minSdk = "21" +targetSdk = "33" + +androidGradlePlugin = "7.4.2" +androidxAppCompat = "1.6.1" +androidxLifecycle = "2.6.0" +constraintlayout = "2.1.4" +kotlin = "1.8.10" +kotlinxCoroutines = "1.6.4" +rxJava = "2.1.1" +trueTime = "4.0.0.alpha" +trueTimeRx = "3.5" + +[libraries] + +# Dependencies of the included build-logic +android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } +kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } + +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidxLifecycle" } +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" } +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } +rxjava-android = { group = "io.reactivex.rxjava2", name = "rxandroid", version.ref = "rxJava" } +truetime = { group = "com.github.instacart", name = "truetime-android", version.ref = "trueTime" } +truetime-rx = { group = "com.github.instacart.truetime-android", name = "library-extension-rx", version.ref = "trueTimeRx" } + + +[plugins] +android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } diff --git a/library/build.gradle b/library/build.gradle index ea281839..28d2ee21 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -38,7 +38,7 @@ android { } dependencies { - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" + api(libs.kotlinx.coroutines.core) } afterEvaluate { From a907a733d17b4c76f140cd5fc2338a2fb7c9ffd7 Mon Sep 17 00:00:00 2001 From: kaush <1042037+kaushikgopal@users.noreply.github.com> Date: Tue, 25 Apr 2023 07:25:35 -0700 Subject: [PATCH 2/5] move sdk versions to version catalog --- app/build.gradle | 6 +++--- build.gradle | 9 +++++---- library/build.gradle | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ca292f4f..fce7fd6a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,13 +4,13 @@ plugins { } android { - compileSdkVersion rootProject.ext.compileSdkVersion + compileSdkVersion libs.versions.compileSdk.get().toInteger() namespace 'com.instacart.sample' defaultConfig { applicationId "com.instacart.truetime" - minSdkVersion 14 - targetSdkVersion rootProject.ext.targetSdkVersion + minSdkVersion libs.versions.minSdk.get() + targetSdkVersion libs.versions.targetSdk.get() versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName diff --git a/build.gradle b/build.gradle index 9c1868f0..13332ad1 100644 --- a/build.gradle +++ b/build.gradle @@ -16,14 +16,15 @@ buildscript { } plugins { + + // alias for plugins that come from the version catalog file libs.versions.toml + // ... + + // id for plugins that don't come from the version catalog file id "com.diffplug.spotless" version "6.15.0" } ext { - minSdkVersion = 9 - targetSdkVersion = 33 - compileSdkVersion = 33 - versionCode = 12 versionName = '4.0.0.alpha' } diff --git a/library/build.gradle b/library/build.gradle index 28d2ee21..4e11aea2 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -7,13 +7,13 @@ plugins { android { namespace = 'com.instacart.truetime' - compileSdkVersion rootProject.ext.compileSdkVersion + compileSdkVersion libs.versions.compileSdk.get().toInteger() defaultConfig { - minSdkVersion rootProject.ext.minSdkVersion + minSdkVersion libs.versions.minSdk.get() testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aarMetadata { - minCompileSdk = rootProject.ext.compileSdkVersion + minCompileSdk = libs.versions.compileSdk.get().toInteger() } } From e73ab47f3a4151af80d6437fc63ac948cb84a899 Mon Sep 17 00:00:00 2001 From: kaush <1042037+kaushikgopal@users.noreply.github.com> Date: Tue, 25 Apr 2023 07:34:53 -0700 Subject: [PATCH 3/5] move kotlin-andorid plugin --- app/build.gradle | 2 +- build.gradle | 2 -- gradle/libs.versions.toml | 6 +++--- library/build.gradle | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fce7fd6a..72361b63 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ plugins { id 'com.android.application' - id 'kotlin-android' + alias libs.plugins.kotlin.android } android { diff --git a/build.gradle b/build.gradle index 13332ad1..8824d384 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ buildscript { ext { - kotlin_version = '1.8.0' coroutines_version = '1.6.4' } @@ -11,7 +10,6 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.4.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 25530480..ab0b1ff2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,8 +16,8 @@ trueTimeRx = "3.5" [libraries] # Dependencies of the included build-logic -android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } -kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +#android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } +#kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } @@ -30,4 +30,4 @@ truetime-rx = { group = "com.github.instacart.truetime-android", name = "library [plugins] -android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } diff --git a/library/build.gradle b/library/build.gradle index 4e11aea2..78d89efe 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,6 +1,6 @@ plugins { id 'com.android.library' - id 'kotlin-android' + alias libs.plugins.kotlin.android id 'maven-publish' } From b7c6a60ec064b6eae063b06988a4e1ab31861c2c Mon Sep 17 00:00:00 2001 From: kaush <1042037+kaushikgopal@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:29:25 -0700 Subject: [PATCH 4/5] move plugins android.library|application --- app/build.gradle | 2 +- build.gradle | 8 -------- gradle/libs.versions.toml | 2 ++ library/build.gradle | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 72361b63..b91142e7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.android.application' + alias libs.plugins.android.application alias libs.plugins.kotlin.android } diff --git a/build.gradle b/build.gradle index 8824d384..06e3125d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,8 @@ buildscript { - ext { - coroutines_version = '1.6.4' - } - repositories { google() mavenCentral() } - - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - } } plugins { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ab0b1ff2..50cec92d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,4 +30,6 @@ truetime-rx = { group = "com.github.instacart.truetime-android", name = "library [plugins] +android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } +android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } diff --git a/library/build.gradle b/library/build.gradle index 78d89efe..6f9966a4 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.android.library' + alias libs.plugins.android.library alias libs.plugins.kotlin.android id 'maven-publish' } From 0a7ff4db65bfec2f728ea1f743c2d7b174fc3a7d Mon Sep 17 00:00:00 2001 From: kaush <1042037+kaushikgopal@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:29:34 -0700 Subject: [PATCH 5/5] move plugin spotless --- build.gradle | 2 +- gradle/libs.versions.toml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 06e3125d..5d9006b3 100644 --- a/build.gradle +++ b/build.gradle @@ -9,9 +9,9 @@ plugins { // alias for plugins that come from the version catalog file libs.versions.toml // ... + alias(libs.plugins.spotless) // id for plugins that don't come from the version catalog file - id "com.diffplug.spotless" version "6.15.0" } ext { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 50cec92d..0956ba74 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,6 +10,7 @@ constraintlayout = "2.1.4" kotlin = "1.8.10" kotlinxCoroutines = "1.6.4" rxJava = "2.1.1" +spotless = "6.15.0" trueTime = "4.0.0.alpha" trueTimeRx = "3.5" @@ -33,3 +34,4 @@ truetime-rx = { group = "com.github.instacart.truetime-android", name = "library android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }