Skip to content

Commit 6e78b2f

Browse files
committed
[skip ci] change publishing plugin
1 parent 09fcaa2 commit 6e78b2f

File tree

1 file changed

+45
-54
lines changed

1 file changed

+45
-54
lines changed

build.gradle.kts

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
import com.vanniktech.maven.publish.JavadocJar
2+
import com.vanniktech.maven.publish.KotlinMultiplatform
3+
import com.vanniktech.maven.publish.SonatypeHost
14
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
25

36
plugins {
47
kotlin("multiplatform") version "2.1.0"
58
id("org.jetbrains.dokka") version "2.0.0"
69
id("org.jetbrains.kotlinx.kover") version "0.9.0"
7-
`maven-publish`
8-
signing
10+
id("com.vanniktech.maven.publish") version "0.30.0"
911
}
1012

1113
group = "com.jsoizo"
1214
version = "1.10.0"
15+
val projectName = "kotlin-csv"
1316

1417
buildscript {
1518
repositories {
@@ -21,22 +24,11 @@ repositories {
2124
mavenCentral()
2225
}
2326

24-
val dokkaJar by tasks.registering(Jar::class) {
25-
group = JavaBasePlugin.DOCUMENTATION_GROUP
26-
description = "A Javadoc JAR containing Dokka HTML"
27-
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
28-
archiveClassifier.set("javadoc")
29-
}
30-
3127
kotlin {
3228
jvm {
3329
compilerOptions {
3430
jvmTarget.set(JvmTarget.JVM_1_8)
3531
}
36-
//https://docs.gradle.org/current/userguide/publishing_maven.html
37-
mavenPublication {
38-
artifact(dokkaJar)
39-
}
4032
}
4133
js {
4234
browser {
@@ -81,52 +73,51 @@ tasks.withType<Test>() {
8173
useJUnitPlatform()
8274
}
8375

76+
mavenPublishing {
77+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
8478

85-
publishing {
86-
publications.all {
87-
(this as MavenPublication).pom {
88-
name.set("kotlin-csv")
89-
description.set("Kotlin CSV Reader/Writer")
90-
url.set("https://github.com/jsoizo/kotlin-csv")
79+
if (project.hasProperty("signing.keyId")) {
80+
signAllPublications()
81+
}
9182

92-
organization {
93-
name.set("com.jsoizo")
94-
url.set("https://github.com/jsoizo")
95-
}
96-
licenses {
97-
license {
98-
name.set("Apache License 2.0")
99-
url.set("https://github.com/jsoizo/kotlin-csv/blob/master/LICENSE")
100-
}
101-
}
102-
scm {
103-
url.set("https://github.com/jsoizo/kotlin-csv")
104-
connection.set("scm:git:git://github.com/jsoizo/kotlin-csv.git")
105-
developerConnection.set("https://github.com/jsoizo/kotlin-csv")
106-
}
107-
developers {
108-
developer {
109-
name.set("jsoizo")
110-
}
83+
coordinates(group.toString(), projectName, version.toString())
84+
85+
configure(
86+
KotlinMultiplatform(
87+
javadocJar = JavadocJar.Dokka("dokkaHtml"),
88+
sourcesJar = true,
89+
androidVariantsToPublish = listOf("debug", "release"),
90+
)
91+
)
92+
93+
val repo = "github.com/jsoizo/${projectName}"
94+
val repoHttpUrl = "https://${repo}"
95+
val repoGitUrl = "git://${repo}.git"
96+
97+
pom {
98+
name = projectName
99+
description = "Pure Kotlin CSV reader and writer"
100+
inceptionYear = "2019"
101+
url = repoHttpUrl
102+
organization {
103+
name.set("com.jsoizo")
104+
url.set("https://github.com/jsoizo")
105+
}
106+
licenses {
107+
license {
108+
name.set("Apache License 2.0")
109+
url.set("${repoHttpUrl}/blob/master/LICENSE")
111110
}
112111
}
113-
}
114-
repositories {
115-
maven {
116-
credentials {
117-
val nexusUsername: String? by project
118-
val nexusPassword: String? by project
119-
username = nexusUsername
120-
password = nexusPassword
112+
scm {
113+
url.set(repoHttpUrl)
114+
connection.set("scm:git:${repoGitUrl}")
115+
developerConnection.set(repoHttpUrl)
116+
}
117+
developers {
118+
developer {
119+
name.set("jsoizo")
121120
}
122-
123-
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
124-
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
125-
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
126121
}
127122
}
128-
}
129-
130-
signing {
131-
sign(publishing.publications)
132123
}

0 commit comments

Comments
 (0)