我可以强制Maven 2要求在命令行上指定属性吗? [英] Can I force Maven 2 to require a property to be specified on the command line?

查看:98
本文介绍了我可以强制Maven 2要求在命令行上指定属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置Maven构建,并且需要在命令行上将目标服务器指定为属性(然后用于选择适当的配置文件),例如

I'm setting up a maven build, and the destination server needs to be specified on the command line as a property (which is then used to select the appropriate profile), eg

mvn -Denv=test

如果属性未设置,我希望构建失败-可能吗?

I'd like the build to fail if the property's not set - is that possible?

是的,我是Maven新手.

Yes, I'm a Maven newbie.

编辑:我见过此链接,这似乎表明这是不可能的,但不确定如何更新.

I've seen this link, which seems to imply it's not possible, but am not sure how up to date it is.

推荐答案

每个人都很亲密,但是强制执行程序中有一条规则专门检查属性,不需要蚂蚁或时髦的配置文件:

Everyone is close, but there's a rule in the enforcer to specifically check for a property, no ant or funky profiles required: http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html

规则还可以检查属性的值.

The rule can also check the value of the property.

这篇关于我可以强制Maven 2要求在命令行上指定属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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