diff --git a/bin/log4j2.xml b/bin/log4j2.xml index 47b012f2cf..feb8954d56 100644 --- a/bin/log4j2.xml +++ b/bin/log4j2.xml @@ -16,7 +16,7 @@ ~ limitations under the License. --> - + diff --git a/src/core/build.gradle.kts b/src/core/build.gradle.kts index 38fa682e8e..98141cdcab 100644 --- a/src/core/build.gradle.kts +++ b/src/core/build.gradle.kts @@ -17,6 +17,7 @@ import com.github.autostyle.gradle.AutostyleTask import com.github.vlsi.gradle.ide.IdeExtension +import java.util.jar.JarFile plugins { id("java-test-fixtures") @@ -45,6 +46,9 @@ dependencies { api("org.apache.logging.log4j:log4j-core") { because("GuiLogEventAppender is using log4j-core to implement GUI-based log appender") } + kapt("org.apache.logging.log4j:log4j-core") { + because("Generates a plugin cache file for GuiLogEventAppender") + } api("org.apache.logging.log4j:log4j-slf4j-impl") { because("Both log4j and slf4j are included, so it makes sense to just add log4j->slf4j bridge as well") } @@ -188,3 +192,16 @@ tasks.jar { from("$rootDir/xdocs/images/logo.svg") } } + +// Checks the generated JAR for a Log4j plugin cache file. +tasks.jar { + doLast { + val jarFile = archiveFile.get().asFile + JarFile(jarFile).use { jar -> + val entryName = "META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat" + if (jar.getJarEntry(entryName) == null) { + throw IllegalStateException("$entryName was not found in $jarFile. The entry should be generated by log4j-core annotation processor") + } + } + } +}