ci: multi-version build matrix + multi-MC compat layer

- Parametrize build: -PmcVersion / -PapiCoordinate / -PjavaRelease / -PapiVersion;
  jar name includes mc version, plugin.yml api-version parametrized
- Compat (reflection): sendBlockChanges / getClientViewDistance /
  getStructureManager (Paper 1.19.3+); particle()/potionEffect() name lookup
  for 1.21 renames (BLOCK_CRACK->BLOCK, REDSTONE->DUST, FIREWORKS_SPARK->
  FIREWORK, JUMP->JUMP_BOOST, SLOW->SLOWNESS); drop CHERRY materials (1.20+)
- Fix Java 17 'unconditional instanceof' in JoinCommandExecutor
- capabilitiesResolution for org.bukkit:bukkit capability conflict on newer
  paper-api artifacts
- .github/workflows/build.yml: matrix for 1.19.2/1.20.1 (Java 17),
  1.21/1.21.11 (Java 21), 26.1.2/26.2 (Java 25) + quality gate
- Verified locally: default + 1.19.2/1.20.1/1.21/1.21.11 build; 26.x deps resolve
This commit is contained in:
loki5512344 2026-08-05 22:48:26 +02:00
parent 3b5d3d97d5
commit c0ca488b9d
Signed by: boba
GPG key ID: 253067914055423B
13 changed files with 260 additions and 36 deletions

View file

@ -10,15 +10,16 @@ group = "dev.loki"
version = "1.3.3"
description = "LoParkour - Advanced parkour plugin for Minecraft"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
// Multi-version build: pass -PmcVersion / -PapiCoordinate / -PjavaRelease / -PapiVersion
// to build the same source against a different Paper API (e.g. GitHub Actions matrix).
val mcVersion: String = providers.gradleProperty("mcVersion").getOrElse("1.20.4")
val apiCoordinate: String = providers.gradleProperty("apiCoordinate")
.getOrElse("org.spigotmc:spigot-api:$mcVersion-R0.1-SNAPSHOT")
val javaRelease: Int = providers.gradleProperty("javaRelease").map { it.toInt() }.getOrElse(21)
val apiVersion: String = providers.gradleProperty("apiVersion").getOrElse("1.20")
repositories {
mavenCentral()
maven {
name = "papermc"
url = uri("https://repo.papermc.io/repository/maven-public/")
@ -76,9 +77,29 @@ repositories {
}
}
// Resolve the org.bukkit:bukkit capability conflict that newer paper-api artifacts
// introduce (they both bundle the bukkit classes and declare the capability).
configurations.configureEach {
resolutionStrategy.capabilitiesResolution.withCapability("org.bukkit:bukkit") {
selectHighestVersion()
}
}
dependencies {
// Spigot API
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
// Spigot/Paper API (overridable per MC version via -PapiCoordinate).
// Newer paper-api artifacts declare a conflicting org.bukkit:bukkit capability
// (they bundle the classes themselves) — drop the duplicate transitive.
if (apiCoordinate.startsWith("io.papermc.paper:paper-api")) {
val (apiGroup, apiName, apiVersion) = apiCoordinate.split(":")
compileOnly(mapOf(
"group" to apiGroup,
"name" to apiName,
"version" to apiVersion,
"exclude" to mapOf("group" to "org.bukkit", "module" to "bukkit")
))
} else {
compileOnly(apiCoordinate)
}
// Adventure API (for Component)
compileOnly("net.kyori:adventure-api:4.14.0")
@ -116,7 +137,7 @@ dependencies {
tasks.shadowJar {
archiveClassifier.set("")
archiveFileName.set("LoParkour-${project.version}.jar")
archiveFileName.set("LoParkour-${project.version}-mc${mcVersion}.jar")
// Relocate shaded dependencies
relocate("dev.lolib", "dev.loki.loparkour.lib.lolib")
@ -141,7 +162,8 @@ tasks.withType<ProcessResources> {
filesMatching(listOf("plugin.yml", "config.yml")) {
expand(
"version" to project.version,
"description" to project.description
"description" to project.description,
"apiVersion" to apiVersion
)
}
}
@ -152,7 +174,7 @@ tasks.withType<Test> {
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release = 21
options.release = javaRelease
}
tasks.withType<Javadoc> {