Reputation: 8654
I'd like to set a system environment variable to be visible by Java code in the unit tests of a Maven project. I tried this:
mvn -Dfoo=bar clean package
But that doesn't seem to take. How do I accomplish this?
Upvotes: 0
Views: 9116
Reputation: 630
You should be able to use a Maven Property in your pom.xml
Check the Properties section of http://maven.apache.org/settings.html#Activation
or maybe this question might help How to identify and set a missing environment property in Maven?
Edit: You can also set an environment variable in the section of a plugin like the surefire plugin: Environment Variable with Maven
Upvotes: 1