mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
132 lines
4.6 KiB
Text
132 lines
4.6 KiB
Text
|
import io.papermc.paperweight.util.*
|
||
|
|
||
|
plugins {
|
||
|
java
|
||
|
`maven-publish`
|
||
|
}
|
||
|
|
||
|
dependencies {
|
||
|
implementation(project(":paper-api"))
|
||
|
implementation("jline:jline:2.12.1")
|
||
|
implementation("org.apache.logging.log4j:log4j-iostreams:2.24.1") {
|
||
|
exclude(group = "org.apache.logging.log4j", module = "log4j-api")
|
||
|
}
|
||
|
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||
|
implementation("commons-lang:commons-lang:2.6")
|
||
|
runtimeOnly("org.xerial:sqlite-jdbc:3.47.0.0")
|
||
|
runtimeOnly("com.mysql:mysql-connector-j:9.1.0")
|
||
|
|
||
|
runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
||
|
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
||
|
runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||
|
|
||
|
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||
|
testImplementation("org.junit.platform:junit-platform-suite-engine:1.10.0")
|
||
|
testImplementation("org.hamcrest:hamcrest:2.2")
|
||
|
testImplementation("org.mockito:mockito-core:5.14.1")
|
||
|
testImplementation("org.ow2.asm:asm-tree:9.7.1")
|
||
|
}
|
||
|
|
||
|
paperweight {
|
||
|
craftBukkitPackageVersion.set("v1_21_R3") // also needs to be updated in MappingEnvironment
|
||
|
}
|
||
|
|
||
|
tasks.jar {
|
||
|
archiveClassifier.set("dev")
|
||
|
|
||
|
manifest {
|
||
|
val git = Git(rootProject.layout.projectDirectory.path)
|
||
|
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
||
|
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
||
|
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
||
|
attributes(
|
||
|
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||
|
"Implementation-Title" to "CraftBukkit",
|
||
|
"Implementation-Version" to "git-Paper-$implementationVersion",
|
||
|
"Implementation-Vendor" to date, // Paper
|
||
|
"Specification-Title" to "Bukkit",
|
||
|
"Specification-Version" to project.version,
|
||
|
"Specification-Vendor" to "Bukkit Team",
|
||
|
)
|
||
|
for (tld in setOf("net", "com", "org")) {
|
||
|
attributes("$tld/bukkit", "Sealed" to true)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
publishing {
|
||
|
publications.create<MavenPublication>("maven") {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
tasks.test {
|
||
|
include("**/**TestSuite.class")
|
||
|
workingDir = temporaryDir
|
||
|
useJUnitPlatform {
|
||
|
forkEvery = 1
|
||
|
excludeTags("Slow")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fun TaskContainer.registerRunTask(
|
||
|
name: String,
|
||
|
block: JavaExec.() -> Unit
|
||
|
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
||
|
group = "paper"
|
||
|
mainClass.set("org.bukkit.craftbukkit.Main")
|
||
|
standardInput = System.`in`
|
||
|
workingDir = rootProject.layout.projectDirectory
|
||
|
.dir(providers.gradleProperty("paper.runWorkDir").getOrElse("run"))
|
||
|
.asFile
|
||
|
javaLauncher.set(project.javaToolchains.launcherFor {
|
||
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||
|
vendor.set(JvmVendorSpec.JETBRAINS)
|
||
|
})
|
||
|
jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:+AllowRedefinitionToAddDeleteMethods")
|
||
|
|
||
|
if (rootProject.childProjects["test-plugin"] != null) {
|
||
|
val testPluginJar = rootProject.project(":test-plugin").tasks.jar.flatMap { it.archiveFile }
|
||
|
inputs.file(testPluginJar)
|
||
|
args("-add-plugin=${testPluginJar.get().asFile.absolutePath}")
|
||
|
}
|
||
|
|
||
|
args("--nogui")
|
||
|
systemProperty("net.kyori.adventure.text.warnWhenLegacyFormattingDetected", true)
|
||
|
if (providers.gradleProperty("paper.runDisableWatchdog").getOrElse("false") == "true") {
|
||
|
systemProperty("disable.watchdog", true)
|
||
|
}
|
||
|
systemProperty("io.papermc.paper.suppress.sout.nags", true)
|
||
|
|
||
|
val memoryGb = providers.gradleProperty("paper.runMemoryGb").getOrElse("2")
|
||
|
minHeapSize = "${memoryGb}G"
|
||
|
maxHeapSize = "${memoryGb}G"
|
||
|
|
||
|
doFirst {
|
||
|
workingDir.mkdirs()
|
||
|
}
|
||
|
|
||
|
block(this)
|
||
|
}
|
||
|
|
||
|
val runtimeClasspathWithoutVanillaServer = configurations.runtimeClasspath.flatMap { it.elements }
|
||
|
.zip(configurations.vanillaServer.map { it.singleFile.absolutePath }) { runtime, vanilla ->
|
||
|
runtime.filterNot { it.asFile.absolutePath == vanilla }
|
||
|
}
|
||
|
|
||
|
tasks.registerRunTask("runServerJar") {
|
||
|
description = "Spin up a test server from the serverJar archiveFile"
|
||
|
classpath(tasks.serverJar.flatMap { it.archiveFile })
|
||
|
classpath(runtimeClasspathWithoutVanillaServer)
|
||
|
}
|
||
|
|
||
|
tasks.registerRunTask("runReobf") {
|
||
|
description = "Spin up a test server from the reobfJar output jar"
|
||
|
classpath(tasks.reobfJar.flatMap { it.outputJar })
|
||
|
classpath(runtimeClasspathWithoutVanillaServer)
|
||
|
}
|
||
|
|
||
|
tasks.registerRunTask("runDev") {
|
||
|
description = "Spin up a non-relocated Mojang-mapped test server"
|
||
|
classpath(sourceSets.main.map { it.runtimeClasspath })
|
||
|
}
|