在 Maven 中禁用战争覆盖

发布于 2024-10-31 17:36:05 字数 218 浏览 6 评论 0原文

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

我想禁用覆盖。

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

关于如何在没有较长构建周期的情况下修改我需要修改的战争依赖项的任何其他建议也是受欢迎的。

When I have a dependency of type 'war' in a maven project, it automatically uses overlay to merge it into the project I am building.

I would like to disable overlay.

To make the development process simpler I want to rather use symlinks with maven-junction-plugin when I'm building for my local Tomcat, and overlay only when I'm building for test and prod servers.

Any other suggestions on how I can work war dependencies that I need to modify without having a long build cycle is also welcome.

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

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

发布评论

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

评论(4

云归处 2024-11-07 17:36:05

您无法像 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>

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

You can't disable the set of overlays as for maven-war-plugin:2.1.1 but you can exclude files from the overlay.

Exclude all overlay files:

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

Exclude all files from a specific overlays:

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

Please note that this will not reduce the amount of overlays that are used.

悍妇囚夫 2024-11-07 17:36:05

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

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

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

到目前为止,我找到的唯一解决方案是将战争依赖项本身放入配置文件中,但我对这个解决方案并不满意,因为它听起来像是一种解决方法。

Configure overlay exclusion in a profile. To configure overlays see:
http://maven.apache.org/plugins/maven-war-plugin/overlays.html

That link specifies how to make maven-war-plugin exclude specific files and folders.

What I want to achieve is to not have any overlay at all, but the overlay happens by default.

The only solution I have found so far is to put the war dependencies themselves in a profile, but I'm not happy with this solution, as it smells too much of a workaround.

夢归不見 2024-11-07 17:36:05

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

Configure overlay exclusion in a profile. To configure overlays see:
http://maven.apache.org/plugins/maven-war-plugin/overlays.html

深海少女心 2024-11-07 17:36:05

就我而言,重叠发生是因为我们有战争类型的依赖关系。

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

<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>

In my case overlay happens because we I have dependencies of type war.

I solve my problem by putting all these dependencies in a profile that is enabled by default. A hack perhaps, but it works.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文