Shade Plugin은 매우 쓸모가 많은 Plugin입니다. Classpath에서 외부 라이브러리 사용시 Conflict가 났을 때 참 처리하기 어렵니다. Shade Plugin을 사용하면 JAR 파일의 패키지를 다른 패키지로 이동할 수 있습니다.
아래 예제는 Netty 4의 패키지를 변경하는 예제입니다.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>pilot.maven</groupId> <artifactId>maven-shade</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>maven-shade</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.1.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadedArtifactAttached>true</shadedArtifactAttached> <shadedClassifierName>jackofall</shadedClassifierName> <relocations> <relocation> <pattern>io.netty</pattern> <shadedPattern>com.mycompany.netty</shadedPattern> </relocation> </relocations> </configuration> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.1.17.Final</version> </dependency> </dependencies> </project>