儿童 Maven 测试 jar

发布于 2024-12-18 12:45:03 字数 795 浏览 4 评论 0原文

我们的项目中有许多模块,我们希望为其中一些模块启用测试 jar 创建。我尝试将maven jar插件添加到父pom的pluginmanagement

<plugins>
  <pluginManagement>
    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>test-jar</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</pluginManagement>

但是,现在它正在为所有模块创建test-jar。

根据文档:插件管理以大致相同的方式包含插件元素,只不过它不是为该特定项目构建配置插件信息,而是旨在配置从此项目继承的项目构建。但是,这仅配置子级中的plugins元素中实际引用的插件。孩子们完全有权覆盖插件管理定义。

它不应该为我们未包含的模块创建测试 jar,但不知何故它确实如此。我的模块都没有在其构建模块中添加 maven-jar-plugin 。

为了阻止它为所有人创建 test-jar,我只能将其添加到我感兴趣的模块中。

是否有其他更好的解决方案来实现此目的?

We have many modules in our project and we want to enable test-jar creation for some of those. I tried adding maven jar plugin to the parent pom's pluginmanagement

<plugins>
  <pluginManagement>
    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>test-jar</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</pluginManagement>

But, now it is creating test-jar for all the modules.

As per documenation: Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children. The children have every right to override pluginManagement definitions.

It should not create test-jar for the modules we haven't included in, but somehow it does. None of my modules has maven-jar-plugin added in its build module.

To stop it creating test-jar for all, I can add it only in the module I am interested in.

Is there any other better solution to achieve this?

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

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

发布评论

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

评论(1

围归者 2024-12-25 12:45:03

一般来说,你所描述的情况是不可能的。如果我不得不猜测,我会说,由于您的打包类型是 jar,所以 maven-jar-plugin 的配置会插入到您的有效 pom.xml 中。然后,由于配置在那里,它也使用插件管理部分的配置。运行 mvn help: effective-pom 可能会提供一些关于这是否属实的见解。

我还要确保层次结构中的父级不包含由子级继承的 maven-jar-pom 的任何具体配置。如果孩子继承了一个具体部分,我认为这也会触发它包含插件管理配置。

Normally, what your describing shouldn't be possible. If I had to guess, I would say that since your packaging type is jar configuration for the maven-jar-plugin gets inserted into your effective pom. Then, since the configuration is there, it also uses the configuration from the plugin management section. Running mvn help:effective-pom might provide some insight into whether or not this is true.

I would also make sure that no parent in your hierarchy contains any concrete configuration for the maven-jar-pom that would be inherited by children. If the child inherits a concrete section, I think that will also trigger it to include the plugin management configuration.

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