Java Maven:从阴影插件中排除依赖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22351542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven: exclude dependency from shade plugin
提问by VB_
I've seen next string after mvn clean install
我看到了下一个字符串之后 mvn clean install
Including com.sun.jersey.contribs:jersey-multipart:jar:1.5 in the shaded jar
在阴影 jar 中包括 com.sun.jersey.contribs:jersey-multipart:jar:1.5
Problem:I can't make it not shaded even I've added exlusion for maven-shade-plugin (see code below)
问题:即使我为 maven-shade-plugin 添加了排除项,我也无法让它不着色(见下面的代码)
My maven-shade-plugin:
我的 maven-shade-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<artifactSet>
<excludes>
//Here ==> <exclude>com.sun.jersey.contribs:jersey-multipart:jar</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>Main</Main-Class>
<Build-Number>123</Build-Number>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
采纳答案by blackbuild
According to http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html, your exclusion syntax is wrong:
根据http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html,您的排除语法是错误的:
Artifacts to include/exclude from the final artifact. Artifacts are denoted by composite identifiers of the general form groupId:artifactId:type:classifier. ... For convenience, the syntax groupIdis equivalent to groupId:*:*:*, groupId:artifactIdis equivalent to groupId:artifactId:*:*and groupId:artifactId:classifieris equivalent to groupId:artifactId:*:classifier.
从最终工件中包含/排除的工件。工件由一般形式groupId:artifactId:type:classifier的复合标识符表示。... 为方便起见,语法groupId等效于groupId:*:*:*,groupId:artifactId等效于groupId:artifactId:*:*并且groupId:artifactId:classifier等效于groupId:artifactId:*:classifier。
So either use com.sun.jersey.contribs:jersey-multipart:*:jar
or com.sun.jersey.contribs:jersey-multipart
for your exclusion.
所以要么使用com.sun.jersey.contribs:jersey-multipart:*:jar
要么com.sun.jersey.contribs:jersey-multipart
为你排除。
<artifactSet>
<excludes>
<exclude>com.sun.jersey.contribs:jersey-multipart</exclude>
</excludes>
</artifactSet>