From 156a2ca993fe5dabdb1b1d02f18538ce1cc6880b Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 2 Apr 2024 17:04:11 +1300 Subject: [PATCH] Set up publishing bits --- capacity/build.gradle.kts | 92 +++++++++++++++++++++++++++++++++++- percentage/build.gradle.kts | 74 +++++++++++++++++++++++++++++ temperature/build.gradle.kts | 74 +++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+), 1 deletion(-) diff --git a/capacity/build.gradle.kts b/capacity/build.gradle.kts index 710d326..daf4e14 100644 --- a/capacity/build.gradle.kts +++ b/capacity/build.gradle.kts @@ -1,10 +1,21 @@ +import org.jetbrains.dokka.gradle.DokkaTaskPartial +import java.net.URL + plugins { alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.android.library) alias(libs.plugins.detekt) + + alias(libs.plugins.dokka) + + id("maven-publish") + id("signing") } +group = findProperty("group")!! +version = findProperty("version")!! + android { namespace = "com.boswelja.capacity" @@ -22,10 +33,19 @@ android { sarifReport = true htmlReport = false } + + publishing { + singleVariant("release") { + withJavadocJar() + withSourcesJar() + } + } } kotlin { - androidTarget() + androidTarget { + publishLibraryVariants("release") + } jvm() jvmToolchain(17) @@ -48,3 +68,73 @@ detekt { config.setFrom("$rootDir/config/detekt.yml") basePath = rootDir.absolutePath } + +signing { + val signingKey: String? by project + val signingPassword: String? by project + useInMemoryPgpKeys(signingKey, signingPassword) + sign(publishing.publications) +} + +publishing { + repositories { + if (System.getenv("PUBLISHING") == "true") { + maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") { + val githubUsername: String? by project.properties + val githubToken: String? by project.properties + name = "github" + credentials { + username = githubUsername + password = githubToken + } + } + maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + val ossrhUsername: String? by project + val ossrhPassword: String? by project + name = "oss" + credentials { + username = ossrhUsername + password = ossrhPassword + } + } + } + } + + publications.withType { + pom { + name = "capacity" + description = "A Capacity class that allows you to convert between any unit of data storage" + url = "https://github.com/boswelja/kotlin-datatypes/tree/main/capacity" + licenses { + license { + name = "MIT" + url = "https://github.com/boswelja/kotlin-datatypes/blob/main/LICENSE" + } + } + developers { + developer { + id = "boswelja" + name = "Jack Boswell (boswelja)" + email = "boswelja@outlook.com" + url = "https://github.com/boswelja" + } + } + scm { + connection.set("scm:git:github.com/boswelja/kotlin-datatypes.git") + developerConnection.set("scm:git:ssh://github.com/boswelja/kotlin-datatypes.git") + url.set("https://github.com/boswelja/kotlin-datatypes") + } + } + } +} + +tasks.withType().configureEach { + dokkaSourceSets.configureEach { + includes.from("MODULE.md") + sourceLink { + localDirectory.set(projectDir.resolve("src")) + remoteUrl.set(URL("https://github.com/boswelja/kotlin-datatypes/tree/main/capacity/src")) + remoteLineSuffix.set("#L") + } + } +} diff --git a/percentage/build.gradle.kts b/percentage/build.gradle.kts index af82766..608ff94 100644 --- a/percentage/build.gradle.kts +++ b/percentage/build.gradle.kts @@ -1,10 +1,21 @@ +import org.jetbrains.dokka.gradle.DokkaTaskPartial +import java.net.URL + plugins { alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.android.library) alias(libs.plugins.detekt) + + alias(libs.plugins.dokka) + + id("maven-publish") + id("signing") } +group = findProperty("group")!! +version = findProperty("version")!! + android { namespace = "com.boswelja.percentage" @@ -48,3 +59,66 @@ detekt { config.setFrom("$rootDir/config/detekt.yml") basePath = rootDir.absolutePath } + +publishing { + repositories { + if (System.getenv("PUBLISHING") == "true") { + maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") { + val githubUsername: String? by project.properties + val githubToken: String? by project.properties + name = "github" + credentials { + username = githubUsername + password = githubToken + } + } + maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + val ossrhUsername: String? by project + val ossrhPassword: String? by project + name = "oss" + credentials { + username = ossrhUsername + password = ossrhPassword + } + } + } + } + + publications.withType { + pom { + name = "percentage" + description = "A Percentage class that allows you to convert between the most common percentage formats" + url = "https://github.com/boswelja/kotlin-datatypes/tree/main/percentage" + licenses { + license { + name = "MIT" + url = "https://github.com/boswelja/kotlin-datatypes/blob/main/LICENSE" + } + } + developers { + developer { + id = "boswelja" + name = "Jack Boswell (boswelja)" + email = "boswelja@outlook.com" + url = "https://github.com/boswelja" + } + } + scm { + connection.set("scm:git:github.com/boswelja/kotlin-datatypes.git") + developerConnection.set("scm:git:ssh://github.com/boswelja/kotlin-datatypes.git") + url.set("https://github.com/boswelja/kotlin-datatypes") + } + } + } +} + +tasks.withType().configureEach { + dokkaSourceSets.configureEach { + includes.from("MODULE.md") + sourceLink { + localDirectory.set(projectDir.resolve("src")) + remoteUrl.set(URL("https://github.com/boswelja/kotlin-datatypes/tree/main/percentage/src")) + remoteLineSuffix.set("#L") + } + } +} diff --git a/temperature/build.gradle.kts b/temperature/build.gradle.kts index 6de03c2..564b2a0 100644 --- a/temperature/build.gradle.kts +++ b/temperature/build.gradle.kts @@ -1,10 +1,21 @@ +import org.jetbrains.dokka.gradle.DokkaTaskPartial +import java.net.URL + plugins { alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.android.library) alias(libs.plugins.detekt) + + alias(libs.plugins.dokka) + + id("maven-publish") + id("signing") } +group = findProperty("group")!! +version = findProperty("version")!! + android { namespace = "com.boswelja.temperature" @@ -49,3 +60,66 @@ detekt { config.setFrom("$rootDir/config/detekt.yml") basePath = rootDir.absolutePath } + +publishing { + repositories { + if (System.getenv("PUBLISHING") == "true") { + maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") { + val githubUsername: String? by project.properties + val githubToken: String? by project.properties + name = "github" + credentials { + username = githubUsername + password = githubToken + } + } + maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + val ossrhUsername: String? by project + val ossrhPassword: String? by project + name = "oss" + credentials { + username = ossrhUsername + password = ossrhPassword + } + } + } + } + + publications.withType { + pom { + name = "temperature" + description = "A Temperature class that allows you to convert between any well-known temperature unit" + url = "https://github.com/boswelja/kotlin-datatypes/tree/main/temperature" + licenses { + license { + name = "MIT" + url = "https://github.com/boswelja/kotlin-datatypes/blob/main/LICENSE" + } + } + developers { + developer { + id = "boswelja" + name = "Jack Boswell (boswelja)" + email = "boswelja@outlook.com" + url = "https://github.com/boswelja" + } + } + scm { + connection.set("scm:git:github.com/boswelja/kotlin-datatypes.git") + developerConnection.set("scm:git:ssh://github.com/boswelja/kotlin-datatypes.git") + url.set("https://github.com/boswelja/kotlin-datatypes") + } + } + } +} + +tasks.withType().configureEach { + dokkaSourceSets.configureEach { + includes.from("MODULE.md") + sourceLink { + localDirectory.set(projectDir.resolve("src")) + remoteUrl.set(URL("https://github.com/boswelja/kotlin-datatypes/tree/main/temperature/src")) + remoteLineSuffix.set("#L") + } + } +}