Skip to content

Commit

Permalink
Migrate to version catalogs (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 authored Aug 17, 2024
1 parent 220313d commit 58e51de
Show file tree
Hide file tree
Showing 33 changed files with 862 additions and 932 deletions.
77 changes: 39 additions & 38 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,55 @@
*/

plugins {
androidApplication()
gamedgeAndroid()
jetpackCompose()
kotlinKapt()
ksp()
daggerHilt()
id(libs.plugins.androidApplication.get().pluginId)
id(libs.plugins.gamedgeAndroid.get().pluginId)
id(libs.plugins.kotlinKapt.get().pluginId)

alias(libs.plugins.jetpackCompose)
alias(libs.plugins.ksp)
alias(libs.plugins.daggerHilt)
}

dependencies {
implementation(project(deps.local.commonDomain))
implementation(project(deps.local.commonData))
implementation(project(deps.local.core))
implementation(project(deps.local.commonUi))
implementation(project(deps.local.commonUiWidgets))
implementation(project(deps.local.igdbApi))
implementation(project(deps.local.gamespotApi))
implementation(project(deps.local.database))
implementation(project(deps.local.featureCategory))
implementation(project(deps.local.featureDiscovery))
implementation(project(deps.local.featureInfo))
implementation(project(deps.local.featureImageViewer))
implementation(project(deps.local.featureLikes))
implementation(project(deps.local.featureNews))
implementation(project(deps.local.featureSearch))
implementation(project(deps.local.featureSettings))
implementation(project(localModules.commonDomain))
implementation(project(localModules.commonData))
implementation(project(localModules.core))
implementation(project(localModules.commonUi))
implementation(project(localModules.commonUiWidgets))
implementation(project(localModules.igdbApi))
implementation(project(localModules.gamespotApi))
implementation(project(localModules.database))
implementation(project(localModules.featureCategory))
implementation(project(localModules.featureDiscovery))
implementation(project(localModules.featureInfo))
implementation(project(localModules.featureImageViewer))
implementation(project(localModules.featureLikes))
implementation(project(localModules.featureNews))
implementation(project(localModules.featureSearch))
implementation(project(localModules.featureSettings))

implementation(deps.androidX.splash)
implementation(libs.splash)

implementation(deps.compose.ui)
implementation(deps.compose.tooling)
implementation(deps.compose.foundation)
implementation(deps.compose.material)
implementation(deps.compose.runtime)
implementation(deps.compose.navigation)
implementation(deps.compose.accompanist.navigationAnimations)
implementation(libs.composeUi)
implementation(libs.composeTooling)
implementation(libs.composeFoundation)
implementation(libs.composeMaterial)
implementation(libs.composeRuntime)
implementation(libs.composeNavigation)
implementation(libs.accompanistNavigationAnimations)

implementation(deps.commons.core)
implementation(deps.commons.ktx)
implementation(libs.commonsCore)
implementation(libs.commonsKtx)

implementation(deps.google.daggerHiltAndroid)
kapt(deps.google.daggerHiltAndroidCompiler)
implementation(libs.daggerHiltAndroid)
kapt(libs.daggerHiltAndroidCompiler)

implementation(deps.misc.hiltBinder)
ksp(deps.misc.hiltBinderCompiler)
implementation(libs.hiltBinder)
ksp(libs.hiltBinderCompiler)

testImplementation(deps.testing.jUnit)
testImplementation(libs.jUnit)

androidTestImplementation(deps.testing.jUnitExt)
androidTestImplementation(libs.jUnitExt)
}

val installGitHook by tasks.registering(Copy::class) {
Expand Down
46 changes: 26 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ import org.jetbrains.kotlin.gradle.plugin.KaptExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
androidApplication() apply false
androidLibrary() apply false
kotlinAndroid() apply false
protobuf() apply false

jetpackCompose() version versions.kotlin apply false
ksp() version versions.kspPlugin apply false
daggerHilt() version versions.daggerHilt apply false
kotlinxSerialization() version versions.kotlin apply false

gradleVersions() version versions.gradleVersionsPlugin apply true
detekt() version versions.detektPlugin apply true
ktlint() version versions.ktlintPlugin apply true
// See https://github.com/gradle/gradle/issues/20084#issuecomment-1060822638
// for why it has to be done this way
id(libs.plugins.androidApplication.get().pluginId) apply false
id(libs.plugins.androidLibrary.get().pluginId) apply false
id(libs.plugins.kotlinJvm.get().pluginId) apply false
id(libs.plugins.kotlinAndroid.get().pluginId) apply false
id(libs.plugins.kotlinKapt.get().pluginId) apply false
id(libs.plugins.protobuf.get().pluginId) apply false
id(libs.plugins.gamedgeAndroid.get().pluginId) apply false
id(libs.plugins.gamedgeProtobuf.get().pluginId) apply false

alias(libs.plugins.jetpackCompose) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.daggerHilt) apply false
alias(libs.plugins.kotlinxSerialization) apply false

alias(libs.plugins.gradleVersions) apply true
alias(libs.plugins.detekt) apply true
alias(libs.plugins.ktlint) apply true
}

