如何排除文件被maven复制到爆炸的战争中

Kri*_*ris 8 war maven

我有一个Java Web应用程序,其中我在标准webapp源目录(src/main/webapp)中有一些文件夹,我不想被复制到war(explodedpackaged)中.

我不希望这些文件复制的原因之一是我们在爆炸战争中的.js和.css文件上运行YUI JS&CSS最小化器和压缩器.我想要排除的文件在压缩阶段产生错误.我不希望他们加入战争的另一个原因是他们支持测试位于webapp中的单页JS应用程序(它们是依赖于node/的客户端JS测试脚本angular.js).

以下是相关部分POM.xml:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.1.1</version>
  <executions>
    <execution>
      <id>parent-resources</id>
      <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <overlays>
        </overlays>
        <webappDirectory>${project.build.directory}/${project.build.finalName}-work</webappDirectory>
      </configuration>
      <phase>generate-sources</phase>
      <goals>
        <goal>exploded</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我尝试过,warSourceExcludes但未成功地使用它来排除某些路径,但无济于事.我的用法示例如下所示,其中client/是直接位于下方的文件夹src/main/webapp:

<configuration>
  ...
  <warSourceExcludes>
    <excludes>
      <exclude>
        client/
      </exclude>
    </excludes>
  </warSourceExcludes>
  ...
</configuration>
Run Code Online (Sandbox Code Playgroud)

将Web应用程序源目录中的某些路径和/或单个文件排除在爆炸战争中的正确方法是什么?

UPDATE

根据@maba的建议,我更新了配置如下:

<configuration>
  <failOnMissingWebXml>false</failOnMissingWebXml>
  <overlays>
  </overlays>                                 
  <webappDirectory>${project.build.directory}/${project.build.finalName}-work</webappDirectory>
  <warSourceExcludes>client/</warSourceExcludes>
</configuration>
Run Code Online (Sandbox Code Playgroud)

该文件夹client/仍然被复制.有任何想法吗?

Kri*_*ris 8

感谢@alexksandr和@maba的回答 - 尽管这些问题没有完全解决我的问题.

解决方案似乎是 - 虽然我不确定为什么会出现这种情况 - 配置部分在放入execution部分时没有被选中.

使用我原来的pom.xml并重新分解它以使其工作给出:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.1.1</version>
  <configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <overlays>
    </overlays>
    <webappDirectory>${project.build.directory}/${project.build.finalName}-work</webappDirectory>
    <warSourceExcludes>client/</warSourceExcludes>
  </configuration>
  <executions>
    <execution>
      <id>parent-resources</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>exploded</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

重要的细节似乎是配置应该在插件的顶层,而不是在execution部分内 - 尽管xml我第一次尝试使用的warSourceExcludes是远离目标(参见更新部分之前的原始问题).