我可以强制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.