2020-12-11 05:54:19 +01:00
import io.papermc.paperweight.util.*
2016-03-01 21:32:43 +01:00
import java.time.Instant
2020-12-11 05:54:19 +01:00
plugins {
2024-12-06 22:02:39 +01:00
`java-library`
2020-12-11 05:54:19 +01:00
`maven-publish`
2024-12-06 22:02:39 +01:00
id("io.papermc.paperweight.core")
}
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
dependencies {
mache("io.papermc:mache:1.21.4+build.5")
2024-12-06 22:46:41 +01:00
paperclip("io.papermc:paperclip:3.0.3")
2024-12-08 04:13:17 +01:00
remapper("net.fabricmc:tiny-remapper:0.10.3:fat")
2024-12-06 22:02:39 +01:00
}
paperweight {
2024-12-06 22:46:41 +01:00
minecraftVersion = providers.gradleProperty("mcVersion")
2024-12-06 22:02:39 +01:00
// macheOldPath = file("F:\\Projects\\PaperTooling\\mache\\versions\\1.21.4\\src\\main\\java")
// gitFilePatches = true
paper {
2024-12-06 22:46:41 +01:00
reobfMappingsPatch = layout.projectDirectory.file("../build-data/reobf-mappings-patch.tiny")
reobfPackagesToFix.addAll(
"co.aikar.timings",
"com.destroystokyo.paper",
"com.mojang",
"io.papermc.paper",
"ca.spottedleaf",
"net.kyori.adventure.bossbar",
"net.minecraft",
"org.bukkit.craftbukkit",
"org.spigotmc",
)
2024-12-06 22:02:39 +01:00
}
2024-12-06 22:46:41 +01:00
spigot {
buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42"
packageVersion = "v1_21_R3" // also needs to be updated in MappingEnvironment"
}
2024-12-06 22:02:39 +01:00
}
tasks.generateDevelopmentBundle {
apiCoordinates = "io.papermc.paper:paper-api"
libraryRepositories.addAll(
"https://repo.maven.apache.org/maven2/",
paperMavenPublicUrl,
)
}
publishing {
if (project.providers.gradleProperty("publishDevBundle").isPresent) {
publications.create<MavenPublication>("devBundle") {
artifact(tasks.generateDevelopmentBundle) {
artifactId = "dev-bundle"
}
}
}
2020-12-11 05:54:19 +01:00
}
2017-06-09 19:03:43 +02:00
val log4jPlugins = sourceSets.create("log4jPlugins")
configurations.named(log4jPlugins.compileClasspathConfigurationName) {
extendsFrom(configurations.compileClasspath.get())
}
val alsoShade: Configuration by configurations.creating
2023-02-13 23:14:56 +01:00
// Paper start - configure mockito agent that is needed in newer java versions
val mockitoAgent = configurations.register("mockitoAgent")
abstract class MockitoAgentProvider : CommandLineArgumentProvider {
@get:CompileClasspath
abstract val fileCollection: ConfigurableFileCollection
override fun asArguments(): Iterable<String> {
return listOf("-javaagent:" + fileCollection.files.single().absolutePath)
}
}
// Paper end - configure mockito agent that is needed in newer java versions
2020-12-11 05:54:19 +01:00
dependencies {
implementation(project(":paper-api"))
2022-01-24 07:58:11 +01:00
implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency
2017-06-09 19:03:43 +02:00
// Paper start
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
implementation("net.minecrell:terminalconsoleappender:1.3.0")
implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file
/*
Required to add the missing Log4j2Plugins.dat file from log4j-core
which has been removed by Mojang. Without it, log4j has to classload
all its classes to check if they are plugins.
Scanning takes about 1-2 seconds so adding this speeds up the server start.
*/
2017-09-21 16:14:55 +02:00
implementation("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - implementation
2017-06-09 19:03:43 +02:00
log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
runtimeOnly(log4jPlugins.output)
alsoShade(log4jPlugins.output)
2022-04-07 16:13:39 +02:00
implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol
2017-06-09 19:03:43 +02:00
// Paper end
2016-03-01 03:40:33 +01:00
implementation("org.apache.logging.log4j:log4j-iostreams:2.24.1") // Paper - remove exclusion
2020-12-11 05:54:19 +01:00
implementation("org.ow2.asm:asm-commons:9.7.1")
2022-06-09 07:20:16 +02:00
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
2020-12-11 05:54:19 +01:00
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")
2021-08-12 13:46:41 +02:00
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
2020-12-11 05:54:19 +01:00
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")
2020-01-03 16:26:19 +01:00
testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
2020-12-11 05:54:19 +01:00
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")
2023-02-13 23:14:56 +01:00
mockitoAgent("org.mockito:mockito-core:5.14.1") { isTransitive = false } // Paper - configure mockito agent that is needed in newer java versions
2020-12-11 05:54:19 +01:00
testImplementation("org.ow2.asm:asm-tree:9.7.1")
2023-02-13 23:14:56 +01:00
testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest
2021-06-21 03:19:09 +02:00
implementation("net.neoforged:srgutils:1.0.9") // Paper - mappings handling
2022-10-30 00:22:32 +02:00
implementation("net.neoforged:AutoRenamingTool:2.0.3") // Paper - remap plugins
2022-10-30 23:47:26 +01:00
// Paper start - Remap reflection
val reflectionRewriterVersion = "0.0.3"
implementation("io.papermc:reflection-rewriter:$reflectionRewriterVersion")
implementation("io.papermc:reflection-rewriter-runtime:$reflectionRewriterVersion")
implementation("io.papermc:reflection-rewriter-proxy-generator:$reflectionRewriterVersion")
// Paper end - Remap reflection
2024-07-16 23:55:23 +02:00
// Paper start - spark
implementation("me.lucko:spark-api:0.1-20240720.200737-2")
implementation("me.lucko:spark-paper:1.10.119-SNAPSHOT")
// Paper end - spark
2020-12-11 05:54:19 +01:00
}
tasks.jar {
manifest {
val git = Git(rootProject.layout.projectDirectory.path)
2016-03-01 21:32:43 +01:00
val mcVersion = rootProject.providers.gradleProperty("mcVersion").get()
val build = System.getenv("BUILD_NUMBER") ?: null
2020-12-11 05:54:19 +01:00
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
2016-03-01 21:32:43 +01:00
val implementationVersion = "$mcVersion-${build ?: "DEV"}-$gitHash"
2020-12-11 05:54:19 +01:00
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
2016-03-01 03:40:33 +01:00
val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
2020-12-11 05:54:19 +01:00
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
2016-03-01 21:32:43 +01:00
"Implementation-Title" to "Paper",
"Implementation-Version" to implementationVersion,
2020-12-11 05:54:19 +01:00
"Implementation-Vendor" to date, // Paper
2016-03-01 21:32:43 +01:00
"Specification-Title" to "Paper",
2020-12-11 05:54:19 +01:00
"Specification-Version" to project.version,
2016-03-01 21:32:43 +01:00
"Specification-Vendor" to "Paper Team",
"Brand-Id" to "papermc:paper",
"Brand-Name" to "Paper",
"Build-Number" to (build ?: ""),
"Build-Time" to Instant.now().toString(),
2016-03-01 03:40:33 +01:00
"Git-Branch" to gitBranch, // Paper
"Git-Commit" to gitHash, // Paper
2020-12-11 05:54:19 +01:00
)
for (tld in setOf("net", "com", "org")) {
attributes("$tld/bukkit", "Sealed" to true)
}
}
}
2023-02-13 23:14:56 +01:00
// Paper start - compile tests with -parameters for better junit parameterized test names
tasks.compileTestJava {
options.compilerArgs.add("-parameters")
}
// Paper end
2020-12-11 05:54:19 +01:00
publishing {
publications.create<MavenPublication>("maven") {
}
}
2016-03-01 03:40:33 +01:00
// Paper start
2024-12-08 04:20:50 +01:00
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
classpath.from(configurations.compileClasspath)
}
tasks.check {
dependsOn(scanJar)
}
2016-03-01 03:40:33 +01:00
// Paper end
2017-06-09 19:03:43 +02:00
// Paper start - use TCA for console improvements
2024-12-08 04:20:50 +01:00
tasks.jar {
from(alsoShade.elements.map {
it.map { f ->
if (f.asFile.isFile) {
zipTree(f.asFile)
} else {
f.asFile
}
}
})
}
2017-06-09 19:03:43 +02:00
// Paper end - use TCA for console improvements
2016-03-01 03:40:33 +01:00
2020-12-11 05:54:19 +01:00
tasks.test {
include("**/**TestSuite.class")
workingDir = temporaryDir
useJUnitPlatform {
forkEvery = 1
excludeTags("Slow")
}
2023-02-13 23:14:56 +01:00
// Paper start - configure mockito agent that is needed in newer java versions
val provider = objects.newInstance<MockitoAgentProvider>()
provider.fileCollection.from(mockitoAgent)
jvmArgumentProviders.add(provider)
// Paper end - configure mockito agent that is needed in newer java versions
2020-12-11 05:54:19 +01:00
}
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)
}
2024-12-08 04:20:50 +01:00
tasks.registerRunTask("runServer") {
description = "Spin up a test server from the Mojang mapped server jar"
classpath(tasks.includeMappings.flatMap { it.outputJar })
classpath(configurations.runtimeClasspath)
}
tasks.registerRunTask("runReobfServer") {
description = "Spin up a test server from the reobfJar output jar"
classpath(tasks.reobfJar.flatMap { it.outputJar })
classpath(configurations.runtimeClasspath)
}
2020-12-11 05:54:19 +01:00
2022-10-30 00:22:32 +02:00
tasks.registerRunTask("runDevServer") {
description = "Spin up a test server without assembling a jar"
2020-12-11 05:54:19 +01:00
classpath(sourceSets.main.map { it.runtimeClasspath })
2016-03-01 03:40:33 +01:00
jvmArgs("-DPaper.pushPaperAssetsRoot=true")
2020-12-11 05:54:19 +01:00
}
2022-10-30 00:22:32 +02:00
tasks.registerRunTask("runBundler") {
description = "Spin up a test server from the Mojang mapped bundler jar"
2024-12-06 22:02:39 +01:00
classpath(tasks.named<io.papermc.paperweight.tasks.CreateBundlerJar>("createMojmapBundlerJar").flatMap { it.outputZip })
2022-10-30 00:22:32 +02:00
mainClass.set(null as String?)
}
2024-12-08 04:20:50 +01:00
tasks.registerRunTask("runReobfBundler") {
description = "Spin up a test server from the reobf bundler jar"
classpath(rootProject.tasks.named<io.papermc.paperweight.tasks.CreateBundlerJar>("createReobfBundlerJar").flatMap { it.outputZip })
mainClass.set(null as String?)
}
2022-10-30 00:22:32 +02:00
tasks.registerRunTask("runPaperclip") {
description = "Spin up a test server from the Mojang mapped Paperclip jar"
2024-12-06 22:02:39 +01:00
classpath(tasks.named<io.papermc.paperweight.tasks.CreatePaperclipJar>("createMojmapPaperclipJar").flatMap { it.outputZip })
2022-10-30 00:22:32 +02:00
mainClass.set(null as String?)
}
2024-12-08 04:20:50 +01:00
tasks.registerRunTask("runReobfPaperclip") {
description = "Spin up a test server from the reobf Paperclip jar"
classpath(rootProject.tasks.named<io.papermc.paperweight.tasks.CreatePaperclipJar>("createReobfPaperclipJar").flatMap { it.outputZip })
mainClass.set(null as String?)
}