Files
ChatItem/build.gradle.kts
T
2025-08-27 17:19:37 -04:00

151 lines
6.8 KiB
Kotlin

/* ------------------------------ Plugins ------------------------------ */
plugins {
id("java") // Import Java plugin.
id("java-library") // Import Java Library plugin.
id("com.diffplug.spotless") version "7.0.4" // Import Spotless plugin.
id("com.gradleup.shadow") version "8.3.6" // Import Shadow plugin.
id("checkstyle") // Import Checkstyle plugin.
eclipse // Import Eclipse plugin.
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
}
/* --------------------------- JDK / Kotlin ---------------------------- */
java {
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
toolchain { // Select Java toolchain.
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
}
}
kotlin { jvmToolchain(17) }
/* ----------------------------- Metadata ------------------------------ */
group = "me.dadus33" // Declare bundle identifier.
version = "2.6.3" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
/* ----------------------------- Resources ----------------------------- */
tasks.named<ProcessResources>("processResources") {
val props = mapOf("version" to version, "apiVersion" to apiVersion)
inputs.properties(props) // Indicates to rerun if version changes.
filesMatching("plugin.yml") { expand(props) }
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
}
/* ---------------------------- Repos ---------------------------------- */
repositories {
mavenCentral() // Import the Maven Central Maven Repository.
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
maven { url = uri("https://repo.md-5.net/content/groups/public/") }
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://raw.github.com/MascusJeoraly/LanguageUtils/mvn-repo/") }
maven { url = uri("https://repo.dmulloy2.net/nexus/repository/public/") }
maven { url = uri("https://repo.viaversion.com") }
maven { url = uri("https://repo.eliapp.fr:8081/repository/internal/") }
maven { url = uri("https://m2.dv8tion.net/releases") }
maven { url = uri("https://nexus.scarsz.me/content/groups/public/") }
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
maven { url = uri("https://repo.essentialsx.net/snapshots/") }
System.getProperty("SELF_MAVEN_LOCAL_REPO")?.let { // TrueOG Bootstrap mavenLocal().
val dir = file(it)
if (dir.isDirectory) {
println("Using SELF_MAVEN_LOCAL_REPO at: $it")
maven { url = uri("file://${dir.absolutePath}") }
} else {
mavenLocal()
}
}
}
/* ---------------------- Java project deps ---------------------------- */
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
implementation("com.google.code.gson:gson:2.9.0")
implementation("com.github.GeyserMC:opennbt:1.5")
implementation("commons-lang:commons-lang:2.6")
compileOnly(files("libs/ProtocolLib-5.0.jar")) // Import Legacy ProtocolLib API.
compileOnly("com.meowj:LangUtils:1.9")
compileOnly("com.viaversion:viaversion-api:5.0.3")
compileOnly("io.shevchik:ProtocolSupport:1.18.2-1-dev")
compileOnly("io.netty:netty-all:4.1.58.Final")
compileOnly("dev.majek:HexNicks:3.1.1")
compileOnly("net.kyori:adventure-api:4.17.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.3.4")
compileOnly("com.discordsrv:discordsrv:1.28.1")
compileOnly("com.willfp:EcoEnchants:8.57.2")
compileOnly("com.github.Auxilor:EcoEnchants:12.5.1")
compileOnly("com.ryderbelserion:ChatManager:3.7.7")
compileOnly("com.willfp:eco:6.66.1")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("be.maximvdw:MVdWPlaceholderAPI:3.1.1-SNAPSHOT")
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
compileOnly("net.essentialsx:EssentialsX:2.21.0-SNAPSHOT")
}
/* ---------------------- Reproducible jars ---------------------------- */
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
/* ----------------------------- Shadow -------------------------------- */
tasks.shadowJar {
archiveClassifier.set("") // Use empty string instead of null.
exclude("io/github/miniplaceholders/**")
relocate("com.google.gson", "me.dadus33.libs.gson")
relocate("com.github.steveice10.opennbt", "me.dadus33.libs.opennbt")
relocate("org.apache.commons.lang", "me.dadus33.libs.commonslang2")
exclude("net/kyori/examination/**")
exclude("net/kyori/adventure/platform/**")
exclude("net/kyori/adventure/text/serializer/legacy/**")
exclude("net/kyori/adventure/text/serializer/gson/**")
exclude("net/kyori/adventure/nbt/**")
minimize()
}
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
/* --------------------------- Javac opts ------------------------------- */
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters") // Enable reflection for java code.
options.isFork = true // Run javac in its own process.
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
options.encoding = "UTF-8" // Use UTF-8 file encoding.
}
/* ----------------------------- Auto Formatting ------------------------ */
spotless {
java {
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
removeUnusedImports() // Remove imports that aren't being called.
}
kotlinGradle {
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
}
}
checkstyle {
toolVersion = "10.18.1" // Declare checkstyle version to use.
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
}
tasks.named("compileJava") {
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
}
tasks.named("spotlessCheck") {
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
}