Maven Shade插件没有重新定位commons-logging

3npbholx  于 12个月前  发布在  Maven
关注(0)|答案(1)|浏览(194)

我不能让maven shade插件实际上重新定位不同包中的类。
OcpSoft不小心在他们漂亮的面孔jar中遮蔽了一个commons logging impl。这使得它几乎不可能禁用一些烦人的日志消息,因为正常的commons logging配置不会被他们的遮蔽impl拾取。
我认为解决这个问题的最好方法是创建一个JCL-SLF 4J桥的shaded版本,但是我似乎不能让maven shade插件真正重新定位所需的类。

<dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.30</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <relocations>
                                <relocation>
                                    <includes>org</includes>
                                    <shadedPattern>org.ocpsoft.shade.org</shadedPattern>
                                </relocation>
                            </relocations>
                            <artifactSet>
                                <includes>
                                    <include>org.slf4j:jcl-over-slf4j</include>
                                </includes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

字符串
这将产生以下结果:

$ unzip ocpsoft-slf4j-bridge-1.0.0-SNAPSHOT.jar 
Archive:  ocpsoft-slf4j-bridge-1.0.0-SNAPSHOT.jar
   creating: META-INF/
  inflating: META-INF/MANIFEST.MF     
   creating: META-INF/maven/
   creating: META-INF/maven/com.xxx.xcut/
   creating: META-INF/maven/com.xxx.xcut/ocpsoft-slf4j-bridge/
  inflating: META-INF/maven/com.xxx.xcut/ocpsoft-slf4j-bridge/pom.xml  
  inflating: META-INF/maven/com.xxx.xcut/ocpsoft-slf4j-bridge/pom.properties  
   creating: META-INF/services/
  inflating: META-INF/services/org.apache.commons.logging.LogFactory  
   creating: org/
   creating: org/apache/
   creating: org/apache/commons/
   creating: org/apache/commons/logging/
   creating: org/apache/commons/logging/impl/
  inflating: org/apache/commons/logging/impl/NoOpLog.class  
  inflating: org/apache/commons/logging/impl/SimpleLog$1.class  
  inflating: org/apache/commons/logging/impl/SimpleLog.class  
  inflating: org/apache/commons/logging/impl/SLF4JLocationAwareLog.class  
  inflating: org/apache/commons/logging/impl/SLF4JLog.class  
  inflating: org/apache/commons/logging/impl/SLF4JLogFactory.class  
  inflating: org/apache/commons/logging/Log.class  
  inflating: org/apache/commons/logging/LogConfigurationException.class  
  inflating: org/apache/commons/logging/LogFactory.class  
   creating: META-INF/maven/org.slf4j/
   creating: META-INF/maven/org.slf4j/jcl-over-slf4j/
  inflating: META-INF/maven/org.slf4j/jcl-over-slf4j/pom.xml  
  inflating: META-INF/maven/org.slf4j/jcl-over-slf4j/pom.properties


我希望上面的类现在就在org.ocpsoft.shade.org.apache.commons.包中

c86crjj0

c86crjj01#

不知道为什么,但将其添加到配置中使其工作:

<transformers>
  <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
  <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
 </transformers>

字符串

相关问题