build: use gradle catalogs for dependency management

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
Aditya Wasan 2021-04-17 17:56:24 +05:30
parent 561a651dc4
commit 6772303bf5
No known key found for this signature in database
GPG Key ID: 6D6DF3BF15DE79B5
14 changed files with 133 additions and 163 deletions

View File

@ -2,7 +2,7 @@
<artifact type="jar" name="database-jvm">
<output-path>$PROJECT_DIR$/database/build/libs</output-path>
<root id="archive" name="database-jvm.jar">
<element id="module-output" name="database.Claw.database.jvmMain" />
<element id="module-output" name="Claw.database.jvmMain" />
</root>
</artifact>
</component>

View File

@ -1,14 +1,14 @@
plugins {
kotlin("jvm")
id("com.google.devtools.ksp") version Dependencies.KSP_VERSION
id("com.google.devtools.ksp")
`lobsters-plugin`
}
dependencies {
api(Dependencies.ThirdParty.Retrofit.lib)
ksp(Dependencies.ThirdParty.Moshi.ksp)
implementation(Dependencies.ThirdParty.Retrofit.moshi)
testImplementation(Dependencies.Kotlin.Coroutines.core)
api(libs.thirdparty.retrofit.lib)
ksp(libs.thirdparty.moshi.ksp)
implementation(libs.thirdparty.retrofit.moshiConverter)
testImplementation(libs.kotlin.coroutines.core)
testImplementation(kotlin("test-junit"))
testImplementation(Dependencies.Testing.mockWebServer)
testImplementation(libs.testing.mockWebServer)
}

View File

@ -5,7 +5,7 @@ plugins {
kotlin("android")
kotlin("kapt")
id("dagger.hilt.android.plugin")
id("org.jetbrains.compose") version Dependencies.JB_COMPOSE_VERSION
id("org.jetbrains.compose")
id("shot")
`versioning-plugin`
`lobsters-plugin`
@ -27,28 +27,27 @@ android {
}
dependencies {
kapt(Dependencies.AndroidX.Hilt.daggerCompiler)
kapt(libs.androidx.hilt.daggerCompiler)
implementation(projects.api)
implementation(projects.common)
implementation(projects.database)
implementation(compose.foundation)
implementation(compose.material)
implementation(Dependencies.AndroidX.appCompat)
implementation(Dependencies.AndroidX.browser)
implementation(Dependencies.AndroidX.datastore)
implementation(Dependencies.AndroidX.Compose.activity)
implementation(Dependencies.AndroidX.Compose.lifecycleViewModel)
implementation(Dependencies.AndroidX.Compose.navigation)
implementation(Dependencies.AndroidX.Compose.paging)
implementation(Dependencies.AndroidX.Compose.uiTooling)
implementation(Dependencies.AndroidX.Hilt.dagger)
implementation(Dependencies.AndroidX.Lifecycle.runtimeKtx)
implementation(Dependencies.AndroidX.Lifecycle.viewmodelKtx)
implementation(Dependencies.Kotlin.Coroutines.android)
implementation(Dependencies.ThirdParty.accompanistCoil)
implementation(Dependencies.ThirdParty.accompanistFlow)
implementation(Dependencies.ThirdParty.Moshi.lib)
implementation(Dependencies.ThirdParty.Retrofit.moshi)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.browser)
implementation(libs.androidx.datastore)
implementation(libs.androidx.compose.activity)
implementation(libs.androidx.compose.lifecycleViewModel)
implementation(libs.androidx.compose.navigation)
implementation(libs.androidx.compose.paging)
implementation(libs.androidx.compose.uiTooling)
implementation(libs.androidx.hilt.dagger)
implementation(libs.bundles.androidxLifecycle)
implementation(libs.kotlin.coroutines.android)
implementation(libs.thirdparty.accompanistCoil)
implementation(libs.thirdparty.accompanistFlow)
implementation(libs.thirdparty.moshi.lib)
implementation(libs.thirdparty.retrofit.moshiConverter)
testImplementation(kotlin("test-junit"))
androidTestImplementation(kotlin("test-junit"))
}

View File

