Files
MobArena/build.gradle.kts
Michael Burgess d1eb4191e9
build / build (push) Successful in 2m7s
build / draft (push) Skipped
Add Maven publishing for MobArenaStats' local build dependency
2026-08-06 22:40:43 -04:00

109 lines
3.1 KiB
Kotlin

plugins {
id("java-library")
id("com.gradleup.shadow") version "9.6.1"
id("maven-publish")
}
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) }
}
publishing {
publications {
create<MavenPublication>("shadow") {
groupId = "com.garbagemule"
artifactId = "MobArena"
version = project.version.toString()
artifact(tasks.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)
}