I'm trying to inject a property into a java project when it is built by maven, by injecting the property via the command line, like
mvn clean install -DMYPROP=myProperty
I thought this was enough to have maven transform this into a System property, which could then be accessed in java via System.getProperty("MYPROP")
. But this hasn't worked.
So I did more research, one post here pointed to Maven Properties, so I tried the following, in the pom.xml:
<properties>
<MY.VARIABLE>${MYPROP}</MY.VARIABLE>
<MY.ENV.VARIABLE>${env.MYPROP}</MY.ENV.VARIABLE>
</properties>
This is not working either. All the following properties are null
System.getProperty("MYPROP")
System.getProperty("MY.VARIABLE")
System.getProperty("MY.ENV.VARIABLE")
I've also tried using a properties-maven-plugin, based on another question. That property was null as well.
Any suggestions?