Skip to content

Commit

Permalink
chore(build): get ready for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Nov 12, 2023
1 parent 5dfe753 commit 29be4c6
Showing 1 changed file with 75 additions and 3 deletions.
78 changes: 75 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.util.*

plugins {
id("java")
id("maven-publish")
id("signing")
id("com.github.johnrengelman.shadow") version "8.1.1"
}

Expand Down Expand Up @@ -31,11 +33,81 @@ tasks.withType<ShadowJar> {
archiveVersion.set("0.0.1")
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}

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

fun getExtraString(name: String) = ext[name]?.toString()

publishing {
publications {
create<MavenPublication>("shadow") {
project.shadow.component(this)
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}

publications.withType<MavenPublication> {
project.shadow.component(this)
artifact(javadocJar.get())

pom {
name.set("ZenKit Java Bindings")
description.set("Java bindings for ZenKit, the ZenGin Asset Parser")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("lmichaelis")
name.set("Luis Michaelis")
email.set("[email protected]")
organization.set("GothicKit")
organizationUrl.set("https://github.com/GothicKit")
}
}

scm {
url.set("https://github.com/GothicKit/ZenKit4J")
}
}
}
}

signing {
sign(publishing.publications)
}

0 comments on commit 29be4c6

Please sign in to comment.