没有设置属性时,使构建失败的简单方法是什么? [英] What is simple way to fail a build when a property is not set?

查看:71
本文介绍了没有设置属性时,使构建失败的简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如标题中所述,如果未在命令行中设置属性,如何以一种最简单的方式修改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.

我正在寻找类似<prerequisites/>

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