summaryrefslogtreecommitdiff
path: root/buildSrc
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-03-07 11:55:08 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-04-04 12:48:04 +0200
commitd25d413415b2c429febe14fd2c34d06fd02615b5 (patch)
treecdcb010bc2f9ec1c11eb42348f01c3773e00fb6e /buildSrc
parent6021aa4278bebb34bf5603ead4b5daeabcdc4c19 (diff)
build: Move build dependencies into version catalog
This change moves build dependencies used by Gradle into the version catalog to ensure a single location for all dependency versions.
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/build.gradle.kts13
-rw-r--r--buildSrc/settings.gradle.kts10
-rw-r--r--buildSrc/src/main/kotlin/Libs.kt10
3 files changed, 17 insertions, 16 deletions
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 760f0cab..1b24b44b 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -31,10 +31,11 @@ repositories {
}
dependencies {
- implementation(kotlin("gradle-plugin", version = "1.6.10"))
- implementation("org.jlleitschuh.gradle:ktlint-gradle:10.2.1")
- implementation("org.jetbrains.kotlin:kotlin-allopen:1.6.10")
- implementation("me.champeau.jmh:jmh-gradle-plugin:0.6.6")
- implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.6.10")
- implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
+ implementation(libs.kotlin.gradle)
+ implementation(libs.kotlin.allopen)
+ implementation(libs.kotlin.noarg)
+ implementation(libs.ktlint.gradle)
+ implementation(libs.jmh.gradle)
+ implementation(libs.dokka.gradle)
+ implementation(libs.shadow)
}
diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts
index c9f9ab38..746d38f1 100644
--- a/buildSrc/settings.gradle.kts
+++ b/buildSrc/settings.gradle.kts
@@ -20,4 +20,12 @@
* SOFTWARE.
*/
-/* Intentionally left blank */
+enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
+
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("../gradle/libs.versions.toml"))
+ }
+ }
+}
diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt
index f538b1ad..6a73e1b9 100644
--- a/buildSrc/src/main/kotlin/Libs.kt
+++ b/buildSrc/src/main/kotlin/Libs.kt
@@ -26,14 +26,12 @@ import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType
-import kotlin.properties.ReadOnlyProperty
/**
* This class makes the version catalog accessible for the build scripts until Gradle adds support for it.
*
* See https://github.com/gradle/gradle/issues/15383
*/
-@Suppress("UnstableApiUsage")
public class Libs(project: Project) {
/**
* The version catalog of the project.
@@ -41,16 +39,10 @@ public class Libs(project: Project) {
private val versionCatalog = project.extensions.getByType(VersionCatalogsExtension::class).named("libs")
/**
- * A delegate for obtaining configuration values from a [Project] instance.
- */
- private fun lib(name: String? = null): ReadOnlyProperty<Libs, String> =
- ReadOnlyProperty { _, property -> get(name ?: property.name) }
-
- /**
* Obtain the version for the specified [dependency][name].
*/
operator fun get(name: String): String {
- val dep = versionCatalog.findDependency(name).get().get()
+ val dep = versionCatalog.findLibrary(name).get().get()
return "${dep.module.group}:${dep.module.name}:${dep.versionConstraint.displayName}"
}