TimeKeeper/build.gradle.kts

184 lines
No EOL
5 KiB
Kotlin

plugins {
java
id("xyz.jpenilla.run-paper") version "3.0.1"
}
group = "org.adrianvictor"
version = System.getenv("TKEEPER_VERSION_NAME") ?: "unknown"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repository.johnymuffin.com/repository/maven-releases/")
flatDir {
dirs("libs")
}
}
/* ----------------------------------------- */
/* SUPPORTED VERSIONS */
/* ----------------------------------------- */
val mcVersions = listOf(
"modern",
"legacy"
)
/* ----------------------------------------- */
/* CREATE SOURCE SET PER VERSION */
/* ----------------------------------------- */
tasks.withType<ProcessResources> {
inputs.property("version", project.version)
filesMatching("plugin.yml") {
expand("version" to project.version)
}
}
mcVersions.forEach { ver ->
val ss = sourceSets.create(ver) {
java.srcDir("src/$ver/java")
resources.setSrcDirs(listOf("src/$ver/resources", "src/main/resources"))
compileClasspath += sourceSets["main"].output
runtimeClasspath += output + compileClasspath
}
tasks.withType<ProcessResources> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
configurations[ss.implementationConfigurationName]
.extendsFrom(configurations["implementation"])
if (ver != "legacy") {
configurations[ss.compileOnlyConfigurationName]
.extendsFrom(configurations["compileOnly"])
}
}
/* ----------------------------------------- */
/* DEPENDENCIES */
/* ----------------------------------------- */
dependencies {
add("compileOnly", "io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
add("modernCompileOnly", "io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
add("legacyImplementation", "com.legacyminecraft.poseidon:poseidon-craftbukkit:1.1.12-260503-0121-a9af58a")
compileOnly(project(":tenkumaLib"))
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testImplementation("org.mockito:mockito-core:5.5.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.102.0")
mcVersions.forEach { ver ->
testImplementation(sourceSets[ver].output)
}
}
tasks.test {
useJUnitPlatform()
}
/* ----------------------------------------- */
/* BUILD TASKS */
/* ----------------------------------------- */
mcVersions.forEach { ver ->
tasks.register<Jar>("jar${ver.replace(".", "_").replace("-", "_").replace("/", "_").capitalize()}") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(sourceSets["main"].output)
from(sourceSets[ver].output)
archiveClassifier.set(ver)
manifest {
attributes(
"TKeeper-Impl-Version" to ver,
"TKeeper-Environment" to (System.getenv("TKEEPER_BUILD_CHANNEL") ?: "dev")
)
}
}
}
tasks.register("buildAll") {
dependsOn(tasks.withType<Jar>())
}
//tasks.register<Jar>("bundleAll") {
// dependsOn(configurations.runtimeClasspath)
//
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
//
// from(sourceSets["main"].output)
//
// mcVersions.forEach { ver ->
// from(sourceSets[ver].output)
// }
//
// from({
// configurations.runtimeClasspath.get()
// .filter { it.name.endsWith("jar") }
// .map { zipTree(it) }
// })
//
// archiveClassifier.set("all-implementations")
// archiveVersion.set(project.version.toString())
//}
/* ----------------------------------------- */
/* JAVA SETTINGS */
/* ----------------------------------------- */
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
tasks.jar {
enabled = false
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.runServer {
minecraftVersion("1.21")
val modern = tasks.named<Jar>("jarModern")
val tLibBundleAll = project(":tenkumaLib").tasks.named<Jar>("bundleAll")
dependsOn(modern)
dependsOn(tLibBundleAll)
pluginJars(
modern.flatMap { it.archiveFile },
tLibBundleAll.flatMap { it.archiveFile }
)
}
tasks.register<Copy>("copyLegacyPlugin") {
from(project(":tenkumaLib").tasks.named<Jar>("bundleAll"))
from(tasks.named<Jar>("jarLegacy"))
into("runBeta/plugins")
}
tasks.register<JavaExec>("runBetaServer") {
group = "verification"
description = "Runs the beta server with legacy TimeKeeper."
dependsOn("copyLegacyPlugin")
jvmArgs = listOf("-Djline.terminal=jline.UnsupportedTerminal", "-Dfile.encoding=UTF-8", "-Djava.awt.headless=true")
classpath = files("runBeta/poseidon-craftbukkit.jar")
mainClass.set("org.bukkit.craftbukkit.Main")
workingDir = file("runBeta")
standardInput = file("/dev/null").inputStream()
}