Skip to content

Commit

Permalink
chore: cleanup Gradle Version Catalog (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMarquis authored Feb 28, 2025
1 parent f19bb91 commit f2079f9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 59 deletions.
8 changes: 5 additions & 3 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ private operator fun VersionCatalog.getValue(
IllegalStateException("Missing catalog version ${property.name}")
}

val ktlint: VersionConstraint by extensions.getByType<VersionCatalogsExtension>().named("libs")
val ktlint = extensions.getByType<VersionCatalogsExtension>()
.named("libs")
.findLibrary("ktlint-bom").orElseThrow()

// This block is a copy of SparkSpotlessPlugin since this included build can't use it's own plugins...
spotless {
Expand All @@ -98,13 +100,13 @@ spotless {
}
kotlin {
target("src/**/*.kt")
ktlint(ktlint.toString())
ktlint(ktlint.get().version)
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(licenseHeader)
}
kotlinGradle {
ktlint(ktlint.toString())
ktlint(ktlint.get().version)
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ internal class SparkProperties private constructor(project: Project) {

@Suppress("HasPlatformType", "PropertyName")
internal class SparkVersions(catalog: VersionCatalog) {
val `androidx-compose-compiler` by catalog
val `targetSdk` by catalog
val `minCompileSdk` by catalog
val `compileSdk` by catalog
val `kotlin` by catalog
val `ktlint` by catalog

private operator fun VersionCatalog.getValue(
thisRef: Any?,
Expand All @@ -62,6 +60,7 @@ internal class SparkLibraries(catalog: VersionCatalog) {
val `androidx-compose-bom` by catalog
val `dokka-android-documentation-plugin` by catalog
val `kotlin-bom` by catalog
val `ktlint-bom` by catalog

private operator fun VersionCatalog.getValue(
thisRef: Any?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal class SparkSpotlessPlugin : Plugin<Project> {
with(target) {
apply(plugin = "com.diffplug.spotless")

val ktlint = spark().versions.ktlint
val ktlint = spark().libraries.`ktlint-bom`.get().version
configure<SpotlessExtension> {
val licenseHeader = rootProject.file("spotless/spotless.kt")
format("misc") {
Expand Down
88 changes: 37 additions & 51 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,16 @@ accompanist = "0.36.0"
android-gradlePlugin = "8.8.2"
androidx-activity = "1.10.0"
androidx-appCompat = "1.7.0"
androidx-compose-bom = "2025.02.00"
androidx-graphics = "1.0.1"
androidx-lifecycle = "2.8.7"
androidx-navigation = "2.8.8"
androidx-savedstate = "1.2.1"
androidx-core = "1.15.0"
androidx-window = "1.3.0"
coil = "2.7.0"
compileSdk = "35"
datastore = "1.1.3"
dependencyGuard = "0.5.0"
dokka = "1.9.20"
junit = "4.13.2"
kotlin = "2.1.10"
kotlinx-coroutines = "1.10.1"
kotlinx-collections-immutable = "0.3.8"
kotlinx-serialization-json = "1.8.0"
ktlint = "1.5.0"
lint = "31.8.2"
minCompileSdk = "24"
material-motion = "2.0.1"
paparazzi = "1.3.5"
slackLint = "1.4.2"
spotless = "7.0.2"
targetSdk = "35"
testParameterInjector = "1.18"
constraintlayout = "2.2.0"
constraintlayoutCompose = "1.1.0"

[libraries]

accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" }
accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "accompanist" }
accompanist-pager = { module = "com.google.accompanist:accompanist-pager", version.ref = "accompanist" }
Expand All @@ -42,11 +21,12 @@ accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiper

androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
# https://androidx.tech/artifacts/appcompat/appcompat-resources/

androidx-appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appCompat" }
androidx-appCompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appCompat" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }

androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics" }
androidx-compose-bom = "androidx.compose:compose-bom:2025.02.00"
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" }
androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" }
androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" }
Expand All @@ -55,37 +35,44 @@ androidx-compose-material3-windowSizeClass = { module = "androidx.compose.materi
androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" }
androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
# https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/package-summary
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
androidx-constraintlayoutCompose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintlayoutCompose" }
androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text-google-fonts" }
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" }
androidx-compose-ui-testJUnit = { module = "androidx.compose.ui:ui-test-junit4" }
androidx-compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" }
androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text-google-fonts" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" }
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-graphics-shapes = { module = "androidx.graphics:graphics-shapes", version.ref = "androidx-graphics" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" }
androidx-savedstate = { module = "androidx.savedstate:savedstate-ktx", version.ref = "androidx-savedstate" }
androidx-window = { module = "androidx.window:window", version.ref = "androidx-window" }
# https://mvnrepository.com/artifact/androidx.test.ext/truth
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
androidx-test-truth = { module = "androidx.test.ext:truth", version = "1.6.0" }

androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.2.0"
androidx-constraintlayout-compose = "androidx.constraintlayout:constraintlayout-compose:1.1.0"

androidx-core = "androidx.core:core-ktx:1.15.0"

androidx-graphics-shapes = "androidx.graphics:graphics-shapes:1.0.1"

androidx-lifecycle-viewmodel = "androidx.lifecycle:lifecycle-viewmodel:2.8.7"

androidx-navigation-compose = "androidx.navigation:navigation-compose:2.8.8"

androidx-savedstate = "androidx.savedstate:savedstate-ktx:1.2.1"

androidx-test-runner = "androidx.test:runner:1.6.2"
androidx-test-truth = "androidx.test.ext:truth:1.6.0"

androidx-window = "androidx.window:window:1.3.0"

# https://coil-kt.github.io/coil/
coil = { module = "io.coil-kt:coil", version.ref = "coil" }
coilCompose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
coil-bom = "io.coil-kt:coil-bom:2.7.0"
coil-compose = { module = "io.coil-kt:coil-compose" }

constraintsExplorer = "com.zachklipp:constraints-explorer:1.1.0"

# https://developer.android.com/topic/libraries/architecture/datastore
androidx-datastore = { module = "androidx.datastore:datastore" , version.ref = "datastore" }
androidx-datastore = "androidx.datastore:datastore:1.1.3"

# Docs: https://developer.android.com/studio/write/java8-support#library-desugaring
# Changelog: https://github.com/google/desugar_jdk_libs/blob/master/CHANGELOG.md
desugarJdkLibs = { module = "com.android.tools:desugar_jdk_libs", version = "2.1.5" }
desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.1.5"

dokka-android-documentation-plugin = { module = "org.jetbrains.dokka:android-documentation-plugin", version.ref = "dokka" }
dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" }
Expand All @@ -97,33 +84,32 @@ gradlePlugins-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", vers
gradlePlugins-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
gradlePlugins-spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }

junit = { module = "junit:junit", version.ref = "junit" }
junit = "junit:junit:4.13.2"

kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinx-collections-immutable" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }

ktlint-bom = { module = "com.pinterest.ktlint:ktlint-bom", version.ref = "ktlint" }
kotlinx-collections-immutable = "org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8"
kotlinx-serialization-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0"

ktlint-bom = "com.pinterest.ktlint:ktlint-bom:1.5.0"

lint = { module = "com.android.tools.lint:lint", version.ref = "lint" }
lint-api = { module = "com.android.tools.lint:lint-api", version.ref = "lint" }
lint-checks = { module = "com.android.tools.lint:lint-checks", version.ref = "lint" }
lint-tests = { module = "com.android.tools.lint:lint-tests", version.ref = "lint" }

material-motion = { module = "io.github.fornewid:material-motion-compose-core", version.ref = "material-motion" }
material-motion = "io.github.fornewid:material-motion-compose-core:2.0.1"

# https://github.com/robolectric/robolectric
robolectric = { module = "org.robolectric:robolectric", version = "4.14.1" }
robolectric = "org.robolectric:robolectric:4.14.1"

slack-lint-compose = { module = "com.slack.lint.compose:compose-lint-checks", version.ref = "slackLint" }
slack-lint-compose = "com.slack.lint.compose:compose-lint-checks:1.4.2"

# https://github.com/google/TestParameterInjector
testParameterInjector = { module = "com.google.testparameterinjector:test-parameter-injector", version.ref = "testParameterInjector" }
testParameterInjector = "com.google.testparameterinjector:test-parameter-injector:1.18"

[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradlePlugin" }
Expand All @@ -132,7 +118,7 @@ android-library = { id = "com.android.library", version.ref = "android-gradlePlu
android-lint = { id = "com.android.lint", version.ref = "android-gradlePlugin" }
android-test = { id = "com.android.test", version.ref = "android-gradlePlugin" }
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
paparazzi = "app.cash.paparazzi:1.3.5"
dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Expand Down
5 changes: 3 additions & 2 deletions spark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ android {

dependencies {
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.constraintlayoutCompose)
implementation(libs.androidx.constraintlayout.compose)
lintPublish(projects.sparkLint)
lintChecks(libs.slack.lint.compose)

Expand All @@ -75,7 +75,8 @@ dependencies {
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.constraintsExplorer)
implementation(libs.androidx.compose.ui.util)
api(libs.coilCompose)
api(platform(libs.coil.bom))
api(libs.coil.compose)
api(libs.kotlinx.collections.immutable)

testImplementation(libs.junit)
Expand Down
1 change: 1 addition & 0 deletions spark/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ com.squareup.okhttp3:okhttp:4.12.0
com.squareup.okio:okio-jvm:3.9.0
com.squareup.okio:okio:3.9.0
io.coil-kt:coil-base:2.7.0
io.coil-kt:coil-bom:2.7.0
io.coil-kt:coil-compose-base:2.7.0
io.coil-kt:coil-compose:2.7.0
io.coil-kt:coil:2.7.0
Expand Down

0 comments on commit f2079f9

Please sign in to comment.