【问题标题】:maven assembly plugin ignoring classifier in excludeMaven 程序集插件忽略排除中的分类器
【发布时间】:2014-03-29 11:34:48
【问题描述】:

我在带有 java 7 的 maven 3.0.4 上使用 maven 程序集插件版本 2.4

这是我的程序集描述符的摘录:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

     <!--...some stuff skipped here...->

      <moduleSets>
        <moduleSet>
          <useAllReactorProjects>true</useAllReactorProjects>
          <includes>
            <include>com.mycompany.myproject.ugui:ugui-application</include>
          </includes>
          <excludes>
            <exclude>com.mycompany.myproject.ugui:ugui-application:war:*:sources</exclude>
          </excludes>
          <binaries>
            <outputDirectory>war-file</outputDirectory>
            <unpack>false</unpack>
          </binaries>
        </moduleSet>
      </moduleSets>

maven 程序集的 xsd 声称我用于排除的格式是正确的...

  <xs:element minOccurs="0" name="excludes">
    <xs:annotation>
      <xs:documentation source="version">1.0.0+</xs:documentation>
      <xs:documentation source="description">

        When &amp;lt;exclude&amp;gt; subelements are present, they define a set of
        dependency artifact coordinates to exclude. If none is present, then
        &amp;lt;excludes&amp;gt; represents no exclusions.

        Artifact coordinatess may be given in simple groupId:artifactId form,
        or they may be fully qualified in the form groupId:artifactId:type:version[:classifier].
        Additionally, wildcards can be used, as in *:maven-*

      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="exclude" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

但是,当我运行程序集时,它无法理解排除...

[INFO] --- maven-assembly-plugin:2.4:single (make-deployment-tar-zip-file) @ ugui-deploy ---
[INFO] Reading assembly descriptor: /home/fitzpatr/code/trunk/unicorn-ui/ugui-deploy/src/main/assembly/assembly.xml
[WARNING] The following patterns were never triggered in this artifact exclusion filter:
o  'com.mycompany.myproject.ugui:ugui-application:war:*:sources'

[WARNING] The following patterns were never triggered in this artifact exclusion filter:
o  'com.mycompany.myproject.ugui:ugui-application:war:*:sources'

...以及我试图排除的来源包含在程序集 tar...

$ tar -tvf ugui-deploy/target/ugui-deploy-1.8-SNAPSHOT-bin.tar.gz 
-rw-rw-r-- user/user 83885791 2014-02-26 15:39 ugui-deploy-1.8-SNAPSHOT/war-file/ugui-application-1.8-SNAPSHOT.war
-rw-rw-r-- user/usser    65220 2014-01-17 11:30 ugui-deploy-1.8-SNAPSHOT/war-file/ugui-application-1.8-SNAPSHOT-sources.war
-rw-rw-r-- user/user        0 2014-02-25 18:13 ugui-deploy-1.8-SNAPSHOT/README.txt

...所以我做错了还是maven程序集插件坏了???

【问题讨论】:

  • 请检查您的程序集描述符,因为根据网站上的文档,包含/排除看起来像这样:groupId:artifactId:type[:classifier]:version
  • 你检查过这个吗?
  • 是的,我已经检查过了,分类器不起作用。
  • 投反对票的人能否提供一些建设性的反馈,谢谢。
  • 请反对的选民为自己辩护。这个问题有什么问题???

标签: maven maven-3 maven-assembly-plugin multi-module


【解决方案1】:

这个问题是通过使用一种不太直观的技巧来解决的,排除二进制元素内的所有内容...

  <moduleSets>
    <moduleSet>
      <useAllReactorProjects>true</useAllReactorProjects>
      <includes>
        <include>com.mycompany.myproject.ugui:ugui-application</include>
      </includes>
      <binaries>
        <outputDirectory>war-file</outputDirectory>
        <unpack>false</unpack>
        <excludes>
          <exclude>*</exclude>
        </excludes>
      </binaries>
    </moduleSet>
  </moduleSets>

...产生期望的结果...

$ tar -tvf ugui-deploy/target/ugui-deploy-1.8-SNAPSHOT-bin.tar.gz
-rw-rw-r-- user/user 0 2014-02-25 18:13 ugui-deploy-1.8-SNAPSHOT/README.txt
-rw-rw-r-- user/user 83885789 2014-02-26 16:49 ugui-deploy-1.8-SNAPSHOT/war-file/ugui-application-1.8-SNAPSHOT.war

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    相关资源
    最近更新 更多