101 lines
4.3 KiB
Kotlin
101 lines
4.3 KiB
Kotlin
/* This is free and unencumbered software released into the public domain */
|
|
|
|
import java.io.BufferedReader
|
|
import org.gradle.kotlin.dsl.provideDelegate
|
|
|
|
/* ------------------------------ 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.
|
|
eclipse // Import Eclipse plugin.
|
|
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
|
|
}
|
|
|
|
extra["kotlinAttribute"] = Attribute.of("kotlin-tag", Boolean::class.javaObjectType)
|
|
|
|
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
|
|
|
/* --------------------------- 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 ------------------------------ */
|
|
val commitHash =
|
|
Runtime.getRuntime().exec(arrayOf("git", "rev-parse", "--short=10", "HEAD")).let { process ->
|
|
process.waitFor()
|
|
val output = process.inputStream.use { it.bufferedReader().use(BufferedReader::readText) }
|
|
process.destroy()
|
|
output.trim()
|
|
}
|
|
|
|
group = "net.trueog.quests-og" // Declare bundle identifier.
|
|
|
|
val apiVersion = "1.19" // Declare minecraft server target version.
|
|
|
|
version = "$apiVersion-$commitHash" // Declare plugin version (will be in .jar).
|
|
|
|
/* ---------------------------- 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.
|
|
}
|
|
|
|
/* ---------------------- Java project deps ---------------------------- */
|
|
dependencies {
|
|
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
|
|
compileOnly("net.luckperms:api:5.5") // Import LuckPerms API.
|
|
implementation("org.jetbrains.kotlin:kotlin-stdlib") // Import Kotlin standard library.
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2") // Import Kotlin async library.
|
|
implementation("io.lettuce:lettuce-core:6.7.1.RELEASE") // Import Lettuce API for keydb.
|
|
compileOnly("com.github.Realizedd.Duels:duels-api:3.5.1") // Import Duels API (API-compatible with Duels-OG).
|
|
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
|
|
compileOnlyApi(project(":libs:DiamondBank-OG")) {
|
|
attributes { attribute(kotlinAttribute, true) }
|
|
} // Import TrueOG network DiamondBank-OG Kotlin API (from source).
|
|
}
|
|
|
|
/* ---------------------- Reproducible jars ---------------------------- */
|
|
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
|
|
isPreserveFileTimestamps = false
|
|
isReproducibleFileOrder = true
|
|
}
|
|
|
|
/* ----------------------------- Shadow -------------------------------- */
|
|
tasks.shadowJar {
|
|
archiveClassifier.set("") // Use empty string instead of null.
|
|
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("-Xlint:deprecation") // Trigger deprecation warning messages.
|
|
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
|
}
|
|
|
|
/* ----------------------------- Auto Formatting ------------------------ */
|
|
spotless {
|
|
kotlin { ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } }
|
|
kotlinGradle {
|
|
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
|
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
|
}
|
|
}
|
|
|
|
tasks.named("spotlessCheck") {
|
|
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
|
}
|