|
| 1 | +@file:OptIn(ExperimentalKotlinGradlePluginApi::class) |
| 2 | + |
1 | 3 | import io.github.petertrr.configurePublishing |
| 4 | +import io.github.petertrr.ext.booleanProperty |
2 | 5 | import io.gitlab.arturbosch.detekt.Detekt |
3 | | -import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest |
| 6 | +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi |
| 7 | +import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 8 | +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion |
4 | 9 |
|
5 | 10 | plugins { |
6 | 11 | kotlin("multiplatform") |
7 | | - id("jacoco-convention") |
8 | 12 | alias(libs.plugins.detekt) |
| 13 | + id("jacoco-convention") |
9 | 14 | } |
10 | 15 |
|
11 | 16 | group = "io.github.petertrr" |
12 | 17 | description = "A multiplatform Kotlin library for calculating text differences" |
13 | 18 |
|
| 19 | +dependencies { |
| 20 | + detektPlugins(libs.detekt.formatting) |
| 21 | +} |
| 22 | + |
14 | 23 | kotlin { |
15 | 24 | explicitApi() |
16 | 25 |
|
17 | | - jvm() |
18 | | - js(IR) { |
| 26 | + compilerOptions { |
| 27 | + apiVersion = KotlinVersion.KOTLIN_1_9 |
| 28 | + languageVersion = KotlinVersion.KOTLIN_1_9 |
| 29 | + } |
| 30 | + |
| 31 | + jvm { |
| 32 | + compilations.configureEach { |
| 33 | + compilerOptions.configure { |
| 34 | + // Minimum bytecode level is 52 |
| 35 | + jvmTarget = JvmTarget.JVM_1_8 |
| 36 | + |
| 37 | + // Output interfaces with default methods |
| 38 | + freeCompilerArgs.add("-Xjvm-default=all") |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + testRuns.configureEach { |
| 43 | + executionTask.configure { |
| 44 | + useJUnitPlatform() |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + js { |
19 | 50 | browser() |
20 | 51 | nodejs() |
21 | 52 | } |
22 | | - // setup native compilation |
| 53 | + |
23 | 54 | linuxX64() |
24 | 55 | mingwX64() |
25 | 56 | macosX64() |
26 | 57 |
|
27 | 58 | sourceSets { |
28 | | - val commonTest by getting { |
29 | | - dependencies { |
30 | | - implementation(kotlin("test-common")) |
31 | | - implementation(kotlin("test-annotations-common")) |
32 | | - } |
33 | | - } |
34 | | - // platform-specific dependencies are needed to use actual test runners |
35 | | - val jvmTest by getting { |
36 | | - dependencies { |
37 | | - implementation(kotlin("test-junit5")) |
38 | | - implementation(libs.junit.jupiter.engine) |
39 | | - runtimeOnly("org.junit.platform:junit-platform-launcher") |
40 | | - } |
41 | | - } |
42 | | - val jsTest by getting { |
| 59 | + commonTest { |
43 | 60 | dependencies { |
44 | | - implementation(kotlin("test-js")) |
| 61 | + implementation(kotlin("test")) |
45 | 62 | } |
46 | 63 | } |
47 | 64 | } |
48 | 65 | } |
49 | 66 |
|
50 | 67 | configurePublishing() |
51 | 68 |
|
52 | | -tasks.withType<KotlinJvmTest> { |
53 | | - useJUnitPlatform() |
54 | | -} |
55 | | - |
56 | 69 | detekt { |
57 | 70 | buildUponDefaultConfig = true |
58 | 71 | config.setFrom(files("detekt.yml")) |
59 | | - autoCorrect = (findProperty("detektAutoCorrect") as String?)?.toBoolean() ?: true |
60 | | -} |
61 | | -dependencies { |
62 | | - detektPlugins(libs.detekt.formatting) |
| 72 | + autoCorrect = booleanProperty("detektAutoCorrect", default = true) |
63 | 73 | } |
64 | | -tasks.withType<Detekt> { |
65 | | - tasks.getByName("check").dependsOn(this) |
| 74 | + |
| 75 | +tasks { |
| 76 | + withType<Detekt> { |
| 77 | + named("check") { |
| 78 | + dependsOn(this@withType) |
| 79 | + } |
| 80 | + } |
66 | 81 | } |
0 commit comments