From 15124297878593fb2fe4cdde703b7d64682083b3 Mon Sep 17 00:00:00 2001 From: duncte123 Date: Thu, 30 Nov 2023 09:07:15 +0100 Subject: [PATCH] Store versions in version catalog --- build.gradle.kts | 32 ++++++++++++++++---------------- settings.gradle.kts | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3efab3c..391019a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,11 +11,11 @@ plugins { java `java-library` `maven-publish` - kotlin("jvm") version "1.9.21" - kotlin("plugin.serialization") version "1.9.21" - id("org.jetbrains.dokka") version "1.9.10" - id("org.ajoberstar.grgit") version "5.2.0" - id("com.vanniktech.maven.publish.base") version "0.25.3" + kotlin("jvm") version libs.versions.kotlin + kotlin("plugin.serialization") version libs.versions.kotlin + id("org.jetbrains.dokka") version libs.versions.dokka + id("org.ajoberstar.grgit") version libs.versions.grgit + id("com.vanniktech.maven.publish.base") version libs.versions.maven.publish } val (gitVersion, release) = versionFromGit() @@ -42,21 +42,21 @@ repositories { dependencies { // package libraries api(kotlin("stdlib")) - api("dev.arbjerg.lavalink:protocol:47201924be7d5a459753fc85f00ca30e49ba3cd1-SNAPSHOT") - api("com.squareup.okhttp3:okhttp:4.10.0") - api("io.projectreactor:reactor-core:3.5.6") - api("io.projectreactor.kotlin:reactor-kotlin-extensions:1.2.2") - api("org.slf4j:slf4j-api:2.0.7") + api(libs.kotlin) + api(libs.lavalink.protocol) + api(libs.okhttp) + api(libs.bundles.reactor) + api(libs.logger.api) // Discord library support - compileOnly("net.dv8tion:JDA:5.0.0-beta.11") - compileOnly("com.discord4j:discord4j-core:3.2.3") + compileOnly(libs.jda) + compileOnly(libs.d4j) testImplementation(kotlin("test")) - testImplementation("net.dv8tion:JDA:5.0.0-beta.11") - testImplementation("com.discord4j:discord4j-core:3.2.3") - testImplementation("org.slf4j:slf4j-simple:2.0.7") - testImplementation("com.github.topi314.lavasearch:lavasearch-protocol:1.0.0-beta.2") + testImplementation(libs.jda) + testImplementation(libs.d4j) + testImplementation(libs.logger.impl) + testImplementation(libs.lavasearch) } val sourcesForRelease = task("sourcesForRelease") { diff --git a/settings.gradle.kts b/settings.gradle.kts index 9aca74e..b081e85 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,45 @@ - rootProject.name = "lavalink-client" +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + versionRefs() + common() + discordLibs() + testLibs() + } + } +} + +fun VersionCatalogBuilder.versionRefs() { + version("kotlin", "1.9.21") + version("dokka", "1.9.10") + version("grgit", "5.2.0") + version("maven-publish", "0.25.3") + + version("logger", "2.0.7") +} + +fun VersionCatalogBuilder.common() { + library("kotlin", "org.jetbrains.kotlin", "kotlin-stdlib").versionRef("kotlin") + library("lavalink-protocol", "dev.arbjerg.lavalink", "protocol").version("47201924be7d5a459753fc85f00ca30e49ba3cd1-SNAPSHOT") + library("okhttp", "com.squareup.okhttp3", "okhttp").version("4.10.0") + library("reactor-core", "io.projectreactor", "reactor-core").version("3.5.6") + library("reactor-kotlin", "io.projectreactor.kotlin", "reactor-kotlin-extensions").version("1.2.2") + + bundle("reactor", listOf("reactor-core", "reactor-kotlin")) + + library("logger-api", "org.slf4j", "slf4j-api").versionRef("logger") +} + +fun VersionCatalogBuilder.discordLibs() { + library("jda", "net.dv8tion", "JDA").version("5.0.0-beta.11") + library("d4j", "com.discord4j", "discord4j-core").version("3.2.3") +} + +fun VersionCatalogBuilder.testLibs() { + library("logger-impl", "org.slf4j", "slf4j-simple").versionRef("logger") + library("lavasearch", "com.github.topi314.lavasearch", "lavasearch-protocol").version("1.0.0-beta.2") +}