【问题标题】:Apache Maven Resources Plugin exclude a directoryApache Maven 资源插件排除目录
【发布时间】:2015-03-13 23:20:56
【问题描述】:

我试图在构建过程中将一些资源从一个点复制到另一个点。因此我使用 Apache Maven 资源插件。实际上我排除了一些文件,我不需要。但我也想排除一个目录。我尝试了几种方法,但都不起作用。

<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
    <execution>
        <id>copy-client-product</id>
        <phase>verify</phase>
        <goals>
            <goal>copy-resources</goal>
        </goals>
        <configuration>
            <outputDirectory>${basedir}/target/pro/client</outputDirectory>
            <resources>
                <resource>
                    <directory>target\products\client\win32\win32\x86\</directory>
                    <excludes>
                        <exclude>p2</exclude>
                        <exclude>eclipsec.exe</exclude>
                    </excludes>
                </resource>
            </resources>
        </configuration>
    </execution>
</executions>

在此示例中,我尝试排除文件夹“p2”。

<exclude>*/p2/**</exclude>
<exclude>p2/**</exclude>
<exclude>**/p2</exclude>

也不行。

【问题讨论】:

  • 曾经尝试过使用&lt;exclude&gt;**/p2/**&lt;/exclude&gt; 吗?
  • 顺便说一句:你为​​什么使用verify 阶段?
  • 顺便说一句:你为​​什么使用verify 阶段?
  • 这是一个旧配置,不知道我为什么这样做^^您的建议有效,谢谢!请将其发布为答案,以便我将其标记为正确。
  • @khmarbaise 我们使用 verify 来防止将 maven 工件安装到本地 m2 存储库。因此我们有一个单独的构建。

标签: maven maven-resources-plugin


【解决方案1】:

&lt;exclude&gt;**/p2/**&lt;/exclude&gt;

感谢@khmarbaise,这是正确答案。

【讨论】:

  • 有人试图利用别人的知识来提升声誉?
  • @UweAllner:答案在 cmets 中,我刚刚添加了它,并标记了来源。
  • 你没有添加任何有价值的东西;不是解释、附加信息或其他任何东西。
  • 这可行,但如果您只想排除特定的 p2 目录而不是所有 p2 目录怎么办?
  • 非常感谢您的回答。本文档并没有提供太多细节:maven.apache.org/plugins-archives/maven-war-plugin-2.3/examples/…
【解决方案2】:

试试这个

<resource>
  <directory>p2</directory>
  <excludes>
      <exclude>p2/**</exclude>
   </excludes>
 </resource>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-28
    • 2019-02-19
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多