Maven property overloading

大兔子大兔子 提交于 2020-01-11 05:05:52

问题


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:


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.


来源:https://stackoverflow.com/questions/4826128/maven-property-overloading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!