Skip to content

Commit

Permalink
Move dependency versions to a libs.versions.toml catalogue.
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth J. Shackleton <[email protected]>
  • Loading branch information
kennethshackleton committed Apr 23, 2024
1 parent ac3bd60 commit 39359d2
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 120 deletions.
14 changes: 7 additions & 7 deletions AndroidCLI/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("io.gitlab.arturbosch.detekt")
id("org.jlleitschuh.gradle.ktlint")
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
}

repositories {
Expand All @@ -28,7 +28,7 @@ repositories {

android {
compileSdk = Versions.ANDROID_SDK.version.toInt()
buildToolsVersion = Versions.ANDROID_BUILD_TOOLS.version
buildToolsVersion = libs.android.tools.gradle.get().version!!
namespace = "com.bloomberg.selekt.cli"
defaultConfig {
applicationId = "com.bloomberg.selekt.cli"
Expand Down Expand Up @@ -59,9 +59,9 @@ android {

dependencies {
implementation(projects.selektAndroid)
implementation(androidX("appcompat", version = "1.0.2"))
implementation(androidX("core", "ktx", version = "1.0.2"))
implementation(androidX("paging", "runtime", "2.1.0"))
implementation(androidX("constraintlayout", version = "1.1.3"))
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.paging)
runtimeOnly(projects.selektAndroidSqlcipher)
}
24 changes: 11 additions & 13 deletions AndroidLibBenchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("androidx.benchmark") version Versions.ANDROID_BENCHMARK.version
id("io.gitlab.arturbosch.detekt")
id("org.jlleitschuh.gradle.ktlint")
alias(libs.plugins.androidx.benchmark)
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
}

repositories {
Expand All @@ -29,7 +29,7 @@ repositories {

android {
compileSdkVersion(Versions.ANDROID_SDK.version.toInt())
buildToolsVersion(Versions.ANDROID_BUILD_TOOLS.version)
buildToolsVersion(libs.android.tools.gradle.get().version!!)
namespace = "com.bloomberg.selekt.android.benchmark"
defaultConfig {
minSdkVersion(21)
Expand All @@ -49,13 +49,11 @@ android {

dependencies {
androidTestImplementation(projects.selektAndroid)
androidTestImplementation("junit:junit:${Versions.JUNIT4}")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test:rules:1.5.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation(androidX("benchmark", "junit4", Versions.ANDROID_BENCHMARK.version))
androidTestImplementation(kotlin("test", Versions.KOTLIN.version))
androidTestImplementation(kotlin("test-junit", Versions.KOTLIN.version))
androidTestImplementation(kotlinX("coroutines-core", Versions.KOTLINX_COROUTINES.version))
testImplementation(kotlinX("coroutines-core", Versions.KOTLINX_COROUTINES.version))
androidTestImplementation(libs.androidx.test.rules)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.junit.junit)
androidTestImplementation(libs.kotlin.test)
androidTestImplementation(libs.kotlin.test.junit)
androidTestImplementation(libs.kotlinx.coroutines.core)
testImplementation(libs.kotlinx.coroutines.core)
}
2 changes: 1 addition & 1 deletion OpenSSL/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {

plugins {
base
id("de.undercouch.download") version Versions.GRADLE_DOWNLOAD_TASK_PLUGIN.version
alias(libs.plugins.undercouch.download)
}

fun Project.openSslVersion() = property("openssl.version").toString()
Expand Down
40 changes: 19 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.LibraryExtension
import io.github.gradlenexus.publishplugin.NexusRepositoryContainer
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import java.net.URL
Expand All @@ -34,13 +33,13 @@ import org.jlleitschuh.gradle.ktlint.tasks.GenerateReportsTask

plugins {
base
id("io.gitlab.arturbosch.detekt") version Versions.DETEKT.version
id("io.github.gradle-nexus.publish-plugin") version Versions.NEXUS_PLUGIN.version
id("org.jetbrains.dokka") version Versions.DOKKA.version
id("org.jetbrains.kotlinx.kover") version Versions.KOTLINX_KOVER.version
id("org.jetbrains.qodana") version Versions.QODANA_PLUGIN.version
id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT_GRADLE_PLUGIN.version
id("org.jetbrains.gradle.plugin.idea-ext") version Versions.IDE_EXT_GRADLE_PLUGIN.version
alias(libs.plugins.dokka)
alias(libs.plugins.kover)
alias(libs.plugins.nexus)
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
alias(libs.plugins.ideaExt)
alias(libs.plugins.qodana)
}

repositories {
Expand All @@ -52,9 +51,9 @@ version = selektVersionName
logger.quiet("Group: {}; Version: {}", group, version)

nexusPublishing {
repositories(Action<NexusRepositoryContainer> {
repositories {
sonatype()
})
}
transitionCheckOptions {
maxRetries.set(180)
delayBetween.set(Duration.ofSeconds(10L))
Expand All @@ -66,7 +65,6 @@ dependencies {
kover(projects.selektApi)
kover(projects.selektJava)
kover(projects.selektSqlite3Classes)
ktlint("com.pinterest:ktlint:${Versions.KTLINT}")
}

subprojects {
Expand All @@ -83,16 +81,17 @@ subprojects {
plugins.withId(it) {
dependencies {
configurations.getByName("compileOnly").apply {
add(name, "com.google.code.findbugs:jsr305:[2.0.2, ${Versions.JSR_305}]")
add(name, "com.google.code.findbugs:jsr305:[2.0.2, ${libs.findbugs.jsr305.get().version}]")
}
configurations.getByName("implementation").apply {
platform(kotlinX("coroutines-bom", version = Versions.KOTLINX_COROUTINES.version))
add(name, platform(libs.kotlin.bom))
add(name, platform(libs.kotlinx.coroutines.bom))
}
configurations.getByName("testImplementation") {
add(name, kotlin("test", Versions.KOTLIN_TEST.version))
add(name, kotlinX("coroutines-core", version = Versions.KOTLINX_COROUTINES.version))
add(name, "org.mockito:mockito-core:${Versions.MOCKITO}")
add(name, "org.mockito.kotlin:mockito-kotlin:${Versions.MOCKITO_KOTLIN}")
add(name, libs.kotlin.test)
add(name, libs.kotlinx.coroutines.core)
add(name, libs.mockito.core)
add(name, libs.mockito.kotlin)
}
}
}
Expand Down Expand Up @@ -161,7 +160,6 @@ subprojects {
}
plugins.withId("io.gitlab.arturbosch.detekt") {
configure<DetektExtension> {
toolVersion = Versions.DETEKT.version
source = files("src")
config = files("${rootProject.projectDir}/config/detekt/config.yml")
buildUponDefaultConfig = true
Expand Down Expand Up @@ -193,8 +191,9 @@ subprojects {
moduleName.set("Selekt")
dokkaSourceSets.named("main") {
sourceLink {
remoteUrl.set(URL("https://github.com/bloomberg/selekt/tree/master/" +
"${this@configureEach.project.name}/src/main/kotlin"))
remoteUrl.set(URL(
"https://github.com/bloomberg/selekt/tree/master/${this@configureEach.project.name}/src/main/kotlin"
))
localDirectory.set(file("src/main/kotlin"))
}
includeNonPublic.set(false)
Expand All @@ -209,7 +208,6 @@ subprojects {
allprojects {
plugins.withId("org.jlleitschuh.gradle.ktlint") {
configure<KtlintExtension> {
version.set(Versions.KTLINT.version)
disabledRules.set(setOf("import-ordering", "indent", "wrapping"))
reporters {
reporter(ReporterType.HTML)
Expand Down
7 changes: 2 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* limitations under the License.
*/

// TODO Move me.
val kotlinVersion = "1.9.23"

plugins {
`kotlin-dsl`
`java-gradle-plugin`
Expand All @@ -37,6 +34,6 @@ gradlePlugin {
}

dependencies {
implementation(kotlin("gradle-plugin", version = kotlinVersion))
implementation("com.android.tools.build:gradle:8.3.2")
implementation(kotlin("gradle-plugin", version = libs.versions.kotlin.get()))
implementation(libs.android.tools.gradle)
}
8 changes: 8 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@
*/

rootProject.name = "buildSrc"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
14 changes: 3 additions & 11 deletions buildSrc/src/main/kotlin/SelektExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,17 @@

import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.artifacts.DependencySubstitutions
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.provider.Provider
import org.gradle.api.publish.maven.MavenPom
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI

fun DependencyHandler.androidX(module: String, suffix: String? = null, version: String? = null): Any =
"androidx.$module:$module${suffix?.let { "-$it" }.orEmpty()}${version?.let { ":$it" }.orEmpty()}"
val <T> NamedDomainObjectContainer<T>.debug: T get() = getByName("debug")

fun DependencyHandler.kotlinX(module: String, version: String? = null): Any =
"org.jetbrains.kotlinx:kotlinx-$module${version?.let { ":$version" }.orEmpty()}"
fun <T> NamedDomainObjectContainer<T>.debug(configure: T.() -> Unit) = getByName("debug", configure)

val <T> NamedDomainObjectContainer<T>.debug: T get() = requireNotNull(getByName("debug"))

fun <T> NamedDomainObjectContainer<T>.debug(configure: T.() -> Unit) = requireNotNull(getByName("debug", configure))

fun <T> NamedDomainObjectContainer<T>.release(configure: T.() -> Unit) = requireNotNull(getByName("release", configure))
fun <T> NamedDomainObjectContainer<T>.release(configure: T.() -> Unit) = getByName("release", configure)

fun Project.gitCommit(): Provider<String> = providers.exec {
commandLine("git", "rev-parse", "HEAD")
Expand Down
29 changes: 1 addition & 28 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,8 @@ enum class Versions(
val version: String,
private val url: URL
) {
ANDROID_BENCHMARK("1.2.0-alpha13", URL("https://developer.android.com/studio/profile/benchmark")),
ANDROID_BUILD_TOOLS("34.0.0", URL("https://developer.android.com/studio/releases/build-tools")),
ANDROID_GRADLE_PLUGIN("8.3.2", URL("https://developer.android.com/tools/revisions/gradle-plugin.html")),
ANDROID_LINT("30.0.2", URL("https://github.com/googlesamples/android-custom-lint-rules")),
ANDROID_NDK("26.3.11579264", URL("https://developer.android.com/ndk")),
ANDROID_SDK("34", URL("https://developer.android.com/sdk")),
ANDROIDX_LIVE_DATA("2.5.1", URL("https://developer.android.com/topic/libraries/architecture/livedata")),
ANDROIDX_ROOM("2.6.1", URL("https://developer.android.com/jetpack/androidx/releases/room")),
CMAKE("3.22.1", URL("https://cmake.org")),
DETEKT("1.22.0", URL("https://github.com/arturbosch/detekt")),
DOKKA("1.9.10", URL("https://github.com/Kotlin/dokka")),
GRADLE_DOWNLOAD_TASK_PLUGIN("5.4.0", URL("https://github.com/michel-kraemer/gradle-download-task")),
GRADLE_LICENSEE_PLUGIN("1.6.0", URL("https://github.com/cashapp/licensee")),
IDE_EXT_GRADLE_PLUGIN("1.1.7", URL("https://github.com/JetBrains/gradle-idea-ext-plugin")),
JMH("1.36", URL("https://openjdk.java.net/projects/code-tools/jmh/")),
JSR_305("3.0.2", URL("https://code.google.com/archive/p/jsr-305/")),
JUNIT4("4.13.2", URL("https://github.com/junit-team/junit4")),
JUNIT5("5.10.2", URL("https://junit.org/junit5/")),
KOTLIN("1.9.23", URL("https://github.com/JetBrains/kotlin")),
KOTLIN_TEST(KOTLIN.version, URL("https://github.com/JetBrains/kotlin")),
KOTLINX_COROUTINES("1.7.3", URL("https://github.com/Kotlin/kotlinx.coroutines")),
KOTLINX_KOVER("0.7.6", URL("https://github.com/Kotlin/kotlinx-kover")),
KTLINT("0.45.2", URL("https://github.com/pinterest/ktlint")),
KTLINT_GRADLE_PLUGIN("11.5.0", URL("https://github.com/JLLeitschuh/ktlint-gradle")),
MOCKITO("5.11.0", URL("https://github.com/mockito/mockito")),
MOCKITO_KOTLIN("5.3.1", URL("https://github.com/mockito/mockito-kotlin")),
NEXUS_PLUGIN("1.3.0", URL("https://github.com/gradle-nexus/publish-plugin")),
QODANA_PLUGIN("0.1.12", URL("https://www.jetbrains.com/help/qodana/qodana-gradle-plugin.html")),
ROBOLECTRIC_ANDROID_ALL("12.1-robolectric-8229987", URL("https://github.com/robolectric/robolectric"));
JMH("1.36", URL("https://openjdk.java.net/projects/code-tools/jmh/"));

override fun toString() = version

Expand Down
49 changes: 49 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml

[versions]
kotlin = "1.9.23"
room = "2.6.1"

[libraries]
android-tools-lint = { group = "com.android.tools.lint", name = "lint", version = "30.0.2" }
android-tools-lint-api = { group = "com.android.tools.lint", name = "lint-api", version = "30.0.2" }
android-tools-gradle = { group = "com.android.tools.build", name = "gradle", version = "8.3.2" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version = "1.0.2" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version = "1.1.3" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version = "1.0.2" }
androidx-paging = { group = "androidx.paging", name = "paging-runtime", version = "2.1.0" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version = "2.5.1" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
androidx-test-ext = { group = "androidx.test.ext", name = "junit", version = "1.1.5" }
androidx-test-rules = { group = "androidx.test", name = "rules", version = "1.5.0" }
androidx-test-runner = { group = "androidx.test", name = "runner", version = "1.5.2" }
findbugs-jsr305 = { group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2" }
jmh-core = { group = "org.openjdk.jmh", name = "jmh-core", version = "1.36" }
jmh-generator-annprocess = { group = "org.openjdk.jmh", name = "jmh-generator-annprocess", version = "1.36" }
junit-junit = { group = "junit", name = "junit", version = "4.13.2" }
junit-jupiter-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version = "5.10.2" }
kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version = "1.9.23" }
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect" }
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test" }
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" }
kotlinx-coroutines-bom = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-bom", version = "1.7.3" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core" }
mockito-core = { group = "org.mockito", name = "mockito-core", version = "5.11.0" }
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version = "5.3.1" }
robolectric-android-all = { group = "org.robolectric", name = "android-all", version = "12.1-robolectric-8229987" }

[bundles]

[plugins]
androidx-benchmark = { id = "androidx.benchmark", version = "1.2.0-alpha13" }
cash-licensee = { id = "app.cash.licensee", version = "1.6.0" }
detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.22.0" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.10" }
ideaExt = { id = "org.jetbrains.gradle.plugin.idea-ext", version = "1.1.7" }
kover = { id = "org.jetbrains.kotlinx.kover", version = "0.7.6" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.5.0" }
nexus = { id = "io.github.gradle-nexus.publish-plugin", version = "1.3.0" }
qodana = { id = "org.jetbrains.qodana", version = "0.1.12" }
undercouch-download = { id = "de.undercouch.download", version = "5.4.0" }
10 changes: 5 additions & 5 deletions selekt-android-lint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ plugins {
kotlin("jvm")
`maven-publish`
signing
id("io.gitlab.arturbosch.detekt")
id("org.jlleitschuh.gradle.ktlint")
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
}

java {
Expand All @@ -33,9 +33,9 @@ java {
}

dependencies {
compileOnly("com.android.tools.lint:lint:${Versions.ANDROID_LINT}")
compileOnly("com.android.tools.lint:lint-api:${Versions.ANDROID_LINT}")
implementation(kotlin("reflect", Versions.KOTLIN.version))
compileOnly(libs.android.tools.lint.asProvider())
compileOnly(libs.android.tools.lint.api)
implementation(libs.kotlin.reflect)
}

tasks.withType<Jar>().configureEach {
Expand Down
9 changes: 5 additions & 4 deletions selekt-android-sqlcipher/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ plugins {
id("kotlin-android")
`maven-publish`
signing
id("io.gitlab.arturbosch.detekt")
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
}

repositories {
Expand All @@ -37,9 +38,9 @@ val allABIs = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")

android {
compileSdk = Versions.ANDROID_SDK.version.toInt()
buildToolsVersion = Versions.ANDROID_BUILD_TOOLS.version
buildToolsVersion = libs.android.tools.gradle.get().version!!
namespace = "com.bloomberg.selekt.android.sqlcipher"
ndkVersion = Versions.ANDROID_NDK.version
ndkVersion = "26.3.11579264"
defaultConfig {
minSdk = 21
}
Expand All @@ -59,7 +60,7 @@ android {
externalNativeBuild {
cmake {
path("$rootDir/SQLite3/CMakeLists.txt")
version = Versions.CMAKE.version
version = "3.22.1"
}
}
publishing {
Expand Down
Loading

0 comments on commit 39359d2

Please sign in to comment.