detekt {
Expand All @@ -55,8 +61,8 @@ tasks.withType<DependencyUpdatesTask> {
}

allprojects {
apply(plugin = PLUGIN_DETEKT)
apply(plugin = PLUGIN_KTLINT)
apply(plugin = rootProject.libs.plugins.detekt.get().pluginId)
apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId)

repositories {
mavenCentral()
Expand All @@ -65,7 +71,7 @@ allprojects {
}

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set(versions.ktlint)
version.set(rootProject.libs.versions.ktlint.get())
android.set(true)
outputToConsole.set(true)
verbose.set(true)
Expand All @@ -89,13 +95,13 @@ allprojects {
}

subprojects {
plugins.withId(PLUGIN_KOTLIN) {
plugins.withId(rootProject.libs.plugins.kotlinJvm.get().pluginId) {
extensions.findByType<KotlinProjectExtension>()?.run {
jvmToolchain(appConfig.jvmToolchainVersion)
jvmToolchain(rootProject.libs.versions.jvmToolchain.get().toInt())
}
}

plugins.withId(PLUGIN_KOTLIN_KAPT) {
plugins.withId(rootProject.libs.plugins.kotlinKapt.get().pluginId) {
extensions.findByType<KaptExtension>()?.run {
correctErrorTypes = true
}
Expand Down Expand Up @@ -124,7 +130,7 @@ subprojects {
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "androidx.lifecycle" && requested.name == "lifecycle-viewmodel-ktx") {
useVersion(deps.androidX.viewModel)
useVersion(rootProject.libs.versions.viewModel.get())
}
}
}
Expand Down
29 changes: 24 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,32 @@ repositories {
google()
}

gradlePlugin {
plugins {
create("com.paulrybitskyi.gamedge.android") {
id = "com.paulrybitskyi.gamedge.android"
implementationClass = "com.paulrybitskyi.gamedge.plugins.GamedgeAndroidPlugin"
}
create("com.paulrybitskyi.gamedge.protobuf") {
id = "com.paulrybitskyi.gamedge.protobuf"
implementationClass = "com.paulrybitskyi.gamedge.plugins.GamedgeProtobufPlugin"
}
}
}

dependencies {
implementation("com.android.tools.build:gradle:8.3.1")
// Enabling the usage of the version catalog to be used inside the buildSrc. Parenthesis
// (libs) are used to avoid a strange "Unresolved reference to version catalog" IDE error.
// For more info, see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files((libs).javaClass.superclass.protectionDomain.codeSource.location))

implementation(libs.androidPlugin)
implementation(libs.kotlinPlugin)
implementation(libs.protobufPlugin)
implementation(gradleApi()) // for custom plugins

// https://github.com/google/dagger/issues/3068#issuecomment-999118496
// Needs to be checked whether JavaPoet is still needed after AGP is updated
// because currently it forces 1.10 JavaPoet version, for some odd reason.
implementation("com.squareup:javapoet:1.13.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.10")
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
implementation(gradleApi()) // for custom plugins
implementation(libs.javaPoet)
}
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Loading

0 comments on commit 58e51de

Please sign in to comment.