Skip to content

Commit 7701cf8

Browse files
committed
convert project to kotlin multiplatform
1 parent 55992dc commit 7701cf8

File tree

58 files changed

+2868
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2868
-549
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ outTmp/
7575
/kotlin-native/dist
7676
kotlin-ide/
7777
site/
78+
kotlin-js-store/
79+
.kotlin/

build.gradle.kts

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,92 @@
1+
import org.jetbrains.kotlin.gradle.dsl.*
2+
13
group = "com.trendyol"
24

35
plugins {
46
kotlin("jvm") version libs.versions.kotlin.get()
57
java
68
alias(libs.plugins.spotless)
79
alias(libs.plugins.maven.publish)
10+
alias(libs.plugins.kover)
11+
alias(libs.plugins.testLogger)
812
}
913

1014
version = properties["version"]!!
1115

16+
val kmpModules = listOf(
17+
projects.projects.kediatrCore.name,
18+
projects.projects.kediatrKoinStarter.name,
19+
)
20+
1221
subprojectsOf("projects") {
22+
val isKmp = name in kmpModules
23+
1324
apply {
14-
plugin("kotlin")
15-
plugin("java")
25+
if (isKmp) {
26+
plugin("org.jetbrains.kotlin.multiplatform")
27+
} else {
28+
plugin("kotlin")
29+
plugin("java")
30+
}
1631
plugin(rootProject.libs.plugins.spotless.pluginId)
1732
plugin(rootProject.libs.plugins.maven.publish.pluginId)
33+
plugin(rootProject.libs.plugins.kover.pluginId)
34+
plugin(rootProject.libs.plugins.testLogger.pluginId)
1835
}
1936

37+
configureKotlin(isKmp)
38+
2039
spotless {
2140
kotlin {
2241
ktlint(rootProject.libs.ktlint.cli.get().version)
2342
.setEditorConfigPath(rootProject.layout.projectDirectory.file(".editorconfig"))
2443
}
2544
}
2645

27-
java {
28-
withSourcesJar()
46+
kover {
47+
reports {
48+
filters {
49+
excludes {
50+
packages("com.trendyol.kediatr.testing")
51+
}
52+
}
53+
}
54+
}
55+
56+
dependencies {
57+
kover(project)
58+
}
59+
60+
// KMP modules handle sources jar automatically, JVM-only modules need explicit configuration
61+
if (!isKmp) {
62+
java {
63+
withSourcesJar()
64+
}
65+
66+
dependencies {
67+
implementation(rootProject.libs.kotlinx.coroutines.core)
68+
testImplementation(rootProject.libs.kotlinx.coroutines.test)
69+
testImplementation(rootProject.libs.kotest.assertions.core)
70+
testImplementation(rootProject.libs.kotest.assertions.table)
71+
testImplementation(rootProject.libs.kotest.framework.engine)
72+
testImplementation(rootProject.libs.kotest.runner.junit5)
73+
}
74+
}
75+
76+
tasks.withType<Test> {
77+
useJUnitPlatform()
78+
configure<com.adarshr.gradle.testlogger.TestLoggerExtension> {
79+
setTheme("mocha")
80+
showStandardStreams = true
81+
}
82+
reports {
83+
junitXml.required.set(true)
84+
html.required.set(true)
85+
}
2986
}
87+
}
3088

89+
subprojects.of("project", except = listOf(projects.projects.kediatrTesting.name)) {
3190
mavenPublishing {
3291
coordinates(groupId = rootProject.group.toString(), artifactId = project.name, version = rootProject.version.toString())
3392
publishToMavenCentral()
@@ -57,3 +116,21 @@ subprojectsOf("projects") {
57116
signAllPublications()
58117
}
59118
}
119+
120+
fun Project.configureKotlin(isKmp: Boolean) {
121+
val kotlinExtension = if (isKmp) {
122+
extensions.getByType<KotlinMultiplatformExtension>()
123+
} else {
124+
extensions.getByType<KotlinJvmProjectExtension>()
125+
}
126+
127+
kotlinExtension.apply {
128+
jvmToolchain(17)
129+
compilerOptions {
130+
val commonArgs = listOf("-Xskip-metadata-version-check", "-Xexpect-actual-classes")
131+
val args = if (isKmp) commonArgs else listOf("-Xjsr305=strict") + commonArgs
132+
freeCompilerArgs.addAll(args)
133+
allWarningsAsErrors.set(true)
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)