我想更改 maven-surefire-plugin
的默认设置,而不是使用 <reportFormat>brief</reportFormat>
,我想使用<reportFormat>plain</reportFormat>
.
通常,我会通过修改个人 pom
来实现这一点对于一个项目,例如:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reportFormat>plain</reportFormat>
</configuration>
</plugin>
但是,是否可以以某种方式修改 ~/.m2/settings.xml
文件并设置 <reportFormat>plain</reportFormat>
作为我想要编译的所有 Maven 项目的默认行为。
我对许多 Maven 项目进行了分析,因此我更愿意更改全局级别的行为,而不是修改 pom
每个单独项目的文件。
最佳答案
settings.xml
配置文件不会详细到这个级别。插件配置只能在pom.xml中指定
检查它的最佳方法是研究 settings.xml 架构:
https://maven.apache.org/xsd/settings-1.0.0.xsd
您可以看到引用“plugin”一词的单个元素与构建中的插件配置没有关系。
根据您的要求,如果使用不当,单一解决方案也有其缺点,即使用定义插件配置的父 pom,并且所有 Maven 模块都应将其作为父级,以从插件配置继承,并可能从其他事物继承。< br/>
如果您的应用项目使用多模块/父pom结构,我认为更好的解决方案是在每个多模块/父pom的父pom中声明此配置。
通过这种方式,您可以多次声明它,但通过一组相关项目声明一次。
关于java - .m2/settings.xml 中 Maven Surefire 插件的全局更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43866302/