简体   繁体   English

如何使用不同的系统属性多次调用 maven 配置文件

[英]How to invoke a maven profile multiple times with different system properties

I have around 15 maven profiles which are identical except that they have different systemPropertyVariables in their configuration.我有大约 15 个 maven 配置文件,它们是相同的,只是它们的配置中有不同的 systemPropertyVariables。 I would like to execute them all with a single command, and I know I can use this: Executing multiple maven profiles我想用一个命令来执行它们,我知道我可以使用这个: Executing multiple maven profiles

Is it possible to do this without having to list all the profiles in the maven command, ie can I make a single profile within my POM file that, in turn, invokes multiple profiles?是否可以这样做而不必在 maven 命令中列出所有配置文件,即我可以在我的 POM 文件中创建一个配置文件,然后调用多个配置文件? Alternatively if I could execute a single profile multiple times with different systemPropertyVariables, that would work too.或者,如果我可以使用不同的 systemPropertyVariables 多次执行单个配置文件,那也可以。

You can activate a profile depending on a property.您可以根据属性激活配置文件。 This can be the same property for many profiles, so using something like -Dsomeprop=true on the command line can activate many profiles for you.这可以是许多配置文件的相同属性,因此在命令行上使用-Dsomeprop=true之类的内容可以为您激活许多配置文件。

That said, having 15 profiles is quite unusual and you should analyse whether your construction is too complicated.也就是说,拥有 15 个配置文件是非常不寻常的,您应该分析您的构建是否过于复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM