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.
How do I do it in maven 2?
It appears as though you activate a profile conditionally...
<profiles>
<profile>
<activation>
<property>
<name>environment</name>
<value>test</value>
</property>
</activation>
...
</profile>
</profiles>
The profile will be activate when the environment variable is defined to the value test
as in the following command:
mvn ... -Denvironment=test
On the off-chance that a system property is acceptable, you can simply define the property in your POM file and override when required:
<project>
...
<properties>
<foo.bar>hello</foo.bar>
</properties>
...
</project>
You can reference this property elsewhere in your POM by referring to ${foo.bar}
. To override on the command line, just pass a new value:
mvn -Dfoo.bar=goodbye ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With