[英]pom config inheritance - maven surefire plugin
I have a java project the has 3 "levels" in it.我有一个 Java 项目,其中有 3 个“级别”。 The pom in my top maven directory is looks like this:我的顶级 maven 目录中的 pom 如下所示:
<groupId>com.my_app</groupId>
<artifactId>my_app</artifactId>
<version>LATEST-SNAPSHOT</version>
<modules>
<module>first_module</module>
<module>second_module</module>
</modules>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<parallel>classes</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
</plugins>
first_module (second level) pom is: first_module (第二级)pom 是:
<parent>
<groupId>com.my_app</groupId>
<artifactId>my_app</artifactId>
<version>LATEST-SNAPSHOT</version>
</parent>
<groupId>com.my_app.first_module</groupId>
<artifactId>first_module</artifactId>
<version>LATEST-SNAPSHOT</version>
...
<plugins>
<plugin>
<version>2.22.1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
and finally, ( 3rd level ) the pom the of the project that actually has test classes in it:最后,(第 3 级)项目中实际包含测试类的 pom:
<parent>
<artifactId>first_module</artifactId>
<groupId>com.my_app.first_module</groupId>
<version>LATEST-SNAPSHOT</version>
</parent>
<artifactId>my_project</artifactId>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
My question is - does this structure of poms allow for configuration inheritance from the top to the bottom pom?我的问题是 - 这种 pom 结构是否允许从顶部到底部 pom 的配置继承? I mean, if I have the parallel configuration in the first pom in the maven-sirefure-plugin - will it take affect in test classes under first_module and under my_project ?我的意思是,如果我在maven-sirefure-plugin的第一个 pom 中有并行配置 - 它会影响first_module和my_project下的测试类吗?
Use pluginManagement
tag in the parent's pom.在父级的 pom 中使用pluginManagement
标签。 Basically, <pluginManagement/>
defines the settings for plugins that will be inherited by modules in your build:基本上, <pluginManagement/>
定义了将由构建中的模块继承的插件的设置:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<parallel>classes</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Then, in the children's pom:然后,在孩子们的 pom 中:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
You don't need to specify the version, since it's inherited from the parent with all the configuration.您不需要指定版本,因为它是从具有所有配置的父级继承的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.