Files
SiegeEngines/build.gradle.kts
T
2025-03-22 00:53:35 -04:00

129 lines
4.0 KiB
Kotlin

import java.time.Instant
plugins {
`java-library`
alias(libs.plugins.shadow) // Shades and relocates dependencies, see https://gradleup.com/shadow/
alias(libs.plugins.run.paper) // Built in test server using runServer and runMojangMappedServer tasks
alias(libs.plugins.plugin.yml) // Automatic plugin.yml generation
eclipse
idea
}
val mainPackage = "${project.group}.${project.name.lowercase()}"
applyCustomVersion()
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21)) // Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.
withJavadocJar()
withSourcesJar()
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://maven.athyrium.eu/releases")
}
dependencies {
// Core dependencies
compileOnly(libs.annotations)
annotationProcessor(libs.annotations)
compileOnly(libs.paper.api)
// API
implementation(libs.colorparser) {
exclude("org.intellij.lang.annotations")
exclude("org.jetbrains.lang.annotations")
exclude("net.kyori")
}
implementation(libs.commandapi.shade)
}
tasks {
build {
dependsOn(shadowJar)
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(21)
options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose"))
}
javadoc {
isFailOnError = false
val options = options as StandardJavadocDocletOptions
options.encoding = Charsets.UTF_8.name()
options.overview = "src/main/javadoc/overview.html"
options.windowTitle = "${rootProject.name} Javadoc"
options.tags("apiNote:a:API Note:", "implNote:a:Implementation Note:", "implSpec:a:Implementation Requirements:")
options.addStringOption("Xdoclint:none", "-quiet")
options.use()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
shadowJar {
archiveBaseName.set(project.name)
archiveClassifier.set("")
// Shadow classes
fun reloc(originPkg: String, targetPkg: String) = relocate(originPkg, "${mainPackage}.lib.${targetPkg}")
reloc("com.github.milkdrinkers.colorparser", "colorparser")
reloc("dev.jorel.commandapi", "commandapi")
minimize()
exclude("META-INF/**")
}
test {
useJUnitPlatform()
failFast = false
}
runServer {
// Configure the Minecraft version for our task.
minecraftVersion("1.21.4")
// IntelliJ IDEA debugger setup: https://docs.papermc.io/paper/dev/debugging#using-a-remote-debugger
jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true", "-DIReallyKnowWhatIAmDoingISwear", "-Dpaper.playerconnection.keepalive=6000")
systemProperty("terminal.jline", false)
systemProperty("terminal.ansi", true)
// Automatically install dependencies
downloadPlugins {}
}
}
bukkit { // Options: https://github.com/Minecrell/plugin-yml#bukkit
// Plugin main class (required)
main = "${mainPackage}.${project.name}"
// Plugin Information
name = project.name
prefix = project.name
version = "${project.version}"
description = "${project.description}"
authors = listOf("ShermansWorld", "C_Corp2002")
contributors = listOf("darksaid98")
apiVersion = "1.21"
// Misc properties
load = net.minecrell.pluginyml.bukkit.BukkitPluginDescription.PluginLoadOrder.POSTWORLD // STARTUP or POSTWORLD
depend = listOf()
softDepend = listOf()
}
fun applyCustomVersion() {
// Apply custom version arg or append snapshot version
val ver = properties["altVer"]?.toString() ?: "${rootProject.version}-SNAPSHOT-${Instant.now().epochSecond}"
// Strip prefixed "v" from version tag
rootProject.version = (if (ver.first().equals('v', true)) ver.substring(1) else ver.uppercase()).uppercase()
}