Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change publishing plugin #155

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 45 additions & 54 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -81,52 +73,51 @@ tasks.withType<Test>() {
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)
}