164 lines
No EOL
4.2 KiB
Kotlin
164 lines
No EOL
4.2 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/")
|
|
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("legacyCompileOnly", files("libs/tenkumaLib/libs/craftbukkit-1060.jar"))
|
|
|
|
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")
|
|
|
|
// Allow tests to see the versioned implementations
|
|
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 bundleAll = tasks.named<Jar>("bundleAll")
|
|
val tLibBundleAll = project(":tenkumaLib").tasks.named<Jar>("bundleAll")
|
|
|
|
dependsOn(bundleAll)
|
|
dependsOn(tLibBundleAll)
|
|
|
|
pluginJars(
|
|
bundleAll.flatMap { it.archiveFile },
|
|
tLibBundleAll.flatMap { it.archiveFile }
|
|
)
|
|
} |