Skip to content

Commit

Permalink
build: enable the kotest runner on multiplatform projects
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Dec 29, 2024
1 parent a1289ec commit 8047adb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ import org.eclipse.jgit.api.Git
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalDependency
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.SourceTask
import org.gradle.api.tasks.TaskCollection
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.VerificationTask
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.gradle.plugin.use.PluginDependency
import java.io.ByteArrayOutputStream
import java.io.File
import java.net.URI
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty

/**
* Collector of imperative code.
Expand Down Expand Up @@ -148,3 +153,8 @@ object Util {
val TaskContainer.allVerificationTasks get(): TaskCollection<SourceTask> =
this.withType<SourceTask>().matching { it is VerificationTask }
}

val Project.catalog get() = object : ReadOnlyProperty<Any?, Provider<MinimalExternalModuleDependency>> {
override operator fun getValue(thisRef: Any?, property: KProperty<*>) =
extensions.getByType<VersionCatalogsExtension>().named("libs").findLibrary(property.name).get()
}
5 changes: 0 additions & 5 deletions buildSrc/src/main/kotlin/kotlin-jvm-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ plugins {
id("dokka-convention")
}

val catalog = object : ReadOnlyProperty<Any?, Provider<MinimalExternalModuleDependency>> {
override operator fun getValue(thisRef: Any?, property: KProperty<*>) =
extensions.getByType<VersionCatalogsExtension>().named("libs").findLibrary(property.name).get()
}

dependencies {
val jsr305 by catalog
val slf4j by catalog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,25 @@ kotlin {
}

sourceSets {
val commonTest by getting {
dependencies {
val `kotest-assertions-core` by catalog
val `kotest-framework-engine` by catalog
implementation(`kotest-assertions-core`)
implementation(`kotest-framework-engine`)
}
}
val jvmMain by getting {
dependencies {
implementation(alchemist("api"))
}
}
val jvmTest by getting {
dependencies {
val `kotest-runner` by catalog
implementation(`kotest-runner`)
}
}
}
}

Expand Down

0 comments on commit 8047adb

Please sign in to comment.