From 3299df61aa534b85875857d19561b49ddfed4211 Mon Sep 17 00:00:00 2001 From: Akshat Tiwari Date: Tue, 16 Jul 2024 14:40:06 +0530 Subject: [PATCH] Migrate to version catalogs --- .gitignore | 2 ++ app/build.gradle.kts | 30 +++++++++++++----------------- build.gradle.kts | 24 +++++------------------- gradle/libs.versions.toml | 31 +++++++++++++++++++++++++++++++ iap/build.gradle.kts | 25 +++++++++++-------------- settings.gradle | 2 -- settings.gradle.kts | 18 ++++++++++++++++++ 7 files changed, 80 insertions(+), 52 deletions(-) create mode 100644 gradle/libs.versions.toml delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/.gitignore b/.gitignore index 00cc4b0..e6b6aec 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,8 @@ proguard/ # Android Studio captures folder captures/ +.kotlin + # Intellij *.iml .idea diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e6252c8..9fce47d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,18 +1,18 @@ import java.util.Properties plugins { - id("com.android.application") - id("kotlin-android") + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) } android { - compileSdk = 34 + compileSdk = libs.versions.compileSdk.get().toInt() namespace = "com.limurse.iapsample" defaultConfig { applicationId = "com.limurse.iapsample" - minSdk = 21 - targetSdk = 34 + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() versionCode = 8 versionName = "1.0.7" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -29,16 +29,12 @@ android { release { isMinifyEnabled = true isShrinkResources = true - proguardFiles( - "proguard-rules.pro" - ) + proguardFiles("proguard-rules.pro") resValue("string", "licenseKey", licenseKey) } debug { isMinifyEnabled = false - proguardFiles( - "proguard-rules.pro" - ) + proguardFiles("proguard-rules.pro") resValue("string", "licenseKey", licenseKey) } } @@ -60,9 +56,9 @@ android { dependencies { implementation(project(":iap")) - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.gridlayout:gridlayout:1.0.0") - implementation("com.google.android.material:material:1.12.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("com.intuit.sdp:sdp-android:1.1.1") -} + implementation(libs.appcompat) + implementation(libs.gridlayout) + implementation(libs.material) + implementation(libs.constraintlayout) + implementation(libs.sdp.android) +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index f6e780b..55a5317 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,23 +1,9 @@ -buildscript { - repositories { - google() - mavenCentral() - } - - val kotlinVersion = "1.9.22" - dependencies { - classpath("com.android.tools.build:gradle:8.5.0") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") - } -} - -allprojects { - repositories { - google() - mavenCentral() - } +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.android) apply false } tasks.register("clean") { delete(layout.buildDirectory) -} +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..9c44ffb --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,31 @@ +[versions] +kotlin = "2.0.0" +agp = "8.5.1" +compileSdk = "34" +targetSdk = "34" +minSdk = "21" +appcompat = "1.7.0" +gridlayout = "1.0.0" +material = "1.12.0" +constraintlayout = "2.1.4" +sdp-android = "1.1.1" +billing-ktx = "7.0.0" +lifecycle-extensions = "2.2.0" +lifecycle-runtime-ktx = "2.8.3" +junit = "4.13.2" + +[libraries] +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +gridlayout = { module = "androidx.gridlayout:gridlayout", version.ref = "gridlayout" } +material = { module = "com.google.android.material:material", version.ref = "material" } +constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } +sdp-android = { module = "com.intuit.sdp:sdp-android", version.ref = "sdp-android" } +billing-ktx = { module = "com.android.billingclient:billing-ktx", version.ref = "billing-ktx" } +lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "lifecycle-extensions" } +lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" } +junit = { module = "junit:junit", version.ref = "junit" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +android-library = { id = "com.android.library", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } \ No newline at end of file diff --git a/iap/build.gradle.kts b/iap/build.gradle.kts index ed56057..20c55c0 100644 --- a/iap/build.gradle.kts +++ b/iap/build.gradle.kts @@ -1,23 +1,21 @@ plugins { - id("com.android.library") - id("kotlin-android") + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) id("maven-publish") } android { - compileSdk = 34 + compileSdk = libs.versions.compileSdk.get().toInt() namespace = "com.limurse.iap" defaultConfig { - minSdk = 21 + minSdk = libs.versions.minSdk.get().toInt() } buildTypes { release { isMinifyEnabled = false - proguardFiles( - "proguard-rules.pro" - ) + proguardFiles("proguard-rules.pro") } } @@ -38,15 +36,14 @@ android { } } - dependencies { - implementation("com.android.billingclient:billing-ktx:7.0.0") + implementation(libs.billing.ktx) - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3") + implementation(libs.appcompat) + implementation(libs.lifecycle.extensions) + implementation(libs.lifecycle.runtime.ktx) - testImplementation("junit:junit:4.13.2") + testImplementation(libs.junit) } publishing { @@ -61,4 +58,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 46e7085..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -include ':iap' -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..e6ce9f6 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +include(":app") +include(":iap") \ No newline at end of file