如何在Maven中定义条件属性? [英] How to define conditional properties in maven?

查看:74
本文介绍了如何在Maven中定义条件属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果有环境变量AAA,我希望将属性Configuration设置为${env:AAA},如果没有环境变量,则希望将属性Configuration设置为其他常量值.

For instance, I would like to have property Configuration set to ${env:AAA} if there is an environment variable AAA and to some other constant value if there is no such environment variable.

我如何在Maven 2中做到这一点?

How do I do it in maven 2?

推荐答案

似乎您有条件地激活个人资料 ...

<profiles>
  <profile>
    <activation>
      <property>
        <name>environment</name>
        <value>test</value>
      </property>
    </activation>
    ...
  </profile>
</profiles>

按以下命令将环境变量定义为值test时,将激活配置文件:

The profile will be activate when the environment variable is defined to the value test as in the following command:

mvn ... -Denvironment=test

这篇关于如何在Maven中定义条件属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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