diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts index 92e730b20578..77b98f1a3304 100644 --- a/bom/build.gradle.kts +++ b/bom/build.gradle.kts @@ -14,7 +14,7 @@ dependencies { constraints { rootProject.subprojects.forEach { subproject -> if (subproject.plugins.hasPlugin("maven-publish") && subproject.name != name) { - subproject.publishing.publications.withType { + subproject.publishing.publications.withType().configureEach { if (!artifactId.endsWith("-metadata") && !artifactId.endsWith("-kotlinMultiplatform") ) { @@ -27,7 +27,7 @@ dependencies { } publishing { - publications.withType { + publications.withType().configureEach { from(components["javaPlatform"]) } } diff --git a/build.gradle.kts b/build.gradle.kts index 922555635c74..7489c68f8b57 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,8 @@ plugins { repositories { mavenCentral() + // until Dokka 1.8.0 is released and we no longer need dev builds, see https://github.com/kordlib/kord/pull/755 + maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") } group = Library.group diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 71fc53572c32..36151e65c587 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -4,6 +4,8 @@ plugins { repositories { mavenCentral() + // until Dokka 1.8.0 is released and we no longer need dev builds, see https://github.com/kordlib/kord/pull/755 + maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") } dependencies { diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index b1d1e31da633..62991c1ef50a 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1,7 +1,6 @@ rootProject.name = "buildSrc" dependencyResolutionManagement { - @Suppress("UnstableApiUsage") versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index d0e75c32e579..382763bca8c7 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -1,4 +1,4 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions object CompilerArguments { const val time = "-opt-in=kotlin.time.ExperimentalTime" @@ -12,13 +12,10 @@ object CompilerArguments { } object Jvm { - // keep these equivalent - const val targetString = "1.8" - const val targetInt = 8 + const val target = 8 } -fun KotlinJvmOptions.applyKordKotlinOptions() { - jvmTarget = Jvm.targetString - allWarningsAsErrors = true - freeCompilerArgs += CompilerArguments.progressive +fun KotlinJvmCompilerOptions.applyKordCompilerOptions() { + allWarningsAsErrors.set(true) + freeCompilerArgs.add(CompilerArguments.progressive) } diff --git a/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts index 20737779b3ff..b61a5411875d 100644 --- a/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-module.gradle.kts @@ -8,15 +8,12 @@ repositories { mavenCentral() } -tasks { - withType { - sourceCompatibility = Jvm.targetString - targetCompatibility = Jvm.targetString - } +kotlin { + jvmToolchain(Jvm.target) +} - withType { - kotlinOptions { - applyKordKotlinOptions() - } +tasks.withType().configureEach { + compilerOptions { + applyKordCompilerOptions() } } diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 02710fa90661..d5fbbba99ec6 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -1,3 +1,4 @@ +import com.google.devtools.ksp.gradle.KspTask import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.net.URL @@ -14,11 +15,15 @@ plugins { repositories { mavenCentral() + // until Dokka 1.8.0 is released and we no longer need dev builds, see https://github.com/kordlib/kord/pull/755 + maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") } kotlin { explicitApi() + jvmToolchain(Jvm.target) + sourceSets { // mark ksp src dir main { kotlin.srcDir("build/generated/ksp/main/kotlin") } @@ -35,15 +40,10 @@ atomicfu { } tasks { - withType { - sourceCompatibility = Jvm.targetString - targetCompatibility = Jvm.targetString - } - withType { - kotlinOptions { - applyKordKotlinOptions() - freeCompilerArgs += listOf( + compilerOptions { + applyKordCompilerOptions() + freeCompilerArgs.addAll( CompilerArguments.time, CompilerArguments.contracts, @@ -54,23 +54,28 @@ tasks { } } - withType { + withType().configureEach { useJUnitPlatform() } + fun Task.dependsOnKspKotlin() { + val kspKotlin = findByName("kspKotlin") + if (kspKotlin != null) dependsOn(kspKotlin) + } + // configure both dokkaHtml and dokkaHtmlPartial tasks // (dokkaHtmlMultiModule depends on dokkaHtmlPartial, dokkaJar depends on dokkaHtml) - withType { + withType().configureEach { // see https://kotlin.github.io/dokka//user_guide/gradle/usage/#configuration-options - // make sure ksp generates files before building docs - dependsOn(compileKotlin) + // include documentation generated by ksp + dependsOnKspKotlin() failOnWarning.set(true) dokkaSourceSets.configureEach { - jdkVersion.set(Jvm.targetInt) + jdkVersion.set(Jvm.target) val baseRemoteUrl = "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.8.x")}/${project.name}" @@ -106,28 +111,27 @@ tasks { } } - val sourcesJar by registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSets.main.get().allSource) + withType().configureEach { + doFirst { require(!Library.isUndefined) { "No release/snapshot version found." } } } - val dokkaJar by registering(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - description = "Assembles Kotlin docs with Dokka" - archiveClassifier.set("javadoc") - from(dokkaHtml) - dependsOn(dokkaHtml) + kotlinSourcesJar { + // include sources generated by ksp + dependsOnKspKotlin() } +} - withType().configureEach { - doFirst { require(!Library.isUndefined) { "No release/snapshot version found." } } - } +val dokkaJar by tasks.registering(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + description = "Assembles Kotlin docs with Dokka" + archiveClassifier.set("javadoc") + from(tasks.dokkaHtml) +} - publishing { - publications.withType { - from(components["java"]) - artifact(sourcesJar.get()) - artifact(dokkaJar.get()) - } +publishing { + publications.withType().configureEach { + from(components["java"]) + artifact(tasks.kotlinSourcesJar) + artifact(dokkaJar) } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 5bc20cfc5167..acddb513a9aa 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -5,7 +5,8 @@ plugins { `kord-publishing` } -val voice by sourceSets.creating +val voice: SourceSet by sourceSets.creating +val voiceApi: Configuration by configurations.getting configurations { getByName("voiceImplementation") { @@ -17,8 +18,8 @@ dependencies { api(projects.common) api(projects.rest) api(projects.gateway) - "voiceApi"(projects.core) - "voiceApi"(projects.voice) + voiceApi(projects.core) + voiceApi(projects.voice) api(libs.kord.cache.api) api(libs.kord.cache.map) diff --git a/gradle.properties b/gradle.properties index 7583167ae78a..b28460e2ab10 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,3 @@ kotlin.code.style=official # https://github.com/Kotlin/kotlinx-atomicfu#atomicfu-compiler-plugin kotlinx.atomicfu.enableJvmIrTransformation=true kotlinx.atomicfu.enableJsIrTransformation=true - -# remove when upgrading to gradle 8.0 -# https://docs.gradle.org/7.6/userguide/upgrading_version_7.html#strict-kotlin-dsl-precompiled-scripts-accessors -systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b678f6a883c3..554d7ced63d8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ 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 +dokka = "1.8.0-dev-194" # https://github.com/Kotlin/dokka kotlinx-atomicfu = "0.19.0" # 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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa754..ccebba7710de 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bc073f67610a..74e2ced04e38 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=312eb12875e1747e05c2f81a4789902d7e4ec5defbd1eefeaccc08acf096505d -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionSha256Sum=f30b29580fe11719087d698da23f3b0f0d04031d8995f7dd8275a31f7674dc01 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d65c8..79a61d421cc4 100755 --- a/gradlew +++ b/gradlew @@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac