Skip to content

Commit

Permalink
Use a precompiled script for publishing & fix javadoc jar (#66)
Browse files Browse the repository at this point in the history
* Set up a precompiled script for publishing

* Add gitignore
  • Loading branch information
boswelja authored Dec 22, 2024
1 parent bfd7e0e commit 9a2ff92
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 130 deletions.
1 change: 1 addition & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
3 changes: 3 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
`kotlin-dsl`
}
11 changes: 11 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
86 changes: 86 additions & 0 deletions buildSrc/src/main/kotlin/com.boswelja.publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
plugins {
id("maven-publish")
id("signing")
}

interface CustomPublishingExtension {
val description: Property<String>
val repositoryUrl: Property<String>
val license: Property<String>
}

val extension = project.extensions.create<CustomPublishingExtension>("publish")

group = findProperty("group")!!
version = findProperty("version")!!

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

afterEvaluate {
publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
maven("https://maven.pkg.github.com/boswelja/compose-markdown") {
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> {
val javadocJar = tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
// Each archive name should be distinct. Mirror the format for the sources Jar tasks.
archiveBaseName.set("${archiveBaseName.get()}-${name}")
}
artifact(javadocJar)
pom {
name = project.name
description = extension.description
url = extension.repositoryUrl.get()
licenses {
license {
name = extension.license.get()
url = "${extension.repositoryUrl}/blob/main/LICENSE"
}
}
developers {
developer {
id = "boswelja"
name = "Jack Boswell (boswelja)"
email = "boswelja@outlook.com"
url = "https://github.com/boswelja"
}
}
scm {
url.set(extension.repositoryUrl.get())
}
}
}
}

// TODO: Remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed
// Thanks to KSoup repository for this code snippet
tasks.withType(AbstractPublishToMaven::class).configureEach {
dependsOn(tasks.withType(Sign::class))
}
}
70 changes: 5 additions & 65 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ plugins {
alias(libs.plugins.detekt)

alias(libs.plugins.dokka)

id("maven-publish")
id("signing")
id("com.boswelja.publish")
}

group = findProperty("group")!!
Expand Down Expand Up @@ -123,68 +121,10 @@ detekt {
basePath = rootDir.absolutePath
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier = "javadoc"
}

publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
maven("https://maven.pkg.github.com/boswelja/compose-markdown") {
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> {
artifact(javadocJar)
pom {
name = "core"
description = " A native Compose Markdown renderer"
url = "https://github.com/boswelja/compose-markdown"
licenses {
license {
name = "MIT"
url = "https://github.com/boswelja/compose-markdown/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/compose-markdown.git")
developerConnection.set("scm:git:ssh://github.com/boswelja/compose-markdown.git")
url.set("https://github.com/boswelja/compose-markdown")
}
}
}
publish {
description = "A native Compose Markdown renderer"
repositoryUrl = "https://github.com/boswelja/compose-markdown"
license = "MIT"
}

dokka {
Expand Down
70 changes: 5 additions & 65 deletions material3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ plugins {
alias(libs.plugins.detekt)

alias(libs.plugins.dokka)

id("maven-publish")
id("signing")
id("com.boswelja.publish")
}

group = findProperty("group")!!
Expand Down Expand Up @@ -78,68 +76,10 @@ detekt {
basePath = rootDir.absolutePath
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier = "javadoc"
}

publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
maven("https://maven.pkg.github.com/boswelja/compose-markdown") {
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> {
artifact(javadocJar)
pom {
name = "material3"
description = " A native Compose Markdown renderer"
url = "https://github.com/boswelja/compose-markdown"
licenses {
license {
name = "MIT"
url = "https://github.com/boswelja/compose-markdown/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/compose-markdown.git")
developerConnection.set("scm:git:ssh://github.com/boswelja/compose-markdown.git")
url.set("https://github.com/boswelja/compose-markdown")
}
}
}
publish {
description = "A native Compose Markdown renderer"
repositoryUrl = "https://github.com/boswelja/compose-markdown"
license = "MIT"
}

dokka {
Expand Down

0 comments on commit 9a2ff92

Please sign in to comment.