How to control VM arguments for maven-jetty-plugin?
How to set VM arguments for Jetty run from maven-jetty-plugin?
For example, I need to pass -Xmx
arguments to Jetty run by the mvn jetty:run
command.
Solution 1:
The enviroment variable MAVEN_OPTS is the answer. The string content of MAVEN_OPTS is passed to JVM (java.exe).
- Linux: in shell type
export MAVEN_OPTS=....
- Windows: in shell (cmd.exe) type
set MAVEN_OPTS=...
For example: on Windows set MAVEN_OPTS="-Xmx1024m"
sets the heap size of the Maven process to 1024mb.
Update (01.04.2013): Pass it directly to Jetty.
Matthew Farwell (please upvote his answer to give him credit) comes with the solution of using a forked JVM process to run Jetty which is a new feature of the Jetty plugin. This is a better solution as the former runs inside same JVM process as Maven (thus shares memory).
Solution 2:
With more recent versions of the maven-jetty-plugin, you can use mvn:run-forked
. The option jvmArgs will allow you to set -Xmx etc.
For more information, see: jetty:run-forked : Running an unassembled webapp in a separate jvm.
I think the original issue was Starting Jetty in separate JVM.
Solution 3:
It seems like your current approach is correct - when running jetty through maven, jetty is a thread inside the maven process. So increasing maven's heap will increase jetty's heap.
How are you setting MAVEN_OPTS?
One example I found looks like this: MAVEN_OPTS='-Xmx256m -Xms10m' mvn clean jetty:run
Note that MAVEN_OPTS
is an environment variable here, and not passed to the JVM (who wouldn't know what to do with it).