-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
271 lines (229 loc) · 9.41 KB
/
build.gradle.kts
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import org.jooq.meta.jaxb.Logging
import java.time.Instant
plugins {
`java-library`
alias(libs.plugins.shadow) // Shades and relocates dependencies, see https://gradleup.com/shadow/
alias(libs.plugins.run.paper) // Built in test server using runServer and runMojangMappedServer tasks
alias(libs.plugins.plugin.yml) // Automatic plugin.yml generation
//alias(libs.plugins.paperweight) // Used to develop internal plugins using Mojang mappings, See https://github.com/PaperMC/paperweight
alias(libs.plugins.flyway) // Database migrations
alias(libs.plugins.jooq) // Database ORM
eclipse
idea
}
val mainPackage = "${project.group}.${project.name.lowercase()}"
applyCustomVersion()
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21)) // Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.
withJavadocJar() // Enable javadoc jar generation
withSourcesJar() // Enable sources jar generation
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://mvn-repo.arim.space/lesser-gpl3/")
maven("https://maven.athyrium.eu/releases")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // PlaceholderAPI
maven("https://repo.codemc.org/repository/maven-public/") {
content {
includeGroup("com.github.retrooper") // PacketEvents
}
}
maven("https://jitpack.io/") {
content {
includeGroup("com.github.MilkBowl") // VaultAPI
}
}
}
dependencies {
// Core dependencies
compileOnly(libs.annotations)
annotationProcessor(libs.annotations)
//paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT") // Use instead of the `paper-api` entry if developing plugins using Mojang mappings
compileOnly(libs.paper.api)
implementation(libs.morepaperlib)
// API
implementation(libs.version.watch)
implementation(libs.crate.api)
implementation(libs.crate.yaml)
implementation(libs.colorparser) {
exclude("net.kyori")
}
implementation(libs.commandapi.shade)
//annotationProcessor(libs.commandapi.annotations) // Uncomment if you want to use command annotations
implementation(libs.triumph.gui) {
exclude("net.kyori")
}
// Plugin dependencies
implementation(libs.bstats)
compileOnly(libs.vault)
compileOnly(libs.packetevents)
compileOnly(libs.placeholderapi) {
exclude("me.clip.placeholderapi.libs", "kyori")
}
// Database dependencies - Core
implementation(libs.hikaricp)
library(libs.bundles.flyway)
library(libs.jooq)
jooqCodegen(libs.h2)
// Database dependencies - JDBC drivers
library(libs.bundles.jdbcdrivers)
// Testing - Core
testImplementation(libs.annotations)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.bundles.junit)
testRuntimeOnly(libs.slf4j)
testImplementation(platform(libs.testcontainers.bom))
testImplementation(libs.bundles.testcontainers)
// Testing - Database dependencies
testImplementation(libs.hikaricp)
testImplementation(libs.bundles.flyway)
testImplementation(libs.jooq)
// Testing - JDBC drivers
testImplementation(libs.bundles.jdbcdrivers)
}
tasks {
// NOTE: Use when developing plugins using Mojang mappings
// assemble {
// dependsOn(reobfJar)
// }
build {
dependsOn(shadowJar)
}
jooqCodegen {
dependsOn(flywayMigrate)
}
compileJava {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
// See https://openjdk.java.net/jeps/247 for more information.
options.release.set(21)
options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose"))
dependsOn(jooqCodegen) // Generate jOOQ sources before compilation
}
javadoc {
isFailOnError = false
exclude("**/database/schema/**") // Exclude generated jOOQ sources from javadocs
val options = options as StandardJavadocDocletOptions
options.encoding = Charsets.UTF_8.name()
options.overview = "src/main/javadoc/overview.html"
options.windowTitle = "${rootProject.name} Javadoc"
options.tags("apiNote:a:API Note:", "implNote:a:Implementation Note:", "implSpec:a:Implementation Requirements:")
options.addStringOption("Xdoclint:none", "-quiet")
options.use()
}
processResources {
filteringCharset = Charsets.UTF_8.name() // We want UTF-8 for everything
}
shadowJar {
archiveBaseName.set(project.name)
archiveClassifier.set("")
// Shadow classes
fun reloc(originPkg: String, targetPkg: String) = relocate(originPkg, "${mainPackage}.lib.${targetPkg}")
reloc("space.arim.morepaperlib", "morepaperlib")
reloc("io.github.milkdrinkers.crate", "crate")
reloc("io.github.milkdrinkers.colorparser", "colorparser")
reloc("io.github.milkdrinkers.versionwatch", "versionwatch")
reloc("dev.jorel.commandapi", "commandapi")
reloc("dev.triumphteam.gui", "gui")
reloc("com.zaxxer.hikari", "hikaricp")
reloc("org.bstats", "bstats")
mergeServiceFiles {
setPath("META-INF/services/org.flywaydb.core.extensibility.Plugin") // Fix Flyway overriding its own files
}
minimize()
}
test {
useJUnitPlatform()
failFast = false
}
runServer {
// Configure the Minecraft version for our task.
minecraftVersion("1.21")
// IntelliJ IDEA debugger setup: https://docs.papermc.io/paper/dev/debugging#using-a-remote-debugger
jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true", "-DIReallyKnowWhatIAmDoingISwear", "-Dpaper.playerconnection.keepalive=6000")
systemProperty("terminal.jline", false)
systemProperty("terminal.ansi", true)
// Automatically install dependencies
downloadPlugins {
// modrinth("carbon", "2.1.0-beta.21")
// github("jpenilla", "MiniMOTD", "v2.0.13", "minimotd-bukkit-2.0.13.jar")
// hangar("squaremap", "1.2.0")
// url("https://download.luckperms.net/1515/bukkit/loader/LuckPerms-Bukkit-5.4.102.jar")
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
github("retrooper", "packetevents", "v2.7.0", "packetevents-spigot-2.7.0.jar")
hangar("PlaceholderAPI", "2.11.6")
hangar("ViaVersion", "5.2.1")
hangar("ViaBackwards", "5.2.1")
}
}
}
tasks.named<Jar>("sourcesJar") { // Required for sources jar generation with jOOQ
dependsOn(tasks.jooqCodegen)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
bukkit { // Options: https://github.com/Minecrell/plugin-yml#bukkit
// Plugin main class (required)
main = "${mainPackage}.${project.name}"
// Plugin Information
name = project.name
prefix = project.name
version = "${project.version}"
description = "${project.description}"
authors = listOf("GITHUB_USERNAME")
contributors = listOf()
apiVersion = "1.21"
foliaSupported = true // Mark plugin as supporting Folia
// Misc properties
load = net.minecrell.pluginyml.bukkit.BukkitPluginDescription.PluginLoadOrder.POSTWORLD // STARTUP or POSTWORLD
depend = listOf()
softDepend = listOf("PacketEvents", "Vault", "PlaceholderAPI")
loadBefore = listOf()
provides = listOf()
}
flyway {
url = "jdbc:h2:${project.layout.buildDirectory.get()}/generated/flyway/db;AUTO_SERVER=TRUE;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE;IGNORECASE=TRUE"
user = "sa"
password = ""
schemas = listOf("PUBLIC").toTypedArray()
placeholders = mapOf( // Substitute placeholders for flyway
"tablePrefix" to "",
)
validateMigrationNaming = true
baselineOnMigrate = true
cleanDisabled = false
locations = arrayOf(
"filesystem:src/main/resources/db/migration",
"classpath:${mainPackage.replace(".", "/")}/database/migration/migrations"
)
}
jooq {
configuration {
logging = Logging.ERROR
jdbc {
driver = "org.h2.Driver"
url = flyway.url
user = flyway.user
password = flyway.password
}
generator {
database {
name = "org.jooq.meta.h2.H2Database"
includes = ".*"
excludes = "(flyway_schema_history)|(?i:information_schema\\..*)|(?i:system_lobs\\..*)" // Exclude database specific files
inputSchema = "PUBLIC"
schemaVersionProvider = "SELECT :schema_name || '_' || MAX(\"version\") FROM \"flyway_schema_history\"" // Grab version from Flyway
}
target {
packageName = "${mainPackage}.database.schema"
withClean(true)
}
}
}
}
fun applyCustomVersion() {
// Apply custom version arg or append snapshot version
val ver = properties["altVer"]?.toString() ?: "${rootProject.version}-SNAPSHOT-${Instant.now().epochSecond}"
// Strip prefixed "v" from version tag
rootProject.version = (if (ver.first().equals('v', true)) ver.substring(1) else ver.uppercase()).uppercase()
}