Maven:从shade插件中排除依赖

时间:2014-03-12 12:27:33

标签: java maven packaging

我在mvn clean install

之后看过下一个字符串
  

包括com.sun.jersey.contribs:jersey-multipart:jar:1.5 in   阴影罐

问题:即使我为maven-shade-plugin添加了exlusion,也无法使其不显示阴影(参见下面的代码)

我的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>

1 个答案:

答案 0 :(得分:5)

根据http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html,您的排除语法错误:

  

要包含/排除最终工件的工件。工件由一般形式 groupId:artifactId:type:classifier 的复合标识符表示。 ...为方便起见,语法 groupId 等同于 groupId:*:*:* groupId:artifactId 等同于 groupId:artifactId:*:* groupId:artifactId:classifier 等同于 groupId:artifactId:*:classifier 。< / p>

因此,您可以使用com.sun.jersey.contribs:jersey-multipart:*:jarcom.sun.jersey.contribs:jersey-multipart进行排除。

               <artifactSet>
                  <excludes>
                     <exclude>com.sun.jersey.contribs:jersey-multipart</exclude>
                   </excludes>
               </artifactSet>