Maven Shade Plugin Extensions
This project contains a collection of resource transformers for the Apache Maven Shade Plugin that allows you to use additional Log4j 2.x Core component modules.
Log4j Plugin Descriptor Transformer
A
resource transformer
for the
Apache Maven Shade Plugin
that merges Log4j2Plugins.dat
plugin caches from all the jars containing Log4j 2.x Core components.
This transformer was formerly available at edwgiz/maven-shaded-log4j-transformer and was donated to the Apache Software Foundation by its author.
If you are a Gradle user, you can use the equivalent Shadow Gradle Plugin transformer. |
Usage
This resource transformer is usually used together with the ManifestResourceTransformer
and ServicesResourceTransformer
to integrate Log4j 2.x libraries in a shaded JAR.
A typical configuration is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
<version>0.3.0-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>shade-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>