As of shadow plugin version 4.0.0 you don't need this transformer anymore and should use the provided transformer:
shadowJar{
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
}
A shadow plugin transformer implementation for log4j to concatenate Log4j2Plugins.dat files.
This is a port of the maven-shaded-log4j-transformer.
The version numbering scheme is has the following format: SHADOW_MAJOR
.MINOR
.PATCH
. This is no real semantic versioning because the SHADOW_MAJOR version number correspond to the MAJOR shadow plugin version number.
At the time of writing, the latest shadow plugin version was 2.0.2
. Therefore, you should use this library's version starting with 2
.
If you are stuck at version 1.2.4
use the library version starting with 1
.
The latest library version is 2.2.0
. It requires at least Java 7.
You can get version notifications on bintray:
This implementation must work with the shadow plugin and will use Log4j 2.
You should use this implementation as library. You may use it as gradle plugin though this is not recommended anymore due to issues (e.g. #2, #3 and, #5).
The implementation should be used as library to provide the Log4j 2 transformer. This is as easy as shown below:
buildscript {
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
classpath 'de.sebastianboegl.gradle.plugins:shadow-log4j-transformer:2.2.0'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
transform(de.sebastianboegl.gradle.plugins.shadow.transformers.Log4j2PluginsFileTransformer)
}
The plugin applies the latest version of the shadow plugin or the one in the dependency block, hence, you don't have to apply the shadow plugin.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
classpath "de.sebastianboegl.gradle.plugins:shadow-log4j-transformer:2.2.0"
}
}
apply plugin: "de.sebastianboegl.shadow.transformer.log4j"
The order of the plugins doesn't matter:
plugins {
id "com.github.johnrengelman.shadow" version "2.0.2"
id "de.sebastianboegl.shadow.transformer.log4j" version "2.2.0"
}
There is no configuration needed. The plugin adds itself as Transformer (see the shadow plugin documentation Section Controlling JAR Content Merging).