@ -4,7 +4,8 @@ subprojects {
configurations.configureEach {
resolutionStrategy {
// Retrofit depends on a very old version of Moshi that causes moshi-ksp to fail
force(Dependencies.ThirdParty.Moshi.lib)
// Using gradle catalog here prevents compilation
force("com.squareup.moshi:moshi:1.12.0")
}
}
}

View File

@ -3,6 +3,7 @@ plugins { `kotlin-dsl` }
repositories {
google()
gradlePluginPortal()
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
kotlinDslPluginOptions { experimentalWarning.set(false) }
@ -25,10 +26,12 @@ gradlePlugin {
}
dependencies {
implementation(Plugins.android)
implementation(Plugins.hilt)
implementation(Plugins.jsemver)
implementation(Plugins.kotlin)
implementation(Plugins.shot)
implementation(Plugins.sqldelight)
implementation("com.android.tools.build:gradle:7.0.0-alpha14")
implementation("com.google.dagger:hilt-android-gradle-plugin:2.34.1-beta")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
implementation("com.google.devtools.ksp:symbol-processing-gradle-plugin:1.4.32-1.0.0-alpha07")
implementation("com.github.zafarkhaja:java-semver:0.9.0")
implementation("com.karumi:shot:5.10.3")
implementation("com.squareup.sqldelight:gradle-plugin:1.4.4")
implementation("org.jetbrains.compose:compose-gradle-plugin:0.4.0-build183")
}

View File

@ -1,17 +0,0 @@
plugins { `kotlin-dsl` }
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
kotlinDslPluginOptions { experimentalWarning.set(false) }
// force compilation of Dependencies.kt so it can be referenced in buildSrc/build.gradle.kts
sourceSets.main {
java {
setSrcDirs(setOf(projectDir.parentFile.resolve("src/main/java")))
include("Dependencies.kt")
}
}

View File

@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

View File

@ -30,6 +30,6 @@ class CoreLibraryDesugaringPlugin : Plugin<Project> {
private fun TestedExtension.configure(project: Project) {
compileOptions.isCoreLibraryDesugaringEnabled = true
project.dependencies.add("coreLibraryDesugaring", Dependencies.AndroidX.coreLibraryDesugaring)
project.dependencies.add("coreLibraryDesugaring", "com.android.tools:desugar_jdk_libs:1.0.10")
}
}

View File

@ -1,102 +0,0 @@
/*
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
private const val DAGGER_HILT_VERSION = "2.34.1-beta"
object Plugins {
const val android = "com.android.tools.build:gradle:7.0.0-alpha14"
const val hilt = "com.google.dagger:hilt-android-gradle-plugin:${DAGGER_HILT_VERSION}"
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
const val jsemver = "com.github.zafarkhaja:java-semver:0.9.0"
const val shot = "com.karumi:shot:5.10.3"
const val sqldelight = "com.squareup.sqldelight:gradle-plugin:1.4.4"
}
object Dependencies {
const val COMPOSE_VERSION = "1.0.0-beta04"
const val KSP_VERSION = "1.4.32-1.0.0-alpha07"
const val JB_COMPOSE_VERSION = "0.4.0-build183"
object Kotlin {
object Coroutines {
private const val version = "1.4.3"
const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
const val jvmCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:$version"
}
}
object AndroidX {
const val appCompat = "androidx.appcompat:appcompat:1.3.0-rc01"
const val browser = "androidx.browser:browser:1.3.0"
const val coreLibraryDesugaring = "com.android.tools:desugar_jdk_libs:1.0.10"
const val datastore = "androidx.datastore:datastore-preferences:1.0.0-alpha08"
object Compose {
const val activity = "androidx.activity:activity-compose:1.3.0-alpha06"
const val compiler = "androidx.compose.compiler:compiler:$COMPOSE_VERSION"
const val foundation = "androidx.compose.foundation:foundation:$COMPOSE_VERSION"
const val foundationLayout = "androidx.compose.foundation:foundation-layout:$COMPOSE_VERSION"
const val lifecycleViewModel = "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04"
const val material = "androidx.compose.material:material:$COMPOSE_VERSION"
const val navigation = "androidx.navigation:navigation-compose:1.0.0-alpha10"
const val paging = "androidx.paging:paging-compose:1.0.0-alpha08"
const val runtime = "androidx.compose.runtime:runtime:$COMPOSE_VERSION"
const val ui = "androidx.compose.ui:ui:$COMPOSE_VERSION"
const val uiUnit = "androidx.compose.ui:ui-unit:$COMPOSE_VERSION"
const val uiTooling = "androidx.compose.ui:ui-tooling:$COMPOSE_VERSION"
}
object Hilt {
const val dagger = "com.google.dagger:hilt-android:$DAGGER_HILT_VERSION"
const val daggerCompiler = "com.google.dagger:hilt-compiler:$DAGGER_HILT_VERSION"
}
object Lifecycle {
private const val version = "2.4.0-alpha01"
const val runtimeKtx = "androidx.lifecycle:lifecycle-runtime-ktx:$version"
const val viewmodelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:$version"
}
}
object ThirdParty {
private const val accompanistVersion = "0.7.1"
const val accompanistCoil = "com.google.accompanist:accompanist-coil:$accompanistVersion"
const val accompanistFlow = "com.google.accompanist:accompanist-flowlayout:$accompanistVersion"
const val kamel = "com.alialbaali.kamel:kamel-image:0.2.0"
const val pullToRefresh = "com.puculek.pulltorefresh:pull-to-refresh-compose:1.0.1"
object Moshi {
const val lib = "com.squareup.moshi:moshi:1.12.0"
const val ksp = "dev.zacsweers.moshix:moshi-ksp:0.10.0"
}
object Retrofit {
private const val version = "2.9.0"
const val lib = "com.squareup.retrofit2:retrofit:$version"
const val moshi = "com.squareup.retrofit2:converter-moshi:$version"
}
object SQLDelight {
private const val version = "1.4.4"
const val jvmDriver = "com.squareup.sqldelight:sqlite-driver:$version"
const val androidDriver = "com.squareup.sqldelight:android-driver:$version"
}
}
object Testing {
const val mockWebServer = "com.squareup.okhttp3:mockwebserver3-junit4:5.0.0-alpha.2"
}
}

View File

@ -1,7 +1,7 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose") version Dependencies.JB_COMPOSE_VERSION
id("org.jetbrains.compose")
`lobsters-plugin`
}
@ -26,7 +26,7 @@ kotlin {
sourceSets {
named("androidMain") {
dependencies {
implementation(Dependencies.AndroidX.browser)
implementation(libs.androidx.browser)
}
}

View File

@ -26,18 +26,18 @@ kotlin {
}
val jvmTest by getting {
dependencies {
implementation(Dependencies.Kotlin.Coroutines.core)
implementation(libs.kotlin.coroutines.core)
implementation(kotlin("test-junit"))
}
}
val jvmMain by getting {
dependencies {
implementation(Dependencies.ThirdParty.SQLDelight.jvmDriver)
implementation(libs.thirdparty.sqldelight.jvmDriver)
}
}
val androidMain by getting {
dependencies {
implementation(Dependencies.ThirdParty.SQLDelight.androidDriver)
implementation(libs.thirdparty.sqldelight.androidDriver)
}
}
}

View File

@ -3,12 +3,10 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose") version Dependencies.JB_COMPOSE_VERSION
id("org.jetbrains.compose")
`lobsters-plugin`
}
repositories { maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
kotlin {
jvm()
sourceSets {
@ -19,9 +17,9 @@ kotlin {
implementation(projects.common)
implementation(projects.database)
implementation(compose.material)
implementation(Dependencies.Kotlin.Coroutines.jvmCore)
implementation(Dependencies.ThirdParty.kamel)
implementation(Dependencies.ThirdParty.Retrofit.moshi)
implementation(libs.kotlin.coroutines.jvm)
implementation(libs.thirdparty.kamel)
implementation(libs.thirdparty.retrofit.moshiConverter)
}
}
}

80
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,80 @@
# Centralized versions for dependencies that share versions
[versions]
accompanist = "0.7.1"
androidx_test = "1.4.0-alpha05"
compose = "1.0.0-beta04"
coroutines = "1.4.3"
dagger_hilt = "2.34.1-beta"
jb_compose = "0.4.0-build183"
kotlin = "1.4.32"
ksp = "1.4.32-1.0.0-alpha07"
lifecycle = "2.4.0-alpha01"
retrofit = "2.9.0"
sqldelight = "1.4.4"
[libraries]
# buildSrc dependencies
androidGradlePlugin = "com.android.tools.build:gradle:7.0.0-alpha14"
composeGradlePlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "jb_compose" }
hiltGradlePlugin = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "dagger_hilt" }
jsemverGradlePlugin = "com.github.zafarkhaja:java-semver:0.9.0"
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kspGradlePlugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
shotGradlePlugin = "com.karumi:shot:5.10.3"
sqldelightGradlePlugin = { module = "com.squareup.sqldelight:gradle-plugin", version.ref = "sqldelight" }
# Kotlin dependencies
kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlin-coroutines-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jvm", version.ref = "coroutines" }
# AndroidX dependencies
androidx-appcompat = "androidx.appcompat:appcompat:1.3.0-rc01"
androidx-browser = "androidx.browser:browser:1.3.0"
androidx-coreLibraryDesugaring = "com.android.tools:desugar_jdk_libs:1.0.10"
androidx-datastore = "androidx.datastore:datastore-preferences:1.0.0-alpha08"
androidx-lifecycle-runtimeKtx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
androidx-lifecycle-viewmodelKtx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
# Compose dependencies
androidx-compose-activity = "androidx.activity:activity-compose:1.3.0-alpha06"
androidx-compose-lifecycleViewModel = "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04"
androidx-compose-navigation = "androidx.navigation:navigation-compose:1.0.0-alpha10"
androidx-compose-paging = "androidx.paging:paging-compose:1.0.0-alpha08"
androidx-compose-uiTooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
# Hilt dependencies
androidx-hilt-dagger = { module = "com.google.dagger:hilt-android", version.ref = "dagger_hilt" }
androidx-hilt-daggerCompiler = { module = "com.google.dagger:hilt-compiler", version.ref = "dagger_hilt" }
# Third-party dependencies
thirdparty-accompanistCoil = { module = "com.google.accompanist:accompanist-coil", version.ref = "accompanist" }
thirdparty-accompanistFlow = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "accompanist" }
thirdparty-kamel = "com.alialbaali.kamel:kamel-image:0.2.0"
thirdparty-pullToRefresh = "com.puculek.pulltorefresh:pull-to-refresh-compose:1.0.1"
# Moshi dependencies
thirdparty-moshi-lib = "com.squareup.moshi:moshi:1.12.0"
thirdparty-moshi-ksp = "dev.zacsweers.moshix:moshi-ksp:0.10.0"
# Retrofit dependencies
thirdparty-retrofit-lib = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
thirdparty-retrofit-moshiConverter = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit" }
# Sqldelight dependencies
thirdparty-sqldelight-jvmDriver = { module = "com.squareup.sqldelight:sqlite-driver", version.ref = "sqldelight" }
thirdparty-sqldelight-androidDriver = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }
# Testing dependencies
androidx-testing-rules = { module = "androidx.test:rules", version.ref = "androidx_test" }
androidx-testing-runner = { module = "androidx.test:runner", version.ref = "androidx_test" }
testing-junit = "junit:junit:4.13.2"
testing-mockWebServer = "com.squareup.okhttp3:mockwebserver3-junit4:5.0.0-alpha.2"
testing-kotlintest-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
# Bundles of dependencies usually used together so they can be included in one go
[bundles]
androidxLifecycle = ["androidx-lifecycle-runtimeKtx", "androidx-lifecycle-viewmodelKtx"]
testDependencies = ["testing-junit", "testing-kotlintest-junit"]
androidTestDependencies = ["androidx-testing-rules", "androidx-testing-runner"]

View File

@ -7,6 +7,7 @@ include(":database")
include(":desktop")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
enableFeaturePreview("VERSION_CATALOGS")
pluginManagement {
repositories {