diff --git a/build.gradle.kts b/build.gradle.kts index 38036fa..d51a689 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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" } @@ -31,11 +33,81 @@ tasks.withType { 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("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 { + 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("publishing@lmichaelis.de") + organization.set("GothicKit") + organizationUrl.set("https://github.com/GothicKit") + } + } + + scm { + url.set("https://github.com/GothicKit/ZenKit4J") + } } } } +signing { + sign(publishing.publications) +}