-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
169 lines (151 loc) · 5.88 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
169 lines (151 loc) · 5.88 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
plugins {
java
`maven-publish`
alias(libs.plugins.shadow)
}
group = "me.playbosswar.tea"
version = (project.findProperty("teacoreVersion") as String?) ?: "0.1.0-SNAPSHOT"
// Spigot API version driving compileOnly / testImplementation. Defaults to the
// lowest supported release (the first Minecraft version that requires Java 21)
// so Maven-published artifacts have the widest server compatibility. CI
// overrides this in a matrix to also verify the build against the latest
// release.
val spigotApiVersion = (project.findProperty("spigotApiVersion") as String?) ?: "1.20.5-R0.1-SNAPSHOT"
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://maven.enginehub.org/repo/")
maven("https://repo.faststats.dev/releases")
maven("https://repo.extendedclip.com/releases/")
// VaultAPI is published via JitPack (hard runtime dep; shipped by the
// server admin, not shaded into our jar).
maven("https://jitpack.io")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
withSourcesJar()
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release.set(21)
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
tasks.withType<ProcessResources>().configureEach {
filesMatching("plugin.yml") {
expand("version" to project.version)
}
}
dependencies {
compileOnly("org.spigotmc:spigot-api:$spigotApiVersion")
compileOnly(libs.worldedit.bukkit) { isTransitive = false }
compileOnly(libs.worldedit.core) { isTransitive = false }
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") { isTransitive = false }
compileOnly("me.clip:placeholderapi:2.11.6")
implementation(libs.adventure.api)
implementation(libs.adventure.minimessage)
implementation(libs.adventure.platform.bukkit)
implementation(libs.hikari)
implementation(libs.lettuce)
implementation(libs.caffeine)
implementation(libs.javalin)
implementation(libs.jackson.databind)
implementation(libs.sqlite.jdbc)
implementation(libs.mysql.connector)
// FastStats — error tracking + custom metrics, shaded with relocation so
// it can't collide with another plugin's copy.
implementation("dev.faststats.metrics:bukkit:0.22.0")
testImplementation("org.spigotmc:spigot-api:$spigotApiVersion")
testImplementation(libs.junit.jupiter)
testImplementation(libs.archunit.junit5)
testImplementation(libs.assertj)
}
// Build the React dashboard SPA and bundle the output onto the plugin classpath
// under /dashboard/. Javalin serves it at runtime.
val dashboardDir = layout.projectDirectory.dir("dashboard")
val dashboardDist = dashboardDir.dir("dist")
val dashboardBuild = tasks.register<Exec>("dashboardBuild") {
group = "build"
description = "Runs the dashboard SPA npm build."
workingDir = dashboardDir.asFile
commandLine("sh", "-c", "npm ci && npm run build")
inputs.file(dashboardDir.file("package.json"))
inputs.file(dashboardDir.file("package-lock.json"))
inputs.dir(dashboardDir.dir("src"))
inputs.file(dashboardDir.file("index.html"))
inputs.file(dashboardDir.file("vite.config.ts"))
inputs.file(dashboardDir.file("tsconfig.json"))
outputs.dir(dashboardDist)
}
tasks.named<Copy>("processResources") {
dependsOn(dashboardBuild)
from(dashboardDist) {
into("dashboard")
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.shadowJar {
archiveClassifier.set("all")
mergeServiceFiles()
val base = "me.playbosswar.tea.core.libs"
relocate("net.kyori", "$base.kyori")
relocate("com.zaxxer.hikari", "$base.hikari")
relocate("io.lettuce", "$base.lettuce")
relocate("io.netty", "$base.netty")
relocate("reactor", "$base.reactor")
relocate("org.reactivestreams", "$base.reactivestreams")
relocate("com.github.benmanes.caffeine", "$base.caffeine")
relocate("io.javalin", "$base.javalin")
relocate("org.eclipse.jetty", "$base.jetty")
relocate("com.fasterxml.jackson", "$base.jackson")
relocate("org.jetbrains.annotations", "$base.annotations")
relocate("kotlin", "$base.kotlin")
relocate("dev.faststats", "$base.faststats")
// org.sqlite.* is intentionally NOT relocated: the native .so binds JNI
// symbols to the original package name and relocating breaks at connect.
}
tasks.build {
dependsOn(tasks.shadowJar)
}
tasks.register<Javadoc>("apiJavadoc") {
description = "Generates Javadoc for the public TeaCore API (api/** packages)."
group = "documentation"
source = sourceSets.main.get().java
include("me/playbosswar/tea/core/api/**/*.java")
classpath = sourceSets.main.get().compileClasspath
setDestinationDir(layout.buildDirectory.dir("docs/api-javadoc").get().asFile)
(options as StandardJavadocDocletOptions).apply {
addStringOption("Xdoclint:none", "-quiet")
windowTitle = "TeaCore API"
docTitle = "TeaCore API"
}
}
// Publishing. Downstream plugins (tealobby, ascend) compile against the plain
// jar; the shadow jar is the runtime artifact you drop into plugins/.
publishing {
publications {
create<MavenPublication>("teacore") {
artifactId = "teacore"
from(components["java"])
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri(
(project.findProperty("teacoreRepoUrl") as String?)
?: "https://maven.pkg.github.com/titivermeesch/teacore"
)
credentials {
username = System.getenv("GITHUB_ACTOR")
?: (project.findProperty("gpr.user") as String?)
password = System.getenv("GITHUB_TOKEN")
?: (project.findProperty("gpr.key") as String?)
}
}
}
}