Skip to content

Commit dd6853a

Browse files
committed
Refactor UUID generation and cleanup Kotlin Multiplatform setup
Revised UUID generation logic for platform-specific implementations, replacing outdated methods with more robust solutions. Simplified Kotlin Multiplatform project configuration, removed deprecated dependencies, and updated Kotlin and Kotest versions. Added `.gitignore` and streamlined build files for improved maintainability.
1 parent 44c2d90 commit dd6853a

File tree

14 files changed

+95
-125
lines changed

14 files changed

+95
-125
lines changed

kotest-multiplatform/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
*.class
2+
3+
# Mobile Tools for Java (J2ME)
4+
.mtj.tmp/
5+
6+
# Package Files #
7+
*.jar
8+
*.war
9+
*.ear
10+
11+
.allure
12+
13+
*.iml
14+
.idea
15+
16+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
17+
hs_err_pid*
18+
out/
19+
20+
build
21+
target
22+
.gradle
23+
24+
allure-results/
25+
26+
# Gradle wrapper
27+
!gradle/wrapper/gradle-wrapper.jar
28+
29+
allure.log
30+
kotest.log
31+
kotest-tests-junit-report.log
32+
kotest-tests-core.log
33+
34+
local.properties
35+
.kotest
36+
/kotest-examples/kotest-examples-javascript/node_modules/
37+
*.gpg.enc
38+
39+
kotest-tests/kotest-tests-js/node_modules/
40+
.DS_Store
41+
.kotlin

kotest-multiplatform/build.gradle.kts

Lines changed: 19 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,40 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
mavenLocal()
5-
}
6-
}
1+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
72

8-
@Suppress("DSL_SCOPE_VIOLATION")
93
plugins {
10-
java
11-
id("java-library")
124
alias(libs.plugins.kotlin.multiplatform)
13-
alias(libs.plugins.kotest.multiplatform)
5+
alias(libs.plugins.kotest)
6+
id("com.google.devtools.ksp") version "2.2.0-2.0.2"
147
}
158

16-
allprojects {
17-
repositories {
18-
mavenCentral()
19-
mavenLocal()
20-
maven("https://oss.sonatype.org/content/repositories/snapshots")
21-
}
9+
repositories {
10+
mavenCentral()
11+
mavenLocal()
2212
}
2313

2414
kotlin {
2515

26-
targets {
27-
jvm {
28-
compilations.all {
29-
kotlinOptions {
30-
jvmTarget = "17"
31-
}
32-
}
33-
}
34-
js(IR) {
35-
browser()
36-
//nodejs()
37-
}
38-
linuxX64()
39-
macosX64()
40-
mingwX64()
16+
compilerOptions {
17+
apiVersion = KotlinVersion.KOTLIN_2_2
18+
languageVersion = KotlinVersion.KOTLIN_2_2
19+
verbose = true
4120
}
4221

43-
targets.all {
44-
compilations.all {
45-
kotlinOptions {
46-
verbose = true
47-
}
48-
}
22+
jvm()
23+
js {
24+
browser()
25+
nodejs()
4926
}
27+
linuxX64()
28+
// macosX64()
29+
// mingwX64()
5030

5131
sourceSets {
5232

53-
val commonMain by getting {
54-
dependencies {
55-
implementation(libs.kotlinx.coroutines.core)
56-
}
57-
}
58-
59-
val commonTest by getting {
33+
commonTest {
6034
dependencies {
61-
implementation(libs.kotest.assertions.core)
6235
implementation(libs.kotest.framework.engine)
63-
implementation(libs.kotest.framework.datatest)
64-
implementation(kotlin("test-common"))
65-
implementation(kotlin("test-annotations-common"))
66-
}
67-
}
68-
69-
val jvmTest by getting {
70-
dependencies {
71-
implementation(libs.kotest.runner.junit5)
36+
implementation(libs.kotest.assertions.core)
7237
}
7338
}
7439
}
7540
}
76-
77-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
78-
kotlinOptions {
79-
languageVersion = "1.9"
80-
apiVersion = "1.9"
81-
}
82-
}
83-
84-
tasks.named<Test>("jvmTest") {
85-
useJUnitPlatform()
86-
filter {
87-
isFailOnNoMatchingTests = false
88-
}
89-
testLogging {
90-
showExceptions = true
91-
showStandardStreams = true
92-
events = setOf(
93-
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
94-
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
95-
)
96-
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
97-
}
98-
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
[versions]
2-
kotlin = "1.9.23"
2+
kotlin = "2.2.0"
33
coroutines = "1.7.1"
4-
kotest = "5.9.1"
4+
kotest = "6.0.0-LOCAL"
55

66
[libraries]
77
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
88
kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
9-
kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" }
10-
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
119

1210
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
1311

1412
[plugins]
1513
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
16-
kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" }
14+
kotest = { id = "io.kotest", version.ref = "kotest" }

kotest-multiplatform/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
mavenLocal()
5+
}
6+
}

kotest-multiplatform/src/commonMain/kotlin/io/kotest/examples/multiplatform/UUID.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package io.kotest.examples.multiplatform
22

33
/**
44
* This is a UUID struct, but the implementations that generate the uuids are located
5-
* in the target specific source sets.
5+
* in the target-specific source sets.
66
*/
77
data class UUID(val value: String)
88

9-
expect fun generateUUID(): UUID
9+
expect fun generateUUID(): UUID

kotest-multiplatform/src/commonTest/kotlin/io/kotest/examples/mpp/data/DataDrivenTest.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package io.kotest.examples.mpp.uuid
22

3-
import io.kotest.core.spec.style.FunSpec
3+
import io.kotest.core.spec.style.DescribeSpec
44
import io.kotest.examples.multiplatform.generateUUID
55
import io.kotest.matchers.collections.shouldHaveSize
66

7-
class UUIDTestCommon : FunSpec() {
8-
init {
9-
test("uuids should be somewhat unique!") {
10-
List(100) { generateUUID() }.toSet().shouldHaveSize(100)
11-
}
12-
}
7+
class UUIDTestCommon : DescribeSpec() {
8+
init {
9+
describe("this test is in common-test so should run for all targets") {
10+
it("uuids should be somewhat unique!") {
11+
List(100) { generateUUID() }.toSet() shouldHaveSize 100
12+
}
13+
}
14+
}
1315
}

kotest-multiplatform/src/jsMain/kotlin/io/kotest/examples/multiplatform/generateUUID.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlin.js.Date
44
import kotlin.random.Random
55

66
actual fun generateUUID(): UUID {
7-
// this is not meant to be a high quality uuid, just showing the principal of each platform
7+
// this is not meant to be a real uuid, just showing the principal of each platform
88
// having its own implementation
99
return UUID(Date().getTime().toString() + Random.nextInt(10000000, 99999999).toString())
10-
}
10+
}

kotest-multiplatform/src/jsTest/kotlin/io/kotest/examples/mpp/UUIDJsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import io.kotest.matchers.string.shouldHaveLength
77
// this test only runs for JS implementations
88
class UUIDJsTest : FunSpec() {
99
init {
10-
test("uuids should have length 21") {
10+
test("Javascript implementations should have length 21") {
1111
generateUUID().value.shouldHaveLength(21)
1212
}
1313
}

0 commit comments

Comments
 (0)