我试图通过使用Maven Shade Plugin
的minimizeJar
来最小化UberJar的大小。它看起来像minimizeJar
只包括在代码中静态导入的类(我怀疑这是因为我看到LogFactory.class
在超级罐子里org\apache\commons\logging\
但没有包括impl
包的类,因此在运行超级罐时抛出java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl
)。配置Maven Shade最小化Jar包含类文件
有没有什么办法可以告诉Maven的Shade插件将指定的软件包包含到最终的jar中?无论minimizeJar
暗示什么?
这里我想做的POM片段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<filters>
<filter>
<artifact>commons-logging:commons-logging</artifact>
<includes>
<include>org/apache/commons/logging/**</include>
</includes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.myproject.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
'org/apache/commons/logging/**'只能匹配目录,你可能想匹配所有文件。改用'org/apache/commons/logging/**/*'。 – Corubba 2012-01-02 12:00:59
按照你的建议,我尝试了'... logging/**','... logging/**/*','... logging /**/*.*',但都没有成功。我想问题是包括首先包括然后最小化Jar忽略其他所有和捆绑罐子,因为它认为是合适的。 – kunal 2012-01-02 13:24:49