-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): get ready for publishing
- Loading branch information
1 parent
5dfe753
commit 29be4c6
Showing
1 changed file
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
|
||
|
@@ -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) | ||
} |