如何使用 Maven War 插件从目标目录中排除文件/目录?

发布于 2024-08-09 16:49:28 字数 915 浏览 3 评论 0原文

我按照此处的说明进行操作,它可以工作,但前提是它映射到默认目录以外的目录。

这是我尝试过的示例:

<configuration>
     <webResources>
          <resource>
              <directory>${basedir}/src/main/webapp/WEB-INF</directory>
              <!-- the below works when uncommented and does exclude *.tmp -->
              <!-- <targetPath>test/WEB-INF</targetPath> -->
              <!-- the below does not -->
              <targetPath>WEB-INF</targetPath>
              <excludes>
                <exclude>*.tmp</exclude>
              </excludes>
          </resource>
      </webResources>
</configuration>

所以我的假设是我有其他东西覆盖了配置。然而,这是我使用 Maven 的第一个项目,所以我不确定接下来要测试或调查什么。

I followed the instructions here, and it worked but only if it was mapped to a directory other than the default.

Here's a sample that I tried:

<configuration>
     <webResources>
          <resource>
              <directory>${basedir}/src/main/webapp/WEB-INF</directory>
              <!-- the below works when uncommented and does exclude *.tmp -->
              <!-- <targetPath>test/WEB-INF</targetPath> -->
              <!-- the below does not -->
              <targetPath>WEB-INF</targetPath>
              <excludes>
                <exclude>*.tmp</exclude>
              </excludes>
          </resource>
      </webResources>
</configuration>

So my assumptions is that I have something else overriding the configuration. However, this is my first project using maven, so I'm not sure what to test or investigate next.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷夜 2024-08-16 16:49:28

将排除更改为

**/*.tmp

您还可以从目录中删除 WEB-INF 并完全删除 targetDirectory。例如,这里将包含所有 xml、xhtml、x*ml 等,并排除任何目录中的所有 *.tmp

<webResources>
    <resource>
        <directory>${basedir}/src/main/webapp</directory>
        <includes>
            <include>**/*.x*ml</include>
        </includes>
        <excludes>
            <exclude>**/*.tmp</exclude>
        </excludes>
    </resource>
</webResources>

change your exclusion to

**/*.tmp

You could also leave off the WEB-INF from the directory and remove the targetDirectory altogether. For instance, here's one that would include all xml, xhtml, x*ml etc. and excludes all *.tmp in any directory

<webResources>
    <resource>
        <directory>${basedir}/src/main/webapp</directory>
        <includes>
            <include>**/*.x*ml</include>
        </includes>
        <excludes>
            <exclude>**/*.tmp</exclude>
        </excludes>
    </resource>
</webResources>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文