Skip to content

Commit

Permalink
chore: Fix publish task
Browse files Browse the repository at this point in the history
  • Loading branch information
sya-ri committed Apr 13, 2024
1 parent 5ec9f6b commit d770c40
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 51 deletions.
114 changes: 63 additions & 51 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,73 +1,85 @@
plugins {
alias(libs.plugins.dokka)
`maven-publish`
signing
}

subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")
afterEvaluate {
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = libs.plugins.dokka.get().pluginId)

version = "1.0.0"
version = "1.0.0"

val sourceJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
val sourceJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}

publishing {
repositories {
maven {
url =
uri(
if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
},
)
credentials {
username = properties["sonatypeUsername"].toString()
password = properties["sonatypePassword"].toString()
val javadocJar by tasks.registering(Jar::class) {
dependsOn(tasks.dokkaJavadoc)

archiveClassifier.set("javadoc")
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
}

publishing {
repositories {
maven {
url =
uri(
if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
},
)
credentials {
username = properties["sonatypeUsername"].toString()
password = properties["sonatypePassword"].toString()
}
}
}
}
publications {
register<MavenPublication>("maven") {
groupId = "dev.s7a"
artifactId = "commandapi-${project.name}-kotlin-improved"
from(components["kotlin"])
artifact(sourceJar.get())
pom {
name.set("commandapi-${project.name}-kotlin-improved")
description.set("Improve CommandAPI Kotlin DSL")
url.set("https://github.com/sya-ri/commandapi-kotlin-improved")
publications {
register<MavenPublication>("maven") {
groupId = "dev.s7a"
artifactId = "commandapi-${project.name}-kotlin-improved"
from(components["kotlin"])
artifact(sourceJar.get())
artifact(javadocJar.get())
pom {
name.set("commandapi-${project.name}-kotlin-improved")
description.set("Improve CommandAPI Kotlin DSL")
url.set("https://github.com/sya-ri/commandapi-kotlin-improved")

licenses {
license {
name.set("MIT License")
url.set("https://github.com/sya-ri/commandapi-kotlin-improved/blob/master/LICENSE")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/sya-ri/commandapi-kotlin-improved/blob/master/LICENSE")
}
}
}
developers {
developer {
id.set("sya-ri")
name.set("sya-ri")
email.set("contact@s7a.dev")
developers {
developer {
id.set("sya-ri")
name.set("sya-ri")
email.set("contact@s7a.dev")
}
}
scm {
url.set("https://github.com/sya-ri/commandapi-kotlin-improved")
}
}
scm {
url.set("https://github.com/sya-ri/commandapi-kotlin-improved")
}
}
}
}
}

signing {
val key = properties["signingKey"]?.toString()?.replace("\\n", "\n")
val password = properties["signingPassword"]?.toString()
signing {
val key = properties["signingKey"]?.toString()?.replace("\\n", "\n")
val password = properties["signingPassword"]?.toString()

useInMemoryPgpKeys(key, password)
sign(publishing.publications["maven"])
useInMemoryPgpKeys(key, password)
sign(publishing.publications["maven"])
}
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
kotlin = "1.9.23"
kotlinter = "4.3.0"
dokka = "1.9.20"
shadow = "8.1.1"
git-version = "3.0.0"
plugin-yml = "0.6.0"
Expand All @@ -11,6 +12,7 @@ paper = "1.19.4-R0.1-SNAPSHOT"
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
git-version = { id = "com.palantir.git-version", version.ref = "git-version" }
plugin-yml-bukkit = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "plugin-yml" }
Expand Down

0 comments on commit d770c40

Please # to comment.