Skip to content

Commit 08a6d13

Browse files
committed
✨ Switch to Kotlin Multiplatform and update publishing plugin
Changed from JVM to Kotlin Multiplatform for broader compatibility, adding multiple targets including JS, iOS, and Linux. Replaced old Maven publishing setup with Vanniktech Maven Publish plugin to simplify the configuration and deployment process. Closes #7
1 parent 2b72f46 commit 08a6d13

File tree

4 files changed

+53
-73
lines changed

4 files changed

+53
-73
lines changed

build.gradle.kts

+53-73
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1+
import com.vanniktech.maven.publish.SonatypeHost
22

33
plugins {
4-
kotlin("jvm") version "2.0.21"
5-
`maven-publish`
4+
kotlin("multiplatform") version "2.0.21"
5+
id("com.vanniktech.maven.publish") version "0.30.0"
66
signing
77
id("org.jetbrains.dokka") version "1.9.20"
88
id("io.gitlab.arturbosch.detekt") version "1.23.7"
@@ -15,90 +15,70 @@ repositories {
1515
mavenCentral()
1616
}
1717

18-
dependencies {
19-
val kotestVersion = "5.9.1"
20-
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
21-
testImplementation("io.kotest:kotest-property:$kotestVersion")
22-
}
18+
kotlin {
19+
applyDefaultHierarchyTemplate()
2320

24-
tasks.withType<KotlinCompile> {
25-
kotlinOptions.jvmTarget = "1.8"
26-
}
21+
jvm()
22+
js {
23+
browser()
24+
nodejs()
25+
}
2726

28-
kotlin {
29-
jvmToolchain(8)
27+
iosX64()
28+
iosArm64()
29+
iosSimulatorArm64()
30+
31+
macosX64()
32+
macosArm64()
33+
34+
linuxX64()
35+
linuxArm64()
36+
37+
sourceSets {
38+
val jvmTest by getting {
39+
dependencies {
40+
val kotestVersion = "5.9.1"
41+
42+
implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
43+
implementation("io.kotest:kotest-property:$kotestVersion")
44+
}
45+
}
46+
}
3047
}
3148

3249
tasks.withType<Test> {
3350
useJUnitPlatform()
3451
}
3552

36-
val sourcesJar by tasks.registering(Jar::class) {
37-
archiveClassifier.set("sources")
38-
from(sourceSets.getByName("main").allSource)
39-
}
53+
mavenPublishing {
54+
publishToMavenCentral(SonatypeHost.DEFAULT)
55+
signAllPublications()
4056

41-
val javadocJar by tasks.registering(Jar::class) {
42-
dependsOn("dokkaHtml")
43-
archiveClassifier.set("javadoc")
44-
from("$buildDir/dokka")
45-
}
57+
pom {
58+
name.set("SimpleCpfValidator")
59+
description.set("Simple CPF Validator")
60+
url.set("https://www.github.com/LeoColman/SimpleCpfValidator")
4661

47-
publishing {
48-
repositories {
49-
maven("https://oss.sonatype.org/service/local/staging/deploy/maven2") {
50-
credentials {
51-
username = System.getenv("OSSRH_USERNAME")
52-
password = System.getenv("OSSRH_PASSWORD")
53-
}
62+
63+
scm {
64+
connection.set("scm:git:http://www.github.com/LeoColman/SimpleCpfValidator/")
65+
developerConnection.set("scm:git:http://github.com/LeoColman/")
66+
url.set("https://www.github.com/LeoColman/SimpleCpfValidator")
5467
}
55-
}
5668

57-
publications {
58-
register("mavenJava", MavenPublication::class) {
59-
from(components["java"])
60-
artifact(sourcesJar.get())
61-
artifact(javadocJar.get())
62-
63-
pom {
64-
name.set("SimpleCpfValidator")
65-
description.set("Simple CPF Validator")
66-
url.set("https://www.github.com/LeoColman/SimpleCpfValidator")
67-
68-
69-
scm {
70-
connection.set("scm:git:http://www.github.com/LeoColman/SimpleCpfValidator/")
71-
developerConnection.set("scm:git:http://github.com/LeoColman/")
72-
url.set("https://www.github.com/LeoColman/SimpleCpfValidator")
73-
}
74-
75-
licenses {
76-
license {
77-
name.set("The Apache 2.0 License")
78-
url.set("https://opensource.org/licenses/Apache-2.0")
79-
}
80-
}
81-
82-
developers {
83-
developer {
84-
id.set("LeoColman")
85-
name.set("Leonardo Colman Lopes")
86-
email.set("[email protected]")
87-
}
88-
}
69+
licenses {
70+
license {
71+
name.set("The Apache 2.0 License")
72+
url.set("https://opensource.org/licenses/Apache-2.0")
8973
}
9074
}
91-
}
92-
}
93-
94-
val signingKey: String? by project
95-
val signingPassword: String? by project
9675

97-
signing {
98-
useGpgCmd()
99-
if (signingKey != null && signingPassword != null) {
100-
useInMemoryPgpKeys(signingKey, signingPassword)
76+
developers {
77+
developer {
78+
id.set("LeoColman")
79+
name.set("Leonardo Colman Lopes")
80+
email.set("[email protected]")
81+
}
82+
}
10183
}
102-
103-
sign(publishing.publications["mavenJava"])
10484
}

0 commit comments

Comments
 (0)