77 lines
2.8 KiB
Kotlin
77 lines
2.8 KiB
Kotlin
// Build-time patching engine. The patches themselves are in compat/b<major>/patches.
|
|
|
|
plugins {
|
|
id("zomboidforge.java-conventions")
|
|
}
|
|
|
|
// Patch set of the targeted Build; only on the class path of patchServerJar.
|
|
val serverPatches = configurations.create("serverPatches") {
|
|
isCanBeConsumed = false
|
|
isCanBeResolved = true
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":api"))
|
|
implementation(libs.bundles.asm)
|
|
serverPatches(project(projectZomboid.compatProject("patches")))
|
|
|
|
testImplementation(platform(libs.junit.bom))
|
|
testImplementation(libs.junit.jupiter)
|
|
testRuntimeOnly(libs.junit.platform.launcher)
|
|
}
|
|
|
|
tasks.test {
|
|
// Enables GameVersionReaderTest.readsTargetedVersionFromServerJar when the jar exists.
|
|
val serverJar = projectZomboid.serverJar
|
|
val targetedVersion = projectZomboid.version
|
|
inputs.property("pzVersion", targetedVersion)
|
|
jvmArgumentProviders.add(CommandLineArgumentProvider {
|
|
listOf(
|
|
"-Dpz.jar=${serverJar.get().asFile.absolutePath}",
|
|
"-Dpz.version=${targetedVersion.get()}",
|
|
)
|
|
})
|
|
}
|
|
|
|
tasks.register<JavaExec>("patchServerJar") {
|
|
description = "Applies the targeted Build's patches to the vanilla server jar."
|
|
group = "build"
|
|
|
|
val vanillaJar = projectZomboid.serverJar
|
|
val patchedJar = layout.buildDirectory.file("server/projectzomboid.jar")
|
|
val expectedVersion = projectZomboid.version
|
|
// Simple class names of patches to skip, e.g. -Pzf.disabledPatches=ServerStartedPatch (debug builds).
|
|
val disabledPatches = providers.gradleProperty("zf.disabledPatches").orElse("")
|
|
inputs.property("disabledPatches", disabledPatches)
|
|
inputs.file(vanillaJar).withPropertyName("vanillaJar")
|
|
inputs.property("expectedVersion", expectedVersion)
|
|
outputs.file(patchedJar).withPropertyName("patchedJar")
|
|
|
|
classpath = sourceSets.main.get().runtimeClasspath + serverPatches
|
|
mainClass = "dev.overlord.zomboidforge.patcher.JarPatcher"
|
|
jvmArgumentProviders.add(CommandLineArgumentProvider {
|
|
listOf("-Dzomboidforge.disabledPatches=${disabledPatches.get()}")
|
|
})
|
|
argumentProviders.add(CommandLineArgumentProvider {
|
|
listOf(
|
|
vanillaJar.get().asFile.absolutePath,
|
|
patchedJar.get().asFile.absolutePath,
|
|
expectedVersion.get(),
|
|
)
|
|
})
|
|
}
|
|
|
|
// Used by ci/release.sh (Dockerfile stage game-version) to name the image before the full build.
|
|
tasks.register<JavaExec>("printGameVersion") {
|
|
description = "Prints the game version of the server jar (pz.jar)."
|
|
group = "help"
|
|
|
|
val serverJar = projectZomboid.serverJar
|
|
|
|
classpath = sourceSets.main.get().runtimeClasspath
|
|
mainClass = "dev.overlord.zomboidforge.patcher.GameVersionReader"
|
|
argumentProviders.add(CommandLineArgumentProvider {
|
|
listOf(serverJar.get().asFile.absolutePath)
|
|
})
|
|
}
|