【问题标题】:Disable war overlays in maven在 Maven 中禁用战争覆盖
【发布时间】:2011-08-03 03:06:09
【问题描述】:

当我在 maven 项目中具有类型为“war”的依赖项时,它会自动使用覆盖将其合并到我正在构建的项目中。

我想禁用覆盖。

为了使开发过程更简单,我希望在为本地 Tomcat 构建时使用带有 maven-junction-plugin 的符号链接,并且仅在为测试和生产服务器构建时使用覆盖。

也欢迎任何其他关于如何处理我需要修改而无需较长构建周期的战争依赖项的建议。

【问题讨论】:

    标签: maven-2 maven build-process war


    【解决方案1】:

    在我的例子中,overlay 发生是因为我们有war 类型的依赖项。

    我通过将所有这些依赖项放在默认启用的配置文件中来解决我的问题。也许是一个 hack,但它确实有效。

    <profile>
      <id>overlay-active</id>
    
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
              <dependentWarExcludes>WEB-INF/lib/*,META-INF/**</dependentWarExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    
      <dependencies>
        <dependency>
          <groupId>myGroup</groupId>
          <artifactId>myWarDepency</artifactId>
          <version>1.0-SNAPSHOT</version>
          <type>war</type>
        </dependency>
    

    【讨论】:

      【解决方案2】:

      您不能像 maven-war-plugin:2.1.1 那样禁用覆盖集,但可以从覆盖中排除文件。

      排除所有覆盖文件:

      <dependentWarIncludes></dependentWarIncludes> 
      <dependentWarExcludes>**</dependentWarExcludes>
      

      从特定叠加层中排除所有文件:

      <overlays>
        <overlay>
          <groupId>com.gentics</groupId>
          <artifactId>portalnode-webapp</artifactId>
          <excludes>
            <exclude>**/*</exclude>
          </excludes>
        </overlay>
      </overlays>
      

      请注意,这不会减少使用的叠加层数量。

      【讨论】:

        【解决方案3】:

        在配置文件中配置覆盖排除。要配置覆盖,请参阅: http://maven.apache.org/plugins/maven-war-plugin/overlays.html

        该链接指定如何使 maven-war-plugin 排除特定文件和文件夹。

        我想要实现的是根本没有任何覆盖,但覆盖是默认发生的。

        到目前为止,我发现的唯一解决方案是将战争依赖项本身放在配置文件中,但我对这个解决方案不满意,因为它闻起来有太多变通方法的味道。

        【讨论】:

          【解决方案4】:

          在配置文件中配置覆盖排除。要配置覆盖,请参阅: http://maven.apache.org/plugins/maven-war-plugin/overlays.html

          【讨论】:

            猜你喜欢
            • 2012-08-25
            • 2014-02-04
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-04-10
            • 2013-02-13
            • 2013-03-31
            • 2011-04-11
            相关资源
            最近更新 更多