javamavenenvironment-variablespom.xml

How to refer environment variable in POM.xml?


I am using Maven as build tool. I have set an environment variable called env. How can I get access to this environment variable's value in the pom.xml file?


Solution

  • Check out the Maven Properties Guide...

    As Seshagiri pointed out in the comments, ${env.VARIABLE_NAME} will do what you want.

    I will add a word of warning and say that a pom.xml should completely describe your project so please use environment variables judiciously. If you make your builds dependent on your environment, they are harder to reproduce