11import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2- import kotlin.math.log
32
43plugins {
54 application
@@ -69,16 +68,6 @@ tasks {
6968 named<ShadowJar>("shadowJar") {
7069 dependsOn("collectSourcePaths")
7170 from(layout.buildDirectory.file("scripts.txt"))
72- // Replace logback file as the custom colour classes can't be individually excluded from minimization
73- // https://github.com/GradleUp/shadow/issues/638
74- exclude("logback.xml")
75- val logback = layout.buildDirectory.file("resources/main/logback.xml")
76- .get().asFile.readText()
77- .replace("%colour", "%highlight")
78- .replace("%message(%msg){}", "%msg")
79- val asFile = layout.buildDirectory.file("logback-test.xml").get().asFile
80- asFile.writeText(logback)
81- from(asFile)
8271 minimize {
8372 exclude("world/gregs/voidps/engine/log/**")
8473 exclude(dependency("org.postgresql:postgresql:.*"))
@@ -88,6 +77,18 @@ tasks {
8877 archiveBaseName.set("void-server-${version}")
8978 archiveClassifier.set("")
9079 archiveVersion.set("")
80+ // Replace logback file as the custom colour classes can't be individually excluded from minimization
81+ // https://github.com/GradleUp/shadow/issues/638
82+ exclude("logback.xml")
83+ val resourcesDir = layout.projectDirectory.dir("src/main/resources")
84+ val logback = resourcesDir.file("logback.xml").asFile
85+ .readText()
86+ .replace("%colour", "%highlight")
87+ .replace("%message(%msg){}", "%msg")
88+ val replacement = layout.buildDirectory.file("logback-test.xml").get().asFile
89+ replacement.parentFile.mkdirs()
90+ replacement.writeText(logback)
91+ from(replacement)
9192 }
9293
9394 withType<Test> {
0 commit comments