[英]pom config inheritance - maven surefire plugin
我有一個 Java 項目,其中有 3 個“級別”。 我的頂級 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 (第二級)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>
最后,(第 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>
我的問題是 - 這種 pom 結構是否允許從頂部到底部 pom 的配置繼承? 我的意思是,如果我在maven-sirefure-plugin的第一個 pom 中有並行配置 - 它會影響first_module和my_project下的測試類嗎?
在父級的 pom 中使用pluginManagement
標簽。 基本上, <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>
然后,在孩子們的 pom 中:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
您不需要指定版本,因為它是從具有所有配置的父級繼承的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.