没有设置属性时,使构建失败的简单方法是什么? [英] What is simple way to fail a build when a property is not set?
问题描述
如标题中所述,如果未在命令行中设置属性,如何以一种最简单的方式修改pom.xml
以使其失败.
As stated in the title, how can I modify - in the simplest manner possible - a pom.xml
in order to make it fails if a property is not set in the command line.
例如,当mvn clean package -Dfoo=bar
成功时,mvn clean package
将失败.
For example, mvn clean package
will fail, when mvn clean package -Dfoo=bar
will succeed.
I'm looking for something like the <prerequisites/>
tag in the pom.xml
(except that <prerequisites/>
only allow me to check the Maven version)...
推荐答案
You can use the requireProperty goal of the maven-enforcer-plugin to fail a build if a property is missing.
请注意,这仅需要设置属性,因此可以在pom的属性部分中进行设置.
Note this only requires that the property is set, so it could have been set in the pom's properties section.
这篇关于没有设置属性时,使构建失败的简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!