File tree Expand file tree Collapse file tree 1 file changed +42
-3
lines changed Expand file tree Collapse file tree 1 file changed +42
-3
lines changed Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
2+
13plugins {
24 kotlin(" multiplatform" ) version " 1.4.30"
5+ jacoco
6+ id(" maven-publish" )
37}
48
5- group = " com .github.petertrr"
9+ group = " io .github.petertrr"
610version = " 0.0.1-SNAPSHOT"
711
812repositories {
@@ -12,10 +16,45 @@ repositories {
1216kotlin {
1317 jvm()
1418 sourceSets {
15- val commonMain by getting {
19+ val commonTest by getting {
1620 dependencies {
17-
21+ implementation(kotlin(" test-common" ))
22+ implementation(kotlin(" test-annotations-common" ))
1823 }
1924 }
25+ // platform-specific dependencies are needed to use actual test runners
26+ val jvmTest by getting {
27+ dependencies {
28+ implementation(kotlin(" test-junit5" ))
29+ }
30+ }
31+ }
32+ }
33+
34+ publishing {
35+ repositories {
36+ mavenLocal()
37+ }
38+ }
39+
40+ // configure Jacoco-based code coverage reports for JVM tests executions
41+ jacoco {
42+ toolVersion = " 0.8.6"
43+ }
44+ val jvmTestTask by tasks.named<KotlinJvmTest >(" jvmTest" ) {
45+ configure<JacocoTaskExtension > {
46+ // this is needed to generate jacoco/jvmTest.exec
47+ isEnabled = true
48+ }
49+ }
50+ val jacocoTestReportTask by tasks.register<JacocoReport >(" jacocoTestReport" ) {
51+ executionData(jvmTestTask.extensions.getByType(JacocoTaskExtension ::class .java).destinationFile)
52+ additionalSourceDirs(kotlin.sourceSets[" commonMain" ].kotlin.sourceDirectories)
53+ classDirectories.setFrom(file(" $buildDir /classes/kotlin/jvm" ))
54+ reports {
55+ xml.isEnabled = true
56+ html.isEnabled = true
2057 }
2158}
59+ jvmTestTask.finalizedBy(jacocoTestReportTask)
60+ jacocoTestReportTask.dependsOn(jvmTestTask)
You can’t perform that action at this time.
0 commit comments