我的 pom.xml 中有一些 maven 配置文件。我将 jenkins 配置为每晚对这些配置文件运行测试。
我今天发现我的 jenkins 配置中的一个配置文件名称存在拼写错误。事实证明,如果 maven 无法提交配置文件,它会运行默认配置文件。
如果配置文件不存在,有没有办法强制 maven 抛出错误?
请您参考如下方法:
Maven Enforcer 插件版本 3.0.0-M2 引入了一个内置检查 requireProfileIdsExist以此目的:
When running Maven with one or more unknown profile ids, Maven will give you a warning. This rule will actually break the build for that reason.
Here is how a project should be setup to use this rule
<project> ... <build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>3.0.0-M2</version> <executions> <execution> <id>enforce</id> <configuration> <rules> <requireProfileIdsExist/> </rules> </configuration> <goals> <goal>enforce</goal> </goals> </execution> </executions> </plugin> ... </plugins> </build> ... </project>


