Maven property overloading

5.9k views Asked by At

I have very simple maven descriptor which defined some properties:

<?xml version="1.0"?>
<project
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  http://maven.apache.org/xsd/maven-4.0.0.xsd"
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <properties>
    <it.port>8080</it.port>
  </properties>

</project>

I can override it.port property with command:

$ mvn -Dit.port=8181 verify

But following command doesn't work as expected:

$ MAVEN_OPTS="-Dit.port=8181" mvn verify

This pass system variable to the JVM but maven refuse to override this property and default value given to test (8080). Original problem is that TeamCity (out CI server) pass system variables to the JVM in MAVEN_OPTS, so property overriding doesn't work.

Can I override maven properties with MAVEN_OPTS environment variable?

1

There are 1 answers

0
krosenvold On BEST ANSWER

No you can't. You can:

  • Use settings.xml on your local machine to specify the property
  • Use a profile in the project pom
  • Use -D directly on the command line.