Skip to content

Commit 23b3c96

Browse files
committed
setup publishing
1 parent db8953a commit 23b3c96

File tree

1 file changed

+87
-11
lines changed

1 file changed

+87
-11
lines changed

build.gradle.kts

+87-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ plugins {
44

55
id("com.gradleup.shadow") version "8.3.3"
66

7+
`maven-publish`
8+
signing
9+
710
id("xyz.jpenilla.run-paper") version "2.3.1"
811
}
912

@@ -21,24 +24,26 @@ repositories {
2124
}
2225

2326
dependencies {
24-
compileOnly(kotlin("stdlib"))
25-
compileOnly(kotlin("reflect"))
26-
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
27+
implementation(kotlin("stdlib"))
28+
implementation(kotlin("reflect"))
29+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
2730

28-
compileOnly("io.papermc.paper:paper-api:$mcVersion-R0.1-SNAPSHOT")
31+
implementation("io.papermc.paper:paper-api:$mcVersion-R0.1-SNAPSHOT")
2932

3033
implementation("org.bstats:bstats-bukkit:1.7")
3134
}
3235

3336
tasks {
34-
val filename = "${project.name}-${project.version}.jar"
3537
jar {
36-
archiveFileName = "original-$filename"
38+
archiveClassifier = "original"
3739
}
3840

3941
shadowJar {
40-
archiveFileName = filename
42+
archiveClassifier = ""
4143
relocate("org.bstats", "com.zp4rker.bukkot.bstats")
44+
dependencies {
45+
include { it.moduleGroup == "org.bstats" }
46+
}
4247
}
4348

4449
processResources {
@@ -55,10 +60,81 @@ tasks {
5560
dependsOn(shadowJar)
5661
}
5762

58-
runServer {
59-
minecraftVersion(mcVersion)
60-
subprojects.forEach {
61-
pluginJars(it.tasks.jar.map { jar -> jar.archiveFile })
63+
create<Jar>("javadocJar") {
64+
archiveClassifier = "javadoc"
65+
from(javadoc)
66+
}
67+
create<Jar>("sourcesJar") {
68+
archiveClassifier = "sources"
69+
from(sourceSets["main"].allSource)
70+
}
71+
}
72+
73+
val sources = artifacts.add("archives", tasks["sourcesJar"])
74+
val javadocs = artifacts.add("archives", tasks["javadocJar"])
75+
val final = artifacts.add("archives", tasks["shadowJar"])
76+
77+
publishing {
78+
publications {
79+
create<MavenPublication>("bukkot") {
80+
artifactId = project.name
81+
from(components["kotlin"])
82+
83+
artifact(sources)
84+
artifact(javadocs)
85+
artifact(final)
86+
87+
pom {
88+
name = project.name
89+
description = project.description
90+
url = "https://github.com/zp4rker/bukkot"
91+
92+
packaging = "jar"
93+
94+
licenses {
95+
license {
96+
name = "The Apache License, Version 2.0"
97+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
98+
}
99+
}
100+
101+
developers {
102+
developer {
103+
id = "zp4rker"
104+
name = "Zaeem Parker"
105+
106+
}
107+
}
108+
109+
scm {
110+
connection = "scm:git:git://github.com/zp4rker/bukkot.git"
111+
url = "https://github.com/zp4rker/bukkot"
112+
}
113+
114+
repositories {
115+
maven {
116+
val stagingUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
117+
val snapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots"
118+
url = uri(if (project.version.toString().endsWith("-SNAPSHOT")) snapshotsUrl else stagingUrl)
119+
credentials {
120+
username = System.getenv("OSSRH_USERNAME")
121+
password = System.getenv("OSSRH_PASSWORD")
122+
}
123+
}
124+
}
125+
}
62126
}
63127
}
128+
}
129+
130+
signing {
131+
useGpgCmd()
132+
sign(publishing.publications["bukkot"])
133+
}
134+
135+
tasks.runServer {
136+
minecraftVersion(mcVersion)
137+
subprojects.forEach {
138+
pluginJars(it.tasks.jar.map { jar -> jar.archiveFile })
139+
}
64140
}

0 commit comments

Comments
 (0)