Reputation: 333
I thought both define the same - JVM properties, but there is obviously a difference between those two and I cannot find a clear explanation. If I use both in Jenkins Maven built, only properties set by -D are visible in Java application by System.getProperties(). Although MAVEN_OPTS should be passed to JVM as well. Seems like I am missing something.
Thx for the explanation.
Upvotes: 4
Views: 11767
Reputation: 2481
MAVEN_OPTS is an environment variable that lets you pass parameters to the Java VM running Maven.
Thus, you can do things like set the heap and perm size using it (e.g. MAVEN_OPTS=-XX:MaxPermSize=256m).
In contrast, the -D parameter are command line parameters. Maven is already running in Java, so you wouldn't be able to control Java related parameters.
See this page for an explanation of command line parameters and MAVEN_OPTS.
Based on that, I'm guessing the reason why you don't see the variable is because it's being used as a JVM argument rather than a property.
Perhaps this answer will help you get them?
Upvotes: 4