Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用maven从war中排除某些覆盖派生目录?_Maven - Fatal编程技术网

如何使用maven从war中排除某些覆盖派生目录?

如何使用maven从war中排除某些覆盖派生目录?,maven,Maven,我们使用maven 3.5.0和maven war插件构建了一个webapp。我们有许多覆盖,其中许多有一个tests目录,其中包含用于在dev环境中测试某些内容的JSP文件。我们不想把这些包括在我们的战争中 我们尝试了以下方法: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId>

我们使用maven 3.5.0和maven war插件构建了一个webapp。我们有许多覆盖,其中许多有一个tests目录,其中包含用于在dev环境中测试某些内容的JSP文件。我们不想把这些包括在我们的战争中

我们尝试了以下方法:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <overlays>...</overlays>
        <warSourceExcludes>tests</warSourceExcludes>
    </configuration>
</plugin>

这是因为我天真地滥用了配置选项,还是与覆盖的处理方式有关?

您应该使用。。看,而不是

DependentWalexCludes元素用于消除测试目录及其内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <overlays>...</overlays>
        <dependentWarExcludes>tests/**</dependentWarExcludes>
    </configuration>
</plugin>

所以,听起来没有办法用一个通用的exclude语句从每个覆盖中排除某个目录。相反,我需要在每个覆盖规范中重复使用excludes语句?问题是,如果以后需要排除它,为什么要将它打包到WAR中?也许制作一个单独的WAR文件是有意义的,它只包含您需要的东西,一种普通的WAR。。?
<packagingExcludes>**/${project.artifactId}/tests/**</packagingExcludes>
 ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.2</version>
        <configuration>
          <overlays>
            <overlay>
              <groupId>com.example.projects</groupId>
              <artifactId>documentedprojectdependency</artifactId>
              <excludes>
                <exclude>WEB-INF/classes/images/sampleimage-dependency.jpg</exclude>
              </excludes>
            </overlay>
          </overlays>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <overlays>...</overlays>
        <dependentWarExcludes>tests/**</dependentWarExcludes>
    </configuration>
</plugin>