Maven property overloading
Asked Answered
H

1

7

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?

Hendricks answered 28/1, 2011 at 8:10 Comment(1)
I know this is old, but my TeamCity (2017.2.2) is passing the system property as an inline '-D' parameter (according to the logs) but it's still not working. Any ideas?Hanleigh
I
12

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.
Interferon answered 28/1, 2011 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.