This repository was archived by the owner on Nov 28, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
122 lines (105 loc) · 3.13 KB
/
build.gradle.kts
File metadata and controls
122 lines (105 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
plugins {
`maven-publish`
kotlin("jvm") version "2.1.0"
}
group = "io.github.dockyard.tide"
version = properties["tide.version"]!!
repositories {
mavenCentral()
maven("https://mvn.devos.one/releases")
maven("https://mvn.devos.one/snapshots")
maven("https://jitpack.io")
}
dependencies {
testImplementation(kotlin("test"))
implementation("cz.lukynka:pretty-log:1.5")
api("io.ktor:ktor-server-netty:3.1.2")
api("com.google.code.gson:gson:2.13.0")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
}
tasks.withType<PublishToMavenRepository> {
if(!version.toString().endsWith("-SNAPSHOT")) {
dependsOn("test")
}
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
repositories {
maven {
url = if(version.toString().endsWith("-SNAPSHOT")) {
uri("https://mvn.devos.one/snapshots")
} else {
uri("https://mvn.devos.one/releases")
}
credentials {
username = System.getenv()["MAVEN_USER"]
password = System.getenv()["MAVEN_PASS"]
}
}
}
publications {
register<MavenPublication>("maven") {
groupId = "io.github.dockyardmc"
artifactId = "tide"
version = version.toString()
from(components["java"])
}
}
}
tasks.publish {
finalizedBy("sendPublishWebhook")
}
task("sendPublishWebhook") {
group = "publishing"
description = "Sends a webhook message after publishing to Maven."
doLast {
sendWebhookToDiscord(System.getenv("DISCORD_DOCKYARD_WEBHOOK"))
}
}
fun sendWebhookToDiscord(webhookUrl: String) {
val httpClient = HttpClient.newHttpClient()
val requestBody = embed()
val request = HttpRequest.newBuilder()
.uri(URI(webhookUrl))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build()
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenRun { println("Webhook sent successfully!") }
.exceptionally { throwable ->
throwable.printStackTrace()
null
}
}
fun embed(): String {
val target = if(version.toString().endsWith("-SNAPSHOT")) "https://mvn.devos.one/snapshots" else "https://mvn.devos.one/releases"
val color = if(version.toString().endsWith("-SNAPSHOT")) 16742912 else 65290
val title = if(version.toString().endsWith("-SNAPSHOT")) "Snapshot Published to Maven" else "Published to Maven"
return """
{
"content": null,
"embeds": [
{
"title": "$title",
"description": "`io.github.dockyardmc:tide:$version` was successfully published to maven **$target**!",
"color": $color
}
],
"username": "Mavenboo",
"avatar_url": "https://img.lukynka.cloud/live_bangboo_reaction.webp",
"attachments": []
}
""".trimIndent()
}