diff --git a/build.gradle.kts b/build.gradle.kts index b0520b2..bb521b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,15 +1,18 @@ +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinMultiplatform +import com.vanniktech.maven.publish.SonatypeHost import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { kotlin("multiplatform") version "2.1.0" id("org.jetbrains.dokka") version "2.0.0" id("org.jetbrains.kotlinx.kover") version "0.9.0" - `maven-publish` - signing + id("com.vanniktech.maven.publish") version "0.30.0" } group = "com.jsoizo" version = "1.10.0" +val projectName = "kotlin-csv" buildscript { repositories { @@ -21,22 +24,11 @@ repositories { mavenCentral() } -val dokkaJar by tasks.registering(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - description = "A Javadoc JAR containing Dokka HTML" - from(tasks.dokkaHtml.flatMap { it.outputDirectory }) - archiveClassifier.set("javadoc") -} - kotlin { jvm { compilerOptions { jvmTarget.set(JvmTarget.JVM_1_8) } - //https://docs.gradle.org/current/userguide/publishing_maven.html - mavenPublication { - artifact(dokkaJar) - } } js { browser { @@ -81,52 +73,51 @@ tasks.withType() { useJUnitPlatform() } +mavenPublishing { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) -publishing { - publications.all { - (this as MavenPublication).pom { - name.set("kotlin-csv") - description.set("Kotlin CSV Reader/Writer") - url.set("https://github.com/jsoizo/kotlin-csv") + if (project.hasProperty("signing.keyId")) { + signAllPublications() + } - organization { - name.set("com.jsoizo") - url.set("https://github.com/jsoizo") - } - licenses { - license { - name.set("Apache License 2.0") - url.set("https://github.com/jsoizo/kotlin-csv/blob/master/LICENSE") - } - } - scm { - url.set("https://github.com/jsoizo/kotlin-csv") - connection.set("scm:git:git://github.com/jsoizo/kotlin-csv.git") - developerConnection.set("https://github.com/jsoizo/kotlin-csv") - } - developers { - developer { - name.set("jsoizo") - } + coordinates(group.toString(), projectName, version.toString()) + + configure( + KotlinMultiplatform( + javadocJar = JavadocJar.Dokka("dokkaHtml"), + sourcesJar = true, + androidVariantsToPublish = listOf("debug", "release"), + ) + ) + + val repo = "github.com/jsoizo/${projectName}" + val repoHttpUrl = "https://${repo}" + val repoGitUrl = "git://${repo}.git" + + pom { + name = projectName + description = "Pure Kotlin CSV reader and writer" + inceptionYear = "2019" + url = repoHttpUrl + organization { + name.set("com.jsoizo") + url.set("https://github.com/jsoizo") + } + licenses { + license { + name.set("Apache License 2.0") + url.set("${repoHttpUrl}/blob/master/LICENSE") } } - } - repositories { - maven { - credentials { - val nexusUsername: String? by project - val nexusPassword: String? by project - username = nexusUsername - password = nexusPassword + scm { + url.set(repoHttpUrl) + connection.set("scm:git:${repoGitUrl}") + developerConnection.set(repoHttpUrl) + } + developers { + developer { + name.set("jsoizo") } - - val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/") - url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl } } -} - -signing { - sign(publishing.publications) } \ No newline at end of file