97 lines
2.9 KiB
Kotlin
97 lines
2.9 KiB
Kotlin
plugins {
|
|
id("java-library")
|
|
id("com.gradleup.shadow") version "9.6.1"
|
|
}
|
|
|
|
group = "com.garbagemule"
|
|
version = "0.109.1-tss3"
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
maven("https://repo.papermc.io/repository/maven-public/")
|
|
maven("https://jitpack.io")
|
|
maven("https://repo.maven.apache.org/maven2/")
|
|
}
|
|
|
|
dependencies {
|
|
compileOnly("io.papermc.paper:paper-api:26.2.build.84-stable")
|
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
|
|
api("org.bstats:bstats-bukkit:2.2.1")
|
|
|
|
testImplementation("junit:junit:4.13.2")
|
|
testImplementation("org.hamcrest:hamcrest-all:1.3")
|
|
testImplementation("org.mockito:mockito-core:5.23.0")
|
|
testImplementation("org.mockbukkit.mockbukkit:mockbukkit-v26.1.2:4.113.2")
|
|
}
|
|
|
|
// Tests use MockBukkit's exact Paper API build because 26.2 registries are not modeled yet.
|
|
configurations.matching { it.name.startsWith("test") }.configureEach {
|
|
resolutionStrategy.force("io.papermc.paper:paper-api:26.1.2.build.57-stable")
|
|
}
|
|
java {
|
|
toolchain {
|
|
languageVersion.set(JavaLanguageVersion.of(25))
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
test {
|
|
// This is a bit of a hack. It ensures that the dependencies for the
|
|
// "main" source set are available to the test suite. Without it, the
|
|
// dependencies would have to be listed twice, and even that doesn't
|
|
// seem to work with the currently used version of Mockito.
|
|
configurations.testImplementation.configure {
|
|
extendsFrom(configurations.compileOnly.get())
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks {
|
|
processResources {
|
|
filesMatching("plugin.yml") {
|
|
expand("project" to mapOf(
|
|
"name" to "MobArena",
|
|
"version" to version,
|
|
))
|
|
}
|
|
}
|
|
|
|
shadowJar {
|
|
minimize()
|
|
|
|
relocate("org.bstats", "com.garbagemule.MobArena.metrics")
|
|
|
|
archiveBaseName = "MobArena"
|
|
archiveClassifier = ""
|
|
}
|
|
|
|
// We're using shadowJar, so we can skip the regular jar task.
|
|
jar { enabled = false }
|
|
|
|
// Let the build task produce the final artifact.
|
|
build { dependsOn(shadowJar) }
|
|
}
|
|
val checkNoLegacyMaterialApi = tasks.register("checkNoLegacyMaterialApi") {
|
|
group = "verification"
|
|
description = "Fails if legacy Bukkit material access returns to production sources."
|
|
val sources = fileTree("src/main/java") { include("**/*.java") }
|
|
inputs.files(sources)
|
|
|
|
doLast {
|
|
val violations = sources.files.flatMap { file ->
|
|
file.readLines().mapIndexedNotNull { index, line ->
|
|
if ("org.bukkit.material" in line || "state.getData()" in line) {
|
|
"${file.relativeTo(projectDir)}:${index + 1}"
|
|
} else null
|
|
}
|
|
}
|
|
check(violations.isEmpty()) {
|
|
"Legacy Bukkit material API usage found:\n${violations.joinToString("\n")}"
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.named("check") {
|
|
dependsOn(checkNoLegacyMaterialApi)
|
|
}
|