1- import io.github.petertrr.configurePublishing
2- import io.github.petertrr.ext.booleanProperty
31import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
42import org.jetbrains.kotlin.gradle.dsl.JvmTarget
53import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
64import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
75
86plugins {
9- kotlin(" multiplatform" )
7+ alias(libs.plugins.kotlinMultiplatform)
8+ alias(libs.plugins.dokka)
109 alias(libs.plugins.detekt)
11- id(" jacoco-convention" )
10+ alias(libs.plugins.vanniktech)
11+ jacoco
1212}
1313
1414group = " io.github.petertrr"
@@ -20,10 +20,9 @@ dependencies {
2020
2121kotlin {
2222 explicitApi()
23-
2423 compilerOptions {
25- apiVersion = KotlinVersion .KOTLIN_2_1
26- languageVersion = KotlinVersion .KOTLIN_2_1
24+ apiVersion = KotlinVersion .KOTLIN_2_2
25+ languageVersion = KotlinVersion .KOTLIN_2_2
2726 }
2827
2928 jvm {
@@ -117,16 +116,91 @@ kotlin {
117116 }
118117}
119118
120- configurePublishing()
119+ mavenPublishing {
120+ coordinates(
121+ groupId = project.group.toString(),
122+ artifactId = project.name,
123+ version = project.version.toString(),
124+ )
125+
126+ // Publishing to Maven Central requires the following Gradle properties:
127+ // mavenCentralUsername=central_username
128+ // mavenCentralPassword=central_password
129+ publishToMavenCentral()
130+
131+ // Signing is enabled only if the key is actually provided.
132+ // We do not want missing signing info to block publication to local.
133+ val signingKey = project.providers.gradleProperty(" signingInMemoryKey" )
134+
135+ if (signingKey.isPresent) {
136+ // Signing requires the following Gradle properties:
137+ // signingInMemoryKeyId=pgp_key_id
138+ // signingInMemoryKey=pgp_key
139+ // signingInMemoryKeyPassword=pgp_key_password
140+ signAllPublications()
141+ }
142+
143+ pom {
144+ name.set(project.name)
145+ description.set(project.description)
146+ url.set(" https://github.com/petertrr/kotlin-multiplatform-diff" )
147+
148+ licenses {
149+ license {
150+ name.set(" The Apache Software License, Version 2.0" )
151+ url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
152+ distribution.set(" repo" )
153+ }
154+ }
155+
156+ developers {
157+ developer {
158+ id.set(" petertrr" )
159+ name.set(" Petr Trifanov" )
160+ email.set(" peter.trifanov@gmail.com" )
161+ }
162+ }
163+
164+ scm {
165+ url.set(" https://github.com/petertrr/kotlin-multiplatform-diff" )
166+ connection.set(" scm:git:git://github.com/petertrr/kotlin-multiplatform-diff.git" )
167+ }
168+ }
169+ }
170+
171+ jacoco {
172+ toolVersion = " 0.8.13"
173+ }
121174
122175detekt {
123176 buildUponDefaultConfig = true
124177 config.setFrom(files(" detekt.yml" ))
125- autoCorrect = booleanProperty (" detektAutoCorrect" , default = true )
178+ autoCorrect = project.providers.gradleProperty (" detektAutoCorrect" ).map( String ::toBoolean).getOrElse( true )
126179}
127180
128181tasks {
129182 check {
130183 dependsOn(detekt)
131184 }
185+
186+ val jvmTest = named<Test >(" jvmTest" )
187+ val jacocoReport = register<JacocoReport >(" jacocoTestReport" ) {
188+ dependsOn(jvmTest)
189+
190+ val commonMainSources = kotlin.sourceSets[" commonMain" ].kotlin.sourceDirectories
191+ val jvmMainSources = kotlin.sourceSets[" jvmMain" ].kotlin.sourceDirectories
192+
193+ sourceDirectories.setFrom(files(commonMainSources, jvmMainSources))
194+ classDirectories.setFrom(layout.buildDirectory.file(" classes/kotlin/jvm/main" ))
195+ executionData.setFrom(layout.buildDirectory.files(" jacoco/jvmTest.exec" ))
196+
197+ reports {
198+ xml.required = true
199+ html.required = true
200+ }
201+ }
202+
203+ jvmTest.configure {
204+ finalizedBy(jacocoReport)
205+ }
132206}
0 commit comments