@@ -4,10 +4,12 @@ plugins {
44 kotlin(" jvm" ) version " 2.0.21"
55 kotlin(" kapt" ) version " 2.0.21"
66 id(" com.github.johnrengelman.shadow" ) version " 8.1.1"
7+ id(" org.jreleaser" ) version " 1.14.0"
78 `maven- publish`
9+ signing
810}
911
10- group = " co.statu .parsek"
12+ group = " dev .parsek"
1113version =
1214 (if (project.hasProperty(" version" ) && project.findProperty(" version" ) != " unspecified" ) project.findProperty(" version" ) else " local-build" )!!
1315
@@ -21,14 +23,13 @@ val pluginsDir: File? by rootProject.extra
2123
2224repositories {
2325 mavenCentral()
24- maven(" https://jitpack.io" )
2526}
2627
2728dependencies {
2829 if (bootstrap) {
2930 compileOnly(project(mapOf (" path" to " :Parsek" )))
3031 } else {
31- compileOnly(" com.github.parsekdev: parsek:v1 .0.0-beta.12 " )
32+ compileOnly(" dev. parsek:core:1 .0.0-beta.18 " )
3233 }
3334
3435 compileOnly(kotlin(" stdlib-jdk8" ))
@@ -59,6 +60,12 @@ dependencies {
5960}
6061
6162tasks {
63+ build {
64+ dependsOn(" copyJar" )
65+ // Ensure standard jar is built for Maven publishing (stays in build/libs)
66+ dependsOn(jar)
67+ }
68+
6269 shadowJar {
6370 val pluginId: String by project
6471 val pluginClass: String by project
@@ -81,6 +88,10 @@ tasks {
8188 it.moduleGroup == " io.netty" || it.moduleGroup == " org.slf4j"
8289 }
8390 }
91+
92+ if (project.gradle.startParameter.taskNames.contains(" publish" )) {
93+ archiveFileName.set(archiveFileName.get().lowercase())
94+ }
8495 }
8596
8697 register(" copyJar" ) {
@@ -96,44 +107,46 @@ tasks {
96107 outputs.upToDateWhen { false }
97108 mustRunAfter(shadowJar)
98109 }
99-
100- jar {
101- enabled = false
102- dependsOn(shadowJar)
103- dependsOn(" copyJar" )
104- }
105110}
106111
107- publishing {
108- repositories {
109- maven {
110- name = " parsek-plugin-database"
111- url = uri(" https://maven.pkg.github.com/StatuParsek/parsek-plugin-database" )
112- credentials {
113- username = project.findProperty(" gpr.user" ) as String? ? : System .getenv(" USERNAME_GITHUB" )
114- password = project.findProperty(" gpr.token" ) as String? ? : System .getenv(" TOKEN_GITHUB" )
115- }
116- }
117- }
118-
119- publications {
120- create<MavenPublication >(" shadow" ) {
121- project.extensions.configure< com.github.jengelman.gradle.plugins.shadow.ShadowExtension > {
122- artifactId = " parsek-plugin-database"
123- component(this @create)
124- }
125- }
112+ tasks.named<Jar >(" jar" ) {
113+ // Keep jar enabled for Maven publishing
114+ enabled = true
115+ // Add custom naming: v before version and -api before .jar
116+ if (version != " unspecified" ) {
117+ archiveFileName.set(" ${rootProject.name} -v${version} -api.jar" )
118+ } else {
119+ archiveFileName.set(" ${rootProject.name} -api.jar" )
126120 }
127121}
128122
129123java {
130- withJavadocJar()
131- withSourcesJar()
132-
133124 // Use Java 21 for compilation
134125 toolchain {
135126 languageVersion.set(JavaLanguageVersion .of(21 ))
136127 }
128+
129+ withJavadocJar()
130+ withSourcesJar()
131+ }
132+
133+ // Configure sources and javadoc jars after they are created
134+ tasks.named<Jar >(" sourcesJar" ) {
135+ // Add custom naming: v before version and -api before .jar
136+ if (version != " unspecified" ) {
137+ archiveFileName.set(" ${rootProject.name} -v${version} -api-sources.jar" )
138+ } else {
139+ archiveFileName.set(" ${rootProject.name} -api-sources.jar" )
140+ }
141+ }
142+
143+ tasks.named<Jar >(" javadocJar" ) {
144+ // Add custom naming: v before version and -api before .jar
145+ if (version != " unspecified" ) {
146+ archiveFileName.set(" ${rootProject.name} -v${version} -api-javadoc.jar" )
147+ } else {
148+ archiveFileName.set(" ${rootProject.name} -api-javadoc.jar" )
149+ }
137150}
138151
139152kotlin {
@@ -149,4 +162,108 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
149162tasks.withType<JavaCompile > {
150163 sourceCompatibility = " 1.8"
151164 targetCompatibility = " 1.8"
165+ }
166+
167+ // Publishing configuration
168+ publishing {
169+ publications {
170+ create<MavenPublication >(" maven" ) {
171+ groupId = " dev.parsek"
172+ artifactId = " parsek-plugin-database"
173+ version = project.version.toString()
174+
175+ // Use the standard jar task output
176+ artifact(tasks.named(" jar" ))
177+ artifact(tasks.named(" sourcesJar" ))
178+ artifact(tasks.named(" javadocJar" ))
179+
180+ pom {
181+ name.set(" Parsek Database Plugin" )
182+ description.set(" Open-source modular backend in Kotlin" )
183+ url.set(" https://github.com/ParsekDev/parsek-plugin-database" )
184+ inceptionYear.set(" 2025" )
185+
186+ licenses {
187+ license {
188+ name.set(" MIT License" )
189+ url.set(" https://opensource.org/licenses/MIT" )
190+ }
191+ }
192+
193+ developers {
194+ developer {
195+ id.set(" Statu" )
196+ name.set(" Statu" )
197+ email.set(" info@statu.co" )
198+ }
199+ }
200+
201+ scm {
202+ connection.set(" scm:git:git://github.com/ParsekDev/parsek-plugin-database.git" )
203+ developerConnection.set(" scm:git:ssh://github.com/ParsekDev/parsek-plugin-database.git" )
204+ url.set(" https://github.com/ParsekDev/parsek-plugin-database" )
205+ }
206+ }
207+ }
208+ }
209+
210+ repositories {
211+ maven {
212+ url = layout.buildDirectory.dir(" staging-deploy" ).get().asFile.toURI()
213+ }
214+ }
215+ }
216+
217+ // Signing configuration
218+ signing {
219+ val signingKey = System .getenv(" GPG_PRIVATE_KEY" )
220+ val signingPassword = System .getenv(" GPG_PASSPHRASE" )
221+
222+ if (signingKey != null && signingPassword != null ) {
223+ useInMemoryPgpKeys(signingKey, signingPassword)
224+ sign(publishing.publications[" maven" ])
225+ }
226+ }
227+
228+ // JReleaser configuration
229+ jreleaser {
230+ project {
231+ name.set(" parsek-plugin-database" )
232+ description.set(" Open-source modular backend in Kotlin" )
233+ authors.add(" Statu" )
234+ license.set(" MIT" )
235+ links {
236+ homepage.set(" https://github.com/ParsekDev/parsek-plugin-database" )
237+ }
238+ inceptionYear.set(" 2025" )
239+ }
240+
241+ // Configure GitHub release provider (required by JReleaser even for deploy-only)
242+ release {
243+ github {
244+ overwrite.set(false )
245+ skipTag.set(true )
246+ skipRelease.set(true )
247+ changelog {
248+ enabled.set(false )
249+ }
250+ }
251+ }
252+
253+ signing {
254+ active.set(org.jreleaser.model.Active .ALWAYS )
255+ armored.set(true )
256+ }
257+
258+ deploy {
259+ maven {
260+ mavenCentral {
261+ create(" sonatype" ) {
262+ active.set(org.jreleaser.model.Active .ALWAYS )
263+ url.set(" https://central.sonatype.com/api/v1/publisher" )
264+ stagingRepository(" build/staging-deploy" )
265+ }
266+ }
267+ }
268+ }
152269}
0 commit comments