Skip to content

Commit

Permalink
Set up publishing bits
Browse files Browse the repository at this point in the history
  • Loading branch information
boswelja committed Apr 2, 2024
1 parent 2ab3538 commit 156a2ca
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 1 deletion.
92 changes: 91 additions & 1 deletion capacity/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -22,10 +33,19 @@ android {
sarifReport = true
htmlReport = false
}

publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}
}
}

kotlin {
androidTarget()
androidTarget {
publishLibraryVariants("release")
}
jvm()
jvmToolchain(17)

Expand All @@ -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<MavenPublication> {
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<DokkaTaskPartial>().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")
}
}
}
74 changes: 74 additions & 0 deletions percentage/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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<MavenPublication> {
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<DokkaTaskPartial>().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")
}
}
}
74 changes: 74 additions & 0 deletions temperature/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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<MavenPublication> {
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<DokkaTaskPartial>().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")
}
}
}

0 comments on commit 156a2ca

Please sign in to comment.