Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
- Remove blank lines in common/build.gradle.kts
- Replace kord-internal-multiplatform-module.gradle.kts and kord-native-module.gradle.kts with kord-targets.gradle.kts
- Check for target family rather than explicit target in samples/build.gradle.kts
- Add slf4j dependency to voice
- Remove nonNative target group
- Use HostManager.hostIsMingw instead of Ant's Os class
- Move nativeMain builder and jsMain to nonJvmMain
- Add versions of remaining Gradle plugins to [versions] block
- No longer catch exception in native test kit
  • Loading branch information
DRSchlaubi committed Mar 4, 2024
1 parent dd69ed9 commit 5869b9a
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 132 deletions.

This file was deleted.

58 changes: 0 additions & 58 deletions buildSrc/src/main/kotlin/kord-module.gradle.kts

This file was deleted.

14 changes: 0 additions & 14 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,10 @@ kotlin {
withNative()
withJs()
}

group("nonNative") {
withJs()
withJvm()
}
}
}

explicitApi()

jvm()

if (name != "voice" && name != "core-voice") {
js {
nodejs()
useCommonJs()
}
}
jvmToolchain(Jvm.target)

targets.all {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.konan.target.HostManager

plugins {
org.jetbrains.kotlin.multiplatform
Expand All @@ -7,13 +7,19 @@ plugins {
kotlin {
// There are issues with compiling the linux variant on windows
// Please use WSL if you need to work on the linux port
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
if (!HostManager.hostIsMingw) {
linuxX64()
linuxArm64()
}

jvm()

if (name != "voice" && name != "core-voice") {
mingwX64()
js {
nodejs()
useCommonJs()
}
}

macosArm64()
Expand Down
6 changes: 1 addition & 5 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dev.kord.gradle.tools.util.commitHash
import dev.kord.gradle.tools.util.shortCommitHash

plugins {
`kord-native-module`
`kord-targets`
`kord-multiplatform-module`
`kord-publishing`
alias(libs.plugins.buildconfig)
Expand Down Expand Up @@ -41,26 +41,22 @@ kotlin {
implementation(projects.kspAnnotations)
}
}

nativeMain {
dependencies {
// Native does not have compileOnly
implementation(projects.kspAnnotations)
}
}

mingwMain {
dependencies {
api(libs.ktor.client.winhttp)
}
}

appleMain {
dependencies {
api(libs.ktor.client.darwin)
}
}

linuxMain {
dependencies {
api(libs.ktor.client.curl)
Expand Down
2 changes: 1 addition & 1 deletion core-voice/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kord-native-module`
`kord-targets`
`kord-multiplatform-module`
`kord-publishing`
}
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kord-native-module`
`kord-targets`
`kord-multiplatform-module`
`kord-publishing`
}
Expand Down
2 changes: 1 addition & 1 deletion core/live-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kord-internal-multiplatform-module`
`kord-targets`
}

kotlin {
Expand Down
3 changes: 0 additions & 3 deletions core/src/nativeMain/kotlin/KordBuilder.kt

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion gateway/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kord-native-module`
`kord-targets`
`kord-multiplatform-module`
`kord-publishing`
}
Expand Down
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ dokka = "1.9.20" # https://github.com/Kotlin/dokka
kotlinx-atomicfu = "0.23.2" # https://github.com/Kotlin/kotlinx-atomicfu
binary-compatibility-validator = "0.14.0" # https://github.com/Kotlin/binary-compatibility-validator
buildconfig = "5.3.5" # https://github.com/gmazzo/gradle-buildconfig-plugin

kord-gradle-tools = "1.3.0" # https://github.com/kordlib/gradle-tools
maven-publish-plugin = "0.27.0" # https://github.com/vanniktech/gradle-maven-publish-plugin

[libraries]

Expand Down Expand Up @@ -92,8 +93,8 @@ dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref
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" }
kord-gradle-plugin = { module = "dev.kord:gradle-tools", version = "1.3.0" }
maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.27.0" }
kord-gradle-plugin = { module = "dev.kord:gradle-tools", version.ref = "kord-gradle-tools" }
maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish-plugin" }


[bundles]
Expand Down
3 changes: 1 addition & 2 deletions ksp-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask

plugins {
`kord-native-module`
`kord-internal-multiplatform-module`
`kord-targets`

// workaround for https://youtrack.jetbrains.com/issue/KT-43500 (not intended to be published)
org.jetbrains.dokka
Expand Down
2 changes: 1 addition & 1 deletion rest/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kord-native-module`
`kord-targets`
`kord-multiplatform-module`
`kord-publishing`
}
Expand Down
8 changes: 4 additions & 4 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.Family

plugins {
`kord-internal-multiplatform-module`
`kord-native-module`
`kord-targets`
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
Expand All @@ -23,7 +22,8 @@ kotlin {
}

targets.withType<KotlinNativeTarget> {
if (konanTarget != KonanTarget.MINGW_X64) {
// Voice does not target windows, so we disable it
if (konanTarget.family != Family.MINGW) {
binaries.executable {
entryPoint = "dev.kord.voice.test.main"
}
Expand Down
3 changes: 1 addition & 2 deletions test-kit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
`kord-native-module`
`kord-internal-multiplatform-module`
`kord-targets`
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
Expand Down
8 changes: 1 addition & 7 deletions test-kit/src/nativeMain/kotlin/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,5 @@ actual suspend fun readFile(project: String, path: String): ByteReadChannel =

private inline fun <T> read(project: String, path: String, readerAction: Source.() -> T): T {
val actualPath = Path("${getEnv("PROJECT_ROOT")}/$project/src/commonTest/resources/$path")
return try {
SystemFileSystem.source(actualPath).buffered().readerAction()
} catch (e: Throwable) {
throw FileNotFoundException(actualPath.toString(), e)
}
return SystemFileSystem.source(actualPath).buffered().readerAction()
}

class FileNotFoundException(absolutePath: String, cause: Throwable) : IOException("Absolute Path: $absolutePath", cause)
7 changes: 6 additions & 1 deletion voice/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kord-native-module`
`kord-targets`
`kord-multiplatform-module`
`kord-publishing`
}
Expand Down Expand Up @@ -27,5 +27,10 @@ kotlin {
implementation(libs.libsodium)
}
}
jvmMain {
dependencies {
implementation(libs.slf4j.api)
}
}
}
}

0 comments on commit 5869b9a

Please sign in to comment.