From b0cedc13f9665f8e10adceb37abca8336c6d0593 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 19 Sep 2022 23:22:02 +0200 Subject: [PATCH] Use libs.versions.toml and clean gradle files Declaring the version catalog in libs.versions.toml instead of settings.gradle.kts has the advantage that it can be reused in buildSrc. It also introduces a single place to define dependencies and their version. General cleanup of gradle files was also done, including: * using default output for dokka: relying on defaults means less config and maintenance burden * removing DocsTask because it was unused, last usage of this custom task was removed in #367 * getting rid of source set workaround introduced in #386 by moving TweetNaclFast from voice/src/main/kotlin to voice/src/main/java --- .github/workflows/docs-ci.yml | 2 +- .gitignore | 1 - api/kord.api | 0 build.gradle.kts | 43 +------ buildSrc/build.gradle.kts | 9 +- buildSrc/settings.gradle.kts | 12 +- buildSrc/src/main/kotlin/Publishing.kt | 18 --- .../kotlin/kord-internal-module.gradle.kts | 2 +- .../src/main/kotlin/kord-module.gradle.kts | 19 ++- .../main/kotlin/kord-publishing.gradle.kts | 98 +++++++------- .../kotlin/kord-sampled-module.gradle.kts | 2 +- common/build.gradle.kts | 21 ++- core/build.gradle.kts | 4 +- gateway/build.gradle.kts | 5 +- gradle/libs.versions.toml | 101 +++++++++++++++ ksp-processors/build.gradle.kts | 8 +- rest/build.gradle.kts | 7 +- settings.gradle.kts | 120 ++---------------- voice/build.gradle.kts | 12 +- .../com/iwebpp/crypto/TweetNaclFast.java | 0 20 files changed, 211 insertions(+), 273 deletions(-) delete mode 100644 api/kord.api delete mode 100644 buildSrc/src/main/kotlin/Publishing.kt create mode 100644 gradle/libs.versions.toml rename voice/src/main/{kotlin => java}/com/iwebpp/crypto/TweetNaclFast.java (100%) diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml index c9d50940d344..bf779b0dfdfc 100644 --- a/.github/workflows/docs-ci.yml +++ b/.github/workflows/docs-ci.yml @@ -31,7 +31,7 @@ jobs: - name: Push docs to gh-pages uses: JamesIves/github-pages-deploy-action@v4 with: - folder: dokka + folder: build/dokka/htmlMultiModule branch: gh-pages git-config-name: GitHub Actions git-config-email: actions@github.com diff --git a/.gitignore b/.gitignore index fc463d6abcfc..e46f4d6a2cc7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .gradle/ .idea/ out/ -dokka/ **/build/* !**/build/generated/ diff --git a/api/kord.api b/api/kord.api deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/build.gradle.kts b/build.gradle.kts index c7d8bf40d9a7..8fce7e24a08e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,12 @@ import org.gradle.api.tasks.wrapper.Wrapper.DistributionType.ALL +@Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { - kotlin("jvm") - kotlin("plugin.serialization") - id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.12.1" - id("org.jetbrains.dokka") + org.jetbrains.dokka signing `maven-publish` - id("io.codearte.nexus-staging") version "0.30.0" + alias(libs.plugins.nexusStaging) } repositories { @@ -18,35 +16,8 @@ repositories { group = Library.group version = Library.version -tasks { - wrapper { - // Steps for upgrading Gradle: - // 1. update `gradleVersion` and `distributionSha256Sum` - // (use 'Complete (-all) ZIP Checksum' found here: https://gradle.org/release-checksums/) - // 2. run `./gradlew wrapper` - // (will update 'gradle/wrapper/gradle-wrapper.properties') - // 3. run `./gradlew wrapper` again - // (might update 'gradle/wrapper/gradle-wrapper.jar', 'gradlew' and 'gradlew.bat') - // 4. commit all changes - - gradleVersion = "7.5.1" - distributionType = ALL - distributionSha256Sum = "db9c8211ed63f61f60292c69e80d89196f9eb36665e369e7f00ac4cc841c2219" - } - - val dokkaOutputDir = rootProject.projectDir.resolve("dokka") - - clean { - delete(dokkaOutputDir) - } - - dokkaHtmlMultiModule { - dependsOn(clean) - failOnWarning.set(true) - outputDirectory.set(dokkaOutputDir) - } -} - -apiValidation { - ignoredProjects += listOf("ksp-annotations", "ksp-processors") +tasks.wrapper { + gradleVersion = libs.versions.gradle.get() + distributionType = ALL + distributionSha256Sum = libs.versions.gradleChecksum.get() } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index bcc6cf4d6b8c..71fc53572c32 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -4,15 +4,8 @@ plugins { repositories { mavenCentral() - gradlePluginPortal() } dependencies { - val kotlinVersion = "1.7.20" - implementation(kotlin("gradle-plugin", kotlinVersion)) - implementation(kotlin("serialization", kotlinVersion)) - implementation("org.jetbrains.dokka", "dokka-gradle-plugin", "1.7.20") - implementation("org.jetbrains.kotlinx", "atomicfu-gradle-plugin", "0.18.5") - implementation("com.google.devtools.ksp", "symbol-processing-gradle-plugin", "1.7.20-1.0.8") - implementation(gradleApi()) + implementation(libs.bundles.pluginsForBuildSrc) } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index c5cb64bc173d..b1d1e31da633 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1,4 +1,10 @@ -// avoids warning: -// "Project accessors enabled, but root project name not explicitly set for 'buildSrc'. Checking out the project in -// different folders will impact the generated code and implicitly the buildscript classpath, breaking caching." rootProject.name = "buildSrc" + +dependencyResolutionManagement { + @Suppress("UnstableApiUsage") + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/Publishing.kt b/buildSrc/src/main/kotlin/Publishing.kt deleted file mode 100644 index ae1a549d2364..000000000000 --- a/buildSrc/src/main/kotlin/Publishing.kt +++ /dev/null @@ -1,18 +0,0 @@ -import org.gradle.api.DefaultTask -import org.gradle.api.tasks.TaskAction -import java.nio.file.Files -import java.nio.file.Paths - -open class DocsTask : DefaultTask() { - - @TaskAction - fun publish() { - val dokkaRoot = Paths.get(project.projectDir.absolutePath, "dokka") - - val modulesFile = Paths.get(dokkaRoot.toAbsolutePath().toString(), "-modules.html") - val newIndex = Paths.get(dokkaRoot.toAbsolutePath().toString(), "index.html") - - Files.copy(modulesFile, newIndex) - } - -} diff --git a/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts index 723a330e392c..20737779b3ff 100644 --- a/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") + org.jetbrains.kotlin.jvm } repositories { diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 62bdb6d48afb..437b6a4a906c 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -3,18 +3,17 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.net.URL plugins { - java - kotlin("jvm") - kotlin("plugin.serialization") - id("org.jetbrains.dokka") - id("kotlinx-atomicfu") - id("com.google.devtools.ksp") + org.jetbrains.kotlin.jvm + org.jetbrains.kotlin.plugin.serialization + org.jetbrains.dokka + `kotlinx-atomicfu` + org.jetbrains.kotlinx.`binary-compatibility-validator` + com.google.devtools.ksp `maven-publish` } repositories { mavenCentral() - maven(url = "https://oss.sonatype.org/content/repositories/snapshots") } dependencies { @@ -34,6 +33,12 @@ kotlin { } } +// https://github.com/Kotlin/kotlinx-atomicfu/issues/210 +atomicfu { + val libs = extensions.getByType().named("libs") + dependenciesVersion = libs.findVersion("kotlinx-atomicfu").get().requiredVersion +} + tasks { withType { sourceCompatibility = Jvm.targetString diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 6bd53ede1e1d..f080e6714f13 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -5,73 +5,71 @@ plugins { signing } -tasks { - publishing { - publications { - create(Library.name) { - groupId = Library.group - artifactId = "kord-${project.name}" - version = Library.version +publishing { + publications { + create(Library.name) { + groupId = Library.group + artifactId = "kord-${project.name}" + version = Library.version - pom { - name.set(Library.name) - description.set(Library.description) - url.set(Library.projectUrl) + pom { + name.set(Library.name) + description.set(Library.description) + url.set(Library.projectUrl) - organization { - name.set("Kord") - url.set("https://github.com/kordlib") - } + organization { + name.set("Kord") + url.set("https://github.com/kordlib") + } - developers { - developer { - name.set("The Kord Team") - } + developers { + developer { + name.set("The Kord Team") } + } - issueManagement { - system.set("GitHub") - url.set("https://github.com/kordlib/kord/issues") - } + issueManagement { + system.set("GitHub") + url.set("https://github.com/kordlib/kord/issues") + } - licenses { - license { - name.set("MIT") - url.set("http://opensource.org/licenses/MIT") - } - } - scm { - connection.set("scm:git:ssh://github.com/kordlib/kord.git") - developerConnection.set("scm:git:ssh://git@github.com:kordlib/kord.git") - url.set(Library.projectUrl) + licenses { + license { + name.set("MIT") + url.set("http://opensource.org/licenses/MIT") } } - if (!isJitPack) { - repositories { - maven { - url = if (Library.isSnapshot) uri(Repo.snapshotsUrl) - else uri(Repo.releasesUrl) + scm { + connection.set("scm:git:ssh://github.com/kordlib/kord.git") + developerConnection.set("scm:git:ssh://git@github.com:kordlib/kord.git") + url.set(Library.projectUrl) + } + } - credentials { - username = System.getenv("NEXUS_USER") - password = System.getenv("NEXUS_PASSWORD") - } + if (!isJitPack) { + repositories { + maven { + url = uri(if (Library.isSnapshot) Repo.snapshotsUrl else Repo.releasesUrl) + + credentials { + username = System.getenv("NEXUS_USER") + password = System.getenv("NEXUS_PASSWORD") } } } } } } +} - if (!isJitPack && Library.isRelease) { - signing { - val signingKey = findProperty("signingKey")?.toString() - val signingPassword = findProperty("signingPassword")?.toString() - if (signingKey != null && signingPassword != null) { - useInMemoryPgpKeys(String(Base64.getDecoder().decode(signingKey)), signingPassword) - } - sign(publishing.publications[Library.name]) +if (!isJitPack && Library.isRelease) { + signing { + val signingKey = findProperty("signingKey")?.toString() + val signingPassword = findProperty("signingPassword")?.toString() + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys(String(Base64.getDecoder().decode(signingKey)), signingPassword) } + sign(publishing.publications[Library.name]) } } diff --git a/buildSrc/src/main/kotlin/kord-sampled-module.gradle.kts b/buildSrc/src/main/kotlin/kord-sampled-module.gradle.kts index 7998472ddbc0..3cd473a68fda 100644 --- a/buildSrc/src/main/kotlin/kord-sampled-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-sampled-module.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("jvm") + org.jetbrains.kotlin.jvm } sourceSets { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 28ea464a6a35..270b4b897d91 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,27 +1,22 @@ -buildscript { - repositories { - mavenCentral() - } -} - +@Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { `kord-module` `kord-sampled-module` `kord-publishing` - - // see https://github.com/gmazzo/gradle-buildconfig-plugin - id("com.github.gmazzo.buildconfig") version "3.1.0" + alias(libs.plugins.buildconfig) } dependencies { + api(libs.kotlinx.coroutines.core) + api(libs.kotlinx.serialization.json) api(libs.kotlinx.datetime) - - api(libs.bundles.common) - testImplementation(libs.bundles.test.implementation) - testRuntimeOnly(libs.bundles.test.runtime) + api(libs.kotlin.logging) compileOnly(projects.kspAnnotations) ksp(projects.kspProcessors) + + testImplementation(libs.bundles.test.implementation) + testRuntimeOnly(libs.bundles.test.runtime) } /* diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 074a46f628a6..5bc20cfc5167 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -20,13 +20,11 @@ dependencies { "voiceApi"(projects.core) "voiceApi"(projects.voice) - implementation(libs.bundles.common) - api(libs.kord.cache.api) api(libs.kord.cache.map) samplesImplementation(libs.slf4j.simple) - testImplementation(libs.mockk) + testImplementation(libs.bundles.test.implementation) testRuntimeOnly(libs.bundles.test.runtime) } diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index a27c6ce50180..b38ed983bec7 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -6,14 +6,11 @@ plugins { dependencies { api(projects.common) - implementation(libs.bundles.common) - api(libs.ktor.client.json) - api(libs.ktor.client.websockets) api(libs.bundles.ktor.client.serialization) + api(libs.ktor.client.websockets) api(libs.ktor.client.cio) - testImplementation(libs.bundles.test.implementation) testRuntimeOnly(libs.bundles.test.runtime) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000000..50c07e14244b --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,101 @@ +[versions] + +# Steps for upgrading Gradle: +# 1. update `gradle` and `gradleChecksum` ('Complete (-all) ZIP Checksum' from https://gradle.org/release-checksums) +# 2. run `./gradlew wrapper` (will update 'gradle/wrapper/gradle-wrapper.properties') +# 3. run `./gradlew wrapper` again (might update 'gradle/wrapper/gradle-wrapper.jar', 'gradlew' and 'gradlew.bat') +# 4. commit all changes +gradle = "7.5.1" # https://github.com/gradle/gradle +gradleChecksum = "db9c8211ed63f61f60292c69e80d89196f9eb36665e369e7f00ac4cc841c2219" + +# api dependencies +kotlin = "1.7.20" # https://github.com/JetBrains/kotlin +ktor = "2.1.3" # https://github.com/ktorio/ktor +kotlinx-coroutines = "1.6.4" # https://github.com/Kotlin/kotlinx.coroutines +kotlinx-serialization = "1.4.1" # https://github.com/Kotlin/kotlinx.serialization +kotlinx-datetime = "0.4.0" # https://github.com/Kotlin/kotlinx-datetime +kotlin-logging = "2.1.23" # https://github.com/MicroUtils/kotlin-logging +kord-cache = { strictly = "[0.3.0, 0.4.0[", prefer = "latest.release" } + +# code generation +ksp = "1.7.20-1.0.8" # https://github.com/google/ksp +kotlinpoet = "1.12.0" # https://github.com/square/kotlinpoet + +# tests +junit5 = "5.9.1" # https://github.com/junit-team/junit5 +mockk = "1.13.2" # https://github.com/mockk/mockk +slf4j = "1.7.36" # https://www.slf4j.org + +# plugins +dokka = "1.7.20" # https://github.com/Kotlin/dokka +kotlinx-atomicfu = "0.18.5" # https://github.com/Kotlin/kotlinx-atomicfu +binary-compatibility-validator = "0.12.1" # https://github.com/Kotlin/binary-compatibility-validator +buildconfig = "3.1.0" # https://github.com/gmazzo/gradle-buildconfig-plugin +nexus-staging = "0.30.0" # https://github.com/Codearte/gradle-nexus-staging-plugin + + +[libraries] + +# cache +kord-cache-api = { module = "dev.kord.cache:cache-api", version.ref = "kord-cache" } +kord-cache-map = { module = "dev.kord.cache:cache-map", version.ref = "kord-cache" } + +# ktor +ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } +ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } +ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } +ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" } +ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } +ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" } + +# kotlinx +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } + +# other +kotlin-logging = { module = "io.github.microutils:kotlin-logging", version.ref = "kotlin-logging" } + +# code generation +ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } +kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } +kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } + +# tests +junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" } +junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" } +mockk = { module = "io.mockk:mockk", version.ref = "mockk" } +slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } + +# actually plugins, not libraries, but used is 'buildSrc/build.gradle.kts' as implementation dependencies: +# https://docs.gradle.org/current/userguide/custom_plugins.html#applying_external_plugins_in_precompiled_script_plugins +kotlin-jvm-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" } +dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } +atomicfu-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "kotlinx-atomicfu" } +binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator" } +ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" } + + +[bundles] + +ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] + +test-implementation = ["kotlinx-coroutines-test", "junit-jupiter-api", "mockk"] +test-runtime = ["junit-jupiter-engine", "slf4j-simple"] + +pluginsForBuildSrc = [ + "kotlin-jvm-plugin", + "kotlin-serialization-plugin", + "dokka-plugin", + "atomicfu-plugin", + "binary-compatibility-validator-plugin", + "ksp-plugin", +] + + +[plugins] + +buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" } +nexusStaging = { id = "io.codearte.nexus-staging", version.ref = "nexus-staging" } diff --git a/ksp-processors/build.gradle.kts b/ksp-processors/build.gradle.kts index 3de1931298c4..a450e7e5b48e 100644 --- a/ksp-processors/build.gradle.kts +++ b/ksp-processors/build.gradle.kts @@ -4,6 +4,10 @@ plugins { dependencies { implementation(projects.kspAnnotations) - implementation(libs.bundles.ksp.processors) - implementation(libs.kotlinx.serialization) // use types directly + + implementation(libs.ksp.api) + implementation(libs.kotlinpoet) + implementation(libs.kotlinpoet.ksp) + + implementation(libs.kotlinx.serialization.json) // use types directly } diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index ca8cfb1795bb..da30cf30ef42 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -6,14 +6,11 @@ plugins { dependencies { api(projects.common) - implementation(libs.bundles.common) - api(libs.ktor.client.cio) - api(libs.ktor.client.json) api(libs.bundles.ktor.client.serialization) - - testImplementation(libs.ktor.client.mock) + api(libs.ktor.client.cio) testImplementation(libs.bundles.test.implementation) + testImplementation(libs.ktor.client.mock) testRuntimeOnly(libs.bundles.test.runtime) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 5b488cb68d86..a603f16045ff 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,112 +1,14 @@ -@file:Suppress("UnstableApiUsage") - -pluginManagement { - resolutionStrategy { - eachPlugin { - if (requested.id.id == "org.jetbrains.dokka") { - useModule("org.jetbrains.dokka:dokka-gradle-plugin:${requested.version}") - } - } - } - repositories { - gradlePluginPortal() - mavenCentral() - } -} - rootProject.name = "kord" -include("gateway") -include("common") -include("rest") -include("core") -include("voice") -include("bom") -include("ksp-annotations") -include("ksp-processors") - -enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") - -dependencyResolutionManagement { - versionCatalogs { - create("libs") { - kotlinx() - ktor() - cache() - common() - tests() - kspProcessors() - } - } -} - -fun VersionCatalogBuilder.cache() { - val cache = version("kord-cache") { - strictly("[0.3.0, 0.4.0[") - prefer("latest.release") - } - - library("kord-cache-api", "dev.kord.cache", "cache-api").versionRef(cache) - library("kord-cache-map", "dev.kord.cache", "cache-map").versionRef(cache) -} - -fun VersionCatalogBuilder.kotlinx() { - library("kotlinx-datetime", "org.jetbrains.kotlinx", "kotlinx-datetime").version("0.4.0") -} - -fun VersionCatalogBuilder.ktor() { - val ktor = version("ktor", "2.1.3") - - library("ktor-client-json", "io.ktor", "ktor-serialization-kotlinx-json").versionRef(ktor) - library("ktor-client-content-negotiation", "io.ktor", "ktor-client-content-negotiation").versionRef(ktor) - - library("ktor-client-cio", "io.ktor", "ktor-client-cio").versionRef(ktor) - - library("ktor-client-websockets", "io.ktor", "ktor-client-websockets").versionRef(ktor) - - library("ktor-client-mock", "io.ktor", "ktor-client-mock").versionRef(ktor) +include( + "bom", + "common", + "core", + "gateway", + "ksp-annotations", + "ksp-processors", + "rest", + "voice", +) - library("ktor-network", "io.ktor", "ktor-network").versionRef(ktor) - - bundle("ktor-client-serialization", listOf("ktor-client-content-negotiation", "ktor-client-json")) -} - -fun VersionCatalogBuilder.common() { - version("kotlinx-coroutines", "1.6.4") - library("kotlinx-serialization", "org.jetbrains.kotlinx", "kotlinx-serialization-json").version("1.4.1") - library("kotlinx-coroutines", "org.jetbrains.kotlinx", "kotlinx-coroutines-core").versionRef("kotlinx-coroutines") - library("kotlinx-atomicfu", "org.jetbrains.kotlinx", "atomicfu").version("0.18.5") - library("kotlin-logging", "io.github.microutils", "kotlin-logging").version("2.1.23") - - bundle("common", listOf("kotlinx-serialization", "kotlinx-coroutines", "kotlinx-atomicfu", "kotlin-logging")) -} - -fun VersionCatalogBuilder.tests() { - val junit5 = version("junit5", "5.9.1") - - library("mockk", "io.mockk", "mockk").version("1.13.2") - library("kotlinx-coroutines-test", "org.jetbrains.kotlinx", "kotlinx-coroutines-test").versionRef("kotlinx-coroutines") - library("junit-jupiter-api", "org.junit.jupiter", "junit-jupiter-api").versionRef(junit5) - - library("slf4j-simple", "org.slf4j", "slf4j-simple").version("1.7.36") - library("junit-jupiter-engine", "org.junit.jupiter", "junit-jupiter-engine").versionRef(junit5) - - bundle("test-implementation", listOf("mockk", "kotlinx-coroutines-test", "junit-jupiter-api")) - - bundle( - "test-runtime", listOf( - "slf4j-simple", - "junit-jupiter-engine" - ) - ) -} - -fun VersionCatalogBuilder.kspProcessors() { - library("ksp-api", "com.google.devtools.ksp", "symbol-processing-api").version("1.7.20-1.0.8") - - val kotlinpoet = version("kotlinpoet", "1.12.0") - library("kotlinpoet", "com.squareup", "kotlinpoet").versionRef(kotlinpoet) - library("kotlinpoet-ksp", "com.squareup", "kotlinpoet-ksp").versionRef(kotlinpoet) - - bundle("ksp-processors", listOf("ksp-api", "kotlinpoet", "kotlinpoet-ksp")) -} +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") diff --git a/voice/build.gradle.kts b/voice/build.gradle.kts index a3632971c141..8cc497a88c3f 100644 --- a/voice/build.gradle.kts +++ b/voice/build.gradle.kts @@ -1,4 +1,5 @@ plugins { + java // for TweetNaclFast `kord-module` `kord-sampled-module` `kord-publishing` @@ -8,16 +9,5 @@ dependencies { api(projects.common) api(projects.gateway) - api(libs.ktor.client.json) - api(libs.bundles.ktor.client.serialization) - api(libs.ktor.client.cio) api(libs.ktor.network) } - -// by convention, java classes (TweetNaclFast) should be in their own java source. -// however, this breaks atomicfu. -// to work around it we just make the kotlin src directory also a java src directory. -// this can be removed when https://github.com/Kotlin/kotlinx.atomicfu/commit/fe0950adcf0da67cd074503c2a78467656c5aa0f is released. -sourceSets.main { - java.srcDirs("src/main/java", "src/main/kotlin") -} diff --git a/voice/src/main/kotlin/com/iwebpp/crypto/TweetNaclFast.java b/voice/src/main/java/com/iwebpp/crypto/TweetNaclFast.java similarity index 100% rename from voice/src/main/kotlin/com/iwebpp/crypto/TweetNaclFast.java rename to voice/src/main/java/com/iwebpp/crypto/TweetNaclFast.java