build(meta): 增加发布配置.

为 meta 模块增加 Maven 构件发布配置, 但仍需本地发布(因为要 GPG 签名).
This commit is contained in:
LamGC 2022-06-27 18:49:40 +08:00
parent 5843e37196
commit aa31bcd3a8
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -1,11 +1,11 @@
plugins { plugins {
kotlin("jvm") version "1.6.10" kotlin("jvm") version "1.6.10"
id("org.jetbrains.kotlinx.kover") version "0.5.1" id("org.jetbrains.kotlinx.kover") version "0.5.1"
id("org.jetbrains.dokka") version "1.7.0"
`maven-publish`
signing
} }
group = "net.lamgc"
version = "0.3.1"
repositories { repositories {
mavenCentral() mavenCentral()
} }
@ -23,8 +23,90 @@ dependencies {
testImplementation("io.mockk:mockk:1.12.4") testImplementation("io.mockk:mockk:1.12.4")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
dokkaHtmlPlugin("org.jetbrains.dokka:javadoc-plugin:1.7.0")
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
}
}
java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
} }
tasks.getByName<Test>("test") { tasks.getByName<Test>("test") {
useJUnitPlatform() useJUnitPlatform()
} }
val javadocJar = tasks.named<Jar>("javadocJar") {
from(tasks.named("dokkaJavadoc"))
}
publishing {
repositories {
if (project.version.toString().endsWith("-SNAPSHOT", ignoreCase = true)) {
maven("https://nexus.kuku.me/repository/maven-snapshots/") {
credentials {
username = project.properties["repo.credentials.private.username"].toString()
password = project.properties["repo.credentials.private.password"].toString()
}
}
} else {
maven("https://nexus.kuku.me/repository/maven-releases/") {
credentials {
username = project.properties["repo.credentials.private.username"].toString()
password = project.properties["repo.credentials.private.password"].toString()
}
}
}
}
publications {
create<MavenPublication>("maven") {
from(components["kotlin"])
artifact(javadocJar)
artifact(tasks.named("sourcesJar"))
pom {
name.set("ScalaBot-meta")
description.set(
"Shared components used by scalabot (such as configuration classes)"
)
url.set("https://github.com/LamGC/ScalaBot")
licenses {
license {
name.set("The MIT License")
url.set("https://www.opensource.org/licenses/mit-license.php")
}
}
developers {
developer {
id.set("LamGC")
name.set("LamGC")
email.set("lam827@lamgc.net")
url.set("https://github.com/LamGC")
}
}
scm {
connection.set("scm:git:https://github.com/LamGC/ScalaBot.git")
developerConnection.set("scm:git:https://github.com/LamGC/ScalaBot.git")
url.set("https://github.com/LamGC/ScalaBot")
}
issueManagement {
url.set("https://github.com/LamGC/ScalaBot/issues")
system.set("Github Issues")
}
}
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["maven"])
}