Skip to content

Commit

Permalink
Use Gradle Version Catalog (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefMa authored Oct 8, 2023
1 parent b1044d2 commit a21126e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
27 changes: 13 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform") version "1.9.10"
kotlin("plugin.serialization") version "1.9.10"
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.kotlinSerialization)
`maven-publish`
}

Expand Down Expand Up @@ -31,34 +31,33 @@ kotlin {
}

sourceSets {
val ktorVersion = "2.3.4"
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
implementation("io.ktor:ktor-client-logging:$ktorVersion")
implementation(libs.common.ktor.core)
implementation(libs.common.ktor.contentNegotiation)
implementation(libs.common.ktor.serialization)
implementation(libs.common.ktor.logging)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("io.ktor:ktor-client-mock:$ktorVersion")
implementation(libs.common.test.kotlin)
implementation(libs.common.test.ktorMock)
}
}
val jvmMain by getting {
dependencies {
implementation("ch.qos.logback:logback-classic:1.3.0")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
implementation(libs.jvm.ktor.client)
implementation(libs.jvm.ktor.logging)
}
}
val jvmTest by getting
val nativeMain by getting {
dependencies {
when {
hostOs == "Mac OS X" -> implementation("io.ktor:ktor-client-darwin:$ktorVersion")
hostOs == "Linux" -> implementation("io.ktor:ktor-client-curl:$ktorVersion")
isMingwX64 -> implementation("io.ktor:ktor-client-winhttp:$ktorVersion")
hostOs == "Mac OS X" -> implementation(libs.macos.ktor.client)
hostOs == "Linux" -> implementation(libs.linux.ktor.client)
isMingwX64 -> implementation(libs.mingw.ktor.client)
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

Expand Down
25 changes: 25 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[versions]
kotlin = "1.9.10"
ktor = "2.3.4"

[libraries]
common-ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
common-ktor-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
common-ktor-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
common-ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }

common-test-kotlin = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
common-test-ktorMock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }

jvm-ktor-client = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
jvm-ktor-logging = "ch.qos.logback:logback-classic:1.3.0"

macos-ktor-client = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }

linux-ktor-client = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }

mingw-ktor-client = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }

[plugins]
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

0 comments on commit a21126e

Please sign in to comment